Specifications
Section 10. CRBASIC Programming Instructions
10-31
The ComPort parameter sets a default communications port when a route to the
remote node is not known. Enter one of the following commands:
ComRS-232
ComME
Com310
ComSDC7
ComSDC8
ComSDC10
ComSDC11
Com1 (C1,C2)
Com2 (C3,C4)
Com3 (C5,C6)
Com4 (C7,C8)
Baud rate on asynchronous ports (ComRS-232, ComME, Com1, Com2, Com3,
and Com4) will default to 9600 unless set otherwise by SerialOpen(), or if the
port is opened by an incoming PakBus packet at some other baud rate.
The baud rate parameter on asynchronous ports is restricted to 300, 1200,
4800, 9600, 19200, 38400, 57600, 115200, with 9600 the default.
In general, PakBus instructions write a result code to a variable indicating
success or failure. Success sets the result code to 0. Otherwise, the result code
increments. If communication succeeds but an error is detected, a negative
result code is set. See CRBASIC Editor Help for an explanation of error codes.
The Timeout parameter in these instructions is in units of 0.01 seconds. If 0 is
used, then the default timeout defined by the time of the best route is used. Use
PakBusGraph “Hop Metrics” to calculate this time.
For instructions returning a result code, retries can be coded with CRBASIC
logic as shown in the GetVariables example in EXAMPLE 10.12-1:
E
XAMPLE 10.12-1. CRBASIC Code: Programming for retries in PakBus peer-to-peer
communications.
For I = 1 to 3
GetVariables (ResultCode,….)
if ResultCode = 0 Exit For
Next
These communication instructions wait for a response or timeout before the
program moves on to the next instruction. However, they can be used in a
SlowSequence scan, which will not interfere with the execution of other
program code. Optionally, the ComPort parameter can be negated, which will
cause the instruction not to wait for a response or timeout. This will make the
instruction execute faster but any data that it retrieves and the result code will
be set when the communication is complete.
Broadcast
Sends a broadcast message to a PakBus network.
Syntax
Broadcast (ComPort, Message)