Class

COMPort

COMPort(port, baud, bits, parity, stop, flow, addropt, irqopt)

Constructor

# new COMPort(port, baud, bits, parity, stop, flow, addropt, irqopt)

open a COM port.

Note: COMPort module must be loaded by calling LoadLibrary("comport") before using!

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

See:
  • LoadLibrary()

Methods

# Close()

close port.

# FlushInput()

flush input buffer.

# FlushOutput()

flush output buffer.

# 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

# IsOutputFull() → {boolean}

check state of send buffer.

true if the output buffer is full.

boolean

# ReadBuffer() → {string}

read a string from the receive buffer.

contents of the received buffer.

string

# ReadByte() → {number}

read a byte from COM port

the value of the byte.

number

# 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.