Section 7.  Installation 
 
209
1.  Open a serial port (SerialOpen() command) to configure it for 
communications. 
•  Parameters are set according to the requirements of the communications link 
and the serial device. 
•  Example: 
SerialOpen(Com1,9600,0,0,10000) 
•  Designate the correct port in CRBasic. 
•  Correctly wire the device to the CR800. 
•  Match the port's baud rate to the baud rate of the device in CRBasic. 
•  Use a fixed baud rate (rather than auto baud) when possible. 
2.  Build the output string. 
•  Example:  
SerialOutString = "*" & "27.435" & "," & "56.789" & "#" 
•  Tip — Concatenate (add) strings together using & instead of +. 
•  Tip — CHR() instruction is used to insert ASCII / ANSI characters into a 
string. 
3.  Output string via the serial port (SerialOut() or SerialOutBlock() command). 
•  Example: 
SerialOut(Com1,SerialOutString,"",0,100) 
•  Declare the output string variable large enough to hold the entire 
concatenation. 
•  Example: 
Public SerialOutString As String * 100 
•  SerialOut() and SerialOutBlock() output the same data, except that 
SerialOutBlock() transmits null values while SerialOut() strings are 
terminated by a null value. 
 
7.8.8.5.4 Translating Bytes 
One or more of three principle data formats may end up in the SerialInString() 
variable (see examples in Serial Input Programming Basics
 (p. 207) ). Data may be 
combinations or variations of all of these. The manufacturer of the instrument 
must provide the rules by which data are to be decoded. 
•  Alpha-numeric: Each digit represents its own alpha-numeric value. For 
example, R = the letter R, and 2 = decimal 2. This is the easiest protocol to 
translate since the literal translation is what is received from the transmitting 
instrument.  Normally, the CRBasic program receiving the transmission will 
be written to parse (split) the string up and place the values in CR800 
variables. 
Example (humidity, temperature, and pressure sensor): 
SerialInString = "RH= 60.5 %RH T= 23.7 °C Tdf= 15.6 °C Td= 
15.6 °C a= 13.0 g/m3   x=   11.1  g/kg    Tw= 18.5  °C H2O=