Class

COMPort

COMPort(port, baud, bits, parity, stop, flow, addr, irq)

Constructor

# new COMPort(port, baud, bits, parity, stop, flow, addr, irq)

Open a COM port. Note: COM port functions must be activated/loaded by calling LoadLibrary("comport")!
Parameters:
Name Type Description
port COM one of COM.PORT.x
baud COM one of COM.BAUD.x
bits COM one of COM.BIT.x
parity COM one of COM.PARITY.x
stop COM one of COM.STOP.x
flow COM one of COM.FLOW.x
addr number COM port address, optional.
irq number COM port IRQ, optional.

Methods

# Close()

close the COM port.

# FlushInput()

Flushes the input buffer.

# FlushOutput()

Flushes the output buffer.

# IsInputEmpty() → {boolean}

check if there is data in the input buffer.
true if the buffer is empty.
boolean

# IsInputFull() → {boolean}

check if the input buffer is full.
true if the buffer is full.
boolean

# IsOutputEmpty() → {boolean}

check if there is data in the output buffer.
true if the buffer is empty.
boolean

# IsOutputFull() → {boolean}

check if the output buffer is full.
true if the buffer is full.
boolean

# ReadBuffer() → {string}

read a string from input buffer. Max length is 4096 byte.
a string composed from the input buffer. for an empty buffer "" is returned.
string

# ReadChar() → {number}

read a char from input buffer.
a char as number or null if none available.
number

# Write(str) → {number}

Write a string to COM port.
Parameters:
Name Type Description
str string the string to send.
the amount of bytes written to the output buffer (might be less than string length).
number

# WriteChar(ch)

Write char to COM port.
Parameters:
Name Type Description
ch number byte value to write.