7 q & a – Campbell Scientific CR800 and CR850 Measurement and Control Systems User Manual

Page 221

Advertising
background image

Section 7. Installation

221

 

7.8.8.7 Q & A

Q: I am writing a CR800 program to transmit a serial command that contains a
null character. The string to transmit is:

CHR(02)+CHR(01)+"CWGT0"+CHR(03)+CHR(00)+CHR(13)+CHR(10)

How does the logger handle the null character?

Is there a way that we can get the logger to send this?

A: Strings created with CRBasic are NULL terminated. Adding strings together
means the 2nd string will start at the first null it finds in the first string.

Use SerialOutBlock() instruction, which lets you send null characters, as shown
below.

SerialOutBlock

(COMRS232, CHR(02) + CHR(01) + "CWGT0" +

CHR(03),8)

SerialOutBlock

(COMRS232, CHR(0),1)

SerialOutBlock

(COMRS232, CHR(13) + CHR(10),2)

 

Q: Please explain and summarize when the CR800 powers the RS-232 port. I get
that there is an "always on" setting. How about when there are beacons? Does the
SerialOpen() instruction cause other power cycles?

A: The RS-232 port is left on under the following conditions: 1) when the setting
RS-232Power is set, or 2) when a SerialOpen() with argument

COMRS232

is

used in the program. Both of these conditions power up the interface and leave it
on (with no timeout). If SerialClose() is used after SerialOpen(), the port is
powered down and in a state waiting for characters to come in.

Under normal operation the port is powered down waiting for input. After
receiving input, there is a 40-second software timeout that must expire before
shutting down. The 40-second timeout is generally circumvented when
communicating with the datalogger support software

(p. 76)

because the software

sends information as part of the protocol that lets the CR800 know that it can shut
down the port.

When in the "dormant" state with the interface powered down, hardware is
configured to detect activity and wake up, but there is the penalty of losing the
first character of the incoming data stream. PakBus® takes this into consideration
in the "ring packets" that are preceded with extra sync bytes at the start of the
packet. For this reason SerialOpen() leaves the interface powered up so no
incoming bytes are lost.

When the CR800 has data to send via the RS-232 port, if the data are not a
response to a received packet, such as sending a beacon, it will power up the
interface, send the data, and return to the "dormant" state with no 40-second
timeout.

 

Q: How can I reference specific characters in a string?

A: Accessing the string using the third dimension allows access to the remainder
of the string that starts at the third dimension specified. For example if

TempData = "STOP",

Advertising