SerialInChk (Number of Serial In Characters)
The SerialInChk function is used to return the number of characters available in the datalogger's serial buffer, which can be read by SerialIn or SerialInBlock.
Syntax
SerialInChk ( ComPort )

In the following example, serial data that is received over the datalogger's RS232 port is stored into a string. After 20 characters are received, the remaining serial buffer is cleared using the SerialFlush function. SerialInChk is used to monitor the number of characters received.
Public InString As String * 25
DataTable (SerialT,True,-1)
Sample (1,InString,String)
EndTable
BeginProg
Scan (5,Sec,3,0)
SerialOpen (ComRS232,
If SerialInChk(ComRS232) > 20 Then SerialFlush (ComRS232)
SerialIn (InString,ComRS232,100,0,20)
CallTable (SerialT)
NextScan
EndProg
Remarks
A variable can hold the result of the SerialInChk function (variable = SerialInChk(Comport)) or the function can be used in an expression (If SerialInChk(Comport)>20 Then…). If the serial port has not been opened (using SerialOpen), a -1 is returned. If the serial port buffer overflows before it has been read, it is reset to 0 and the remainder of the bytes available is returned by the function. For instance, if you have a buffer of 100 bytes, and 120 bytes come in before the buffer is read, SerialInChk returns a value of 20 (the last 20 bytes received). In this instance, there is no way to detect that the buffer has overflowed and been reset.
Beginning with OS
This instruction can also be used along with other serial instructions to set up and control the SDM-SIO1A or SDM-SIO4A or SDM-SIO2R.
Parameter
ComPort_Serial_In (Communications Port Serial In)
The COM port that will be used by the instruction. Right-click to display a list.
Alphanumeric | Description |
---|---|
ComRS232 | RS232 port of the datalogger |
ComUSB | Datalogger's USB port |
ComMe | Datalogger's CS I/O port;modem enabled |
Com310 | Datalogger's CS I/O port; Com310 modem |
Com320 | Datalogger's CS I/O port; Com320 modem |
ComSDC7 | Datalogger's CS I/O port; SDC7 |
ComSDC8 | Datalogger's CS I/O port; SDC8 |
ComSDC10 | Datalogger's CS I/O port; SDC10 |
ComSDC11 | Datalogger's CS I/O port; SDC11 |
ComC1 | Datalogger's control ports 1 (TX) & 2 (RX) |
ComC3 | Datalogger's control ports 3 (TX) & 4 (RX) |
ComU1 | Universal terminal pair U1 (TX) & U2 (RX) |
ComU3 | Universal terminal pair U3 (TX) & U4 (RX) |
ComU5 | Universal terminal pair U5 (TX) & U6 (RX) |
ComU7 | Universal terminal pair U7 (TX) & U8 (RX) |
ComU9 | Universal terminal pair U9 (TX) & U10 (RX) |
ComU11 | Universal terminal pair U11 (TX) & U12 (RX) |
ComRF | Integrated RF communication |
Type: Constant. For all instructions except SerialOpen, this parameter can also be a variable. However, if a variable is used, the port must be opened previously by SerialOpen (Open Communication Port)
A variable can be used in the ComPort parameter for use with functions that return a communication port. If communication occurs using TCP/IP, enter the variable for the socket returned by TCPOpen.