...
OpenPort | Opens the serial port. |
Function | n=OpenPort(PortNo., BaudRate, Parity, Data Bit, Stop Bit) |
Description | PortNo. (use predefined constant, _COMxxx_) BaudRate (use predefined constant, _BPSxxx_) Parity (use predefined constant, _PARITY_xxx_) Data Bit (7 or 8) Stop Bit (use predefined constant, _STOPBIT_xxx_) This function opens the assigned serial port. You cannot use this function if the port has already been opened. Once you opened the COM port with the script, it must be closed with ClosePort() function. If an error occurs during the port opening, the script will return 0. If the port opened successfully, the script would return a value other than 0. |
Example | Opens COM1 port with the following options; RS485, 19200bps, No Parity, Data Bit 8, Stop Bit 1. OpenPort(_COM485_, _BPS19200_, _PARITY_NONE_, 8, _STOPBIT_ONE_); |
ReceiveByte | Receives data with the selected port. |
Function | ReceiveByte(PortNo., Data) |
Description | PortNo. (use predefined constant, _COMxxx_) Data (0~255) This function is used when you wish to receive a data with the COM port that was previously opened by the OpenPort() function. Once you receive the data successfully, the Data (0~255) will be stored in the variable. If there is no received data until the timeout, the script will return 256. The OpenPort() function must be used before the execution of the ReceiveByte() function. |
Example | Receives byte data through the COM1 port which uses RS485 communication. Saves the received data at the variable ‘RxData’. VAR RxData; OpenPort(_COM485_, _BPS19200_, _PARITY_NONE_, 8, _STOPBIT_ONE_); RxData = ReceiveByte(_COM485_, 1000); If(RxData < 256) { } …… |
SendByte | Sends byte data through the selected port. |
Function | n=SendByte(PortNo., Data) |
Description | PortNo. (use predefined constant, _COMxxx_) Data (0~255) This function is used when you wish to transmit a data with the COM port that was previously opened by the OpenPort() function. Data must be a byte data in the range of 0(0x00) to 255(0xFF). If the data is greater than 255(0xFF), only the lower byte will be transmitted. For example, if you assign Data with 0x1234, only 0x34 will be transmitted. The OpenPort() function must be used before the execution of the SendByte() function. If an error occurs during the data transmission, the script will return 0. If the data transmitted successfully, the script would return a value other than 0. |
Example | Transmits byte data “2” through COM1 port which uses RS485 communication. SendByte(_COM485_, 2); |
...
SendString | Sends string data through the selected port. |
Function | SendString(PortNo., Data) |
Description | PortNo. (use predefined constant, _COMxxx_) Data (Enter the String Tag or “String”) This function is used when you wish to transmit a data with the COM port that was previously opened by the OpenPort() function. The Data must be assigned with a string tag or string data. If you use the string data, it must be used with double quotation marks (“ “). The OpenPort() function must be used before the execution of the SendString() function. If an error occurs during the data transmission, the script will return 0. If the data transmits successfully, the script will return a value other than 0. |
Example | Transmits string data “TEXT” through COM1 port which uses RS485 communication. SendString(_COM485_, “TEXT”); |
...