SerialOpen() instruction cause other power cycles?
A: The RS-232 port is left on under the following conditions:
• When the setting RS-232Power
(p. 627) is set
• When a SerialOpen() with argument COMRS232 is used in the program
Both 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. 95) because the software
sends information as part of the protocol that lets the CR1000 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 CR1000 has data to send with 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: The third 'dimension' of a string variable provides access to that part of the
string after the position specified. For example, if
TempData = "STOP"
then,
TempData(1,1,2) = "TOP"
TempData(1,1,3) = "OP"
TempData(1,1,1) = "STOP"
To handle single-character manipulations, declare a string with a size of 1. This
single-character string is then used to search for specific characters. In the
following example, the first character of string LargerString is determined and
used to control program logic:
Public TempData As String * 1
TempData = LargerString
If TempData = "S" Then...
A single character can be retrieved from any position in a string. The following
example retrieves the fifth character of a string:
Public TempData As String * 1
TempData = LargerString(1,1,5)
Q: How can I get SerialIn(), SerialInBlock(), and SerialInRecord() to read
extended characters?
265