Constructor
# new COMPort(port, baud, bits, parity, stop, flow, addropt, irqopt)
open a COM port.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
port |
number | one of COM.PORT: COM1, COM2, COM3, COM4. | |
baud |
number | one of COM.BAUD: B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, B9600, B19200, B38400, B57600, B115200 | |
bits |
number | one of COM.BIT: BITS_5, BITS_6, BITS_7, BITS_8 | |
parity |
number | one of COM.PARITY: NO_PARITY, ODD_PARITY, EVEN_PARITY, MARK_PARITY, SPACE_PARITY | |
stop |
number | one of COM.STOP: STOP_1, STOP_2 | |
flow |
number | one of COM.FLOW: NO_CONTROL, XON_XOFF, RTS_CTS | |
addr |
number |
<optional> |
optional: port io address |
irq |
number |
<optional> |
optional: port IRQ |
Methods
# IsInputEmpty() → {boolean}
check state of receive buffer.
true if the input buffer is empty.
boolean
# IsInputFull() → {boolean}
check state of receive buffer.
true if the input buffer is full.
boolean
# IsOutputEmpty() → {boolean}
check state of send buffer.
true if the output buffer is empty.
boolean
# ReadBuffer() → {string}
read a string from the receive buffer.
contents of the received buffer.
string
# WriteByte(ch)
Write a single byte to COM port.
Parameters:
Name | Type | Description |
---|---|---|
ch |
number | the byte to write. |
# WriteString(txt)
Write a string to COM port.
Parameters:
Name | Type | Description |
---|---|---|
txt |
string | the string to write. |