SerSend
(Engine-Level Function)
Description: | Serial Port Send. This function writes a string to the transmit buffer and returns the number of bytes written. |
Returns: | Numeric |
Usage: | Script Only. |
Function Groups: | Serial Port |
Related to: | COMPort | SerCheck | SerIn | StrLen | SerOut | SerRcv | SerRTS | SerStrEsc | SerString | SerWait |
Format: | SerSend(Port, Buffer, MaxBytes, Escape) |
Parameters: |
Port |
Required. Any numeric expression for the serial port number (opened with a ComPort function) or any stream value. |
Buffer |
Required. Any text expression to send. |
MaxBytes |
Required. Any numeric expression which gives the maximum number of bytes to send. |
Escape |
Required. Any numeric expression which gives the byte value of an escape code. Whenever an escape code is encountered, two escape codes will be transmitted. To be valid, Escape must be in the range of 0 to 255. If the Escape parameter is greater than 0 or less than 256, it is transmitted with escape codes. If Escape is a value greater than 255, it will perform in the same manner that it would if Escape were a value of 0. If the value of Escape is less than 0, it doesn't take into account escape codes and the buffer is transmitted in its entirety, stopping at MaxBytes. |
Comments: | The return value is the actual number of buffer bytes successfully placed in the transmit buffer (not including extra escape codes). MaxBytes should be transmitted, unless the end of the buffer is encountered, or a transmit buffer overflow occurs. |
Example:
If MatchKeys(2, "S"); [ SerSend(2, "Hello World ", 12, 0); ]
The code above sends the message "Hello World" through serial port 2.