beautypg.com

C.5 example crbasic get program – Campbell Scientific CS125 Present Weather Sensor User Manual

Page 64

background image

CS125 Present Weather Sensor

C-10

C.5 Example CRBasic GET program

'-------------------------------------------------------------------------------
' CS125 Visibility
'
' Program to test the GET command part of the command line interface on the CS125
' Connecting to serial port one on a CR1000 logger
' Logger:CR1000
'
' Example outputs including checksums (varies with sensor ID)
' GET:0:0:2C67:
' GET:1:0:1B57:
' GET:2:0:4207:
' GET:3:0:7537:
' GET:4:0:F0A7:
' GET:5:0:C797:
' GET:6:0:9EC7:
' GET:7:0:A9F7:
' GET:8:0:85C6:
' GET:9:0:B2F6:
'-------------------------------------------------------------------------------
Public OutString As String * 40 ' Outgoing string
Dim CheckVal As Long ' Checksum value
Public InString As String * 200 ' Incomming string
Dim TempString As String * 16

'Main Program
BeginProg

SerialOpen (Com1,38400,3,0,10000) ' open port to the visibility sensor

' Send a request for information once every 10 seconds
Scan (10,Sec,0,0)

' Create the basic GET string for the CS125
TempString = "GET:0:0"
CheckVal = CheckSum (TempString,1,0) ' Use the CCITT CRC16 checksum
OutString = CHR(2) + TempString + ":" + FormatLong (CheckVal,"%04X") + ":" + CHR(3)
+ CHR(13) + CHR(10)

SerialOut (Com1,OutString,"",0,100) ' Send GET command to the CS125

Delay (1,1,Sec)

SerialIn (InString,Com1,100,0,200) ' Save the data returned from the GET command

NextScan
EndProg