Set Until channel, packetLength[, stopChar]
channel | RS232 channel. (1 to 3) |
packetLength | Length of packet (0 to 255) |
stopChar | Character to catch |
charCheck | (Optional) Whether to use stopChar |
0 = Check Char (default) | |
1 = Don’t Check Char |
This is a conditional statement you can put right after the On Recv command. Normally, the On Recv interrupt is generated when a single byte is received via the specified serial port. Set Until can be used to only generate an interrupt when either packetLength bytes are received, or stopChar is detected.
packetLength is used to interrupt stopChar never arrives. To interrupt only on packetLength, set charCheck to 1.
You MUST use this command with the On Recv command. The following is an example:
Dim A(5) As Byte OpenCom 1,19200,0, 100, 50 On Recv1 DATARECV_RTN Set Until 1,99,"S"
As you can see above, the packet size is 99 bytes. In other words, if character “S” is not received within 99 bytes, an interrupt will occur. The stop character may also be written in decimal form as shown below:
Set Until 1,100,4
In the following example, an interrupt be generated only when the packet length is greater than or equal to 5. charCheck is 1 so stopChar is ignored.
Set Until 1,5,0,1