I am trying to read an RS232 sensor with a CR350 with this code:
Public SerialIndest As String * 100, NBytesReturned
BeginProg
SerialOpen(COM2,9600,0,0,50)
Scan (5,Sec,3,0)
'Send command to take a measurement
SerialOutBlock(Com2,"*0100P3"+CHR(13)+CHR(10),9)
'Wait for sensor to respond with data
Delay(0,2000,mSec)
'Read the data from the serial buffer
SerialInRecord (COM2,SerialInDest,&H2A30303031,0,&H0D0A,NbytesReturned,01)
NextScan
EndProg
The SerialInDest variable is not showing any data getting returned and just stays NAN.
But when I go into serial watch mode I can see the sensor communicating as expected:
23:03:40.00 T 2A 30 31 30 30 50 33 0D 0A *0100P3.. 23:03:41.34 R 2A 30 30 30 31 2E 30 30 *0001.00 23:03:41.35 R 30 38 32 0D 0A 082.. 23:03:45.00 T 2A 30 31 30 30 50 33 0D 0A *0100P3.. 23:03:46.34 R 2A 30 30 30 31 2E 30 30 *0001.00 23:03:46.35 R 30 38 32 0D 0A 082.. 23:03:50.00 T 2A 30 31 30 30 50 33 0D 0A *0100P3.. 23:03:51.34 R 2A 30 30 30 31 2E 30 30 *0001.00 23:03:51.35 R 30 38 32 0D 0A 082..
Three readings are shown in the above traffic and the expected value in SerialInDest for all 3 should be ".00082"
Any idea what I'm doing wrong?