Software
Crestron
SIMPL+
The Serial Send symbol
simply generates the static
text defined in its parameter
field onto the output serial
signal whenever the trigger
input sees a rising signal.
To make this concept even clearer, consider the following simple example. The
SIMPL program shown below contains two Serial Send symbols, each one triggered
by a button press. The outputs of these symbols are tied together so that both
symbols can generate a string onto the same serial signal. Next this signal is
connected in two places to the SIMPL+ module. The first input is mapped to a
STRING_INPUT and the second is mapped to a BUFFER_INPUT. The declaration
section for this module should appear as follows.
STRING_INPUT theString[100];
BUFFER_INPUT theBuffer[100];
The table below shows the state of these two input variables in response to button
presses.
States of Two Input Variables
ACTION
theString
theBuffer
system initializes
empty
empty
button 1 pressed
“Now is”
“Now is”
button 2 pressed
“the time”
“Now is the time”
button 1 pressed
“Now is”
“Now is the time Now is”
From this table, notice that each time the serial signal changes,
theString
assumes
this value and the old data stored there is lost. On the other hand,
theBuffer
retains
any old data and simply appends the new data onto the end.
A logic wave is the time
needed for a signal to
propagate from the input to
the output of a single logic
symbol. This concept is
discussed fully in
“Understanding Processing
Order” on page 49.
Each application should dictate whether it is appropriate to use a STRING_INPUT
or a BUFFER_INPUT. In general, use STRING_INPUTs when the serial signal that
is feeding it is being driven from a logic symbol like a Serial Send, Analog to Serial,
or Serial Gather. In these cases, the serial data is issued on a single logic wave.
Therefore, it is certain that the entire string is copied into the STRING_INPUT.
If, on the other hand, the signal feeding into the SIMPL+ program comes from a
streaming source such as a serial port, use a BUFFER_INPUT, which can gather up
the data as it “dribbles in.”
To solidify this concept, consider another example. Say the program is written for a
CD jukebox, which is capable of sending text strings containing the current song
information. Typical data received from this device might appear as the following.
Artist=Frank Sinatra, Track=My Way, Album=Very Good Years<CR>
Where the <CR> at the end of the string represents a carriage return character. This
is a relatively long string of data and it is quite possible, even probable, that the
operating system would not remove the entire string from the serial port in one piece.
This is due to the fact that the control system checks the state of the serial ports very
often and removes any data that is found there. Since this data takes some time to
reach the port (depending on the baud rate), it is likely that the port’s input buffer is
collected before the whole string is there. If there was a serial signal called
jukebox_in
connected to the rx terminal on the COM port definition, the program
might be written as follows.
first pass:
jukebox_in = "Artist=Frank Sinatra, Trac"
46
•
SIMPL+
Programming Guide – DOC. 5789A