Notice: Constant DATE_RFC7231 already defined in /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc on line 258
Binary and Hex Comms | ComScript Manual

Error message

  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 690 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 691 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 692 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 695 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 697 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 290 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 291 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 299 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 306 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_settings_initialize() (line 860 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_settings_initialize() (line 869 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: session_name(): Cannot change session name when headers already sent in drupal_settings_initialize() (line 872 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in _drupal_bootstrap_page_cache() (line 2485 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: session_set_save_handler(): Cannot change save handler when headers already sent in drupal_session_initialize() (line 242 of /home2/greeneye/public_html/comscript_manual/includes/session.inc).
  • Warning: session_id(): Cannot change session id when headers already sent in drupal_session_initialize() (line 266 of /home2/greeneye/public_html/comscript_manual/includes/session.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in book_prev() (line 775 of /home2/greeneye/public_html/comscript_manual/modules/book/book.module).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home2/greeneye/public_html/comscript_manual/includes/common.inc).

Binary and Hex Comms

While the majority of devices that ComScript is used with communicate in regular ASCII text, some use binary communication which is more efficient and can speed up computer and device communication (for more on binary numerals visit http://en.wikipedia.org/wiki/Binary_numeral_system).  ComScript supports binary communication with connected devices by setting the type attribute in the send or collect commands to Hex(hexadecimal).
 
Ex. 1: <send type="Hex" string="FF" />
This command will send out an 8 bit, binary array of 1s (i.e. 11111111) which equals FF in hex and 255 in decimal.
 
Tip: The windows calculator easily converts between decimal, hex and binary.  Be sure to click "scientific" under the view menu for this functionality.
 
Ex. 2: <send type="Hex" string="FE" behavior="TT" trigger="63" terminator="64" var="HexResponse" />
 
Let's suppose that our set device is an anemometer that communicates in binary with an RS232 serial connection.  When the anemometer receives a binary value of 254 (FE in hex) it responds with a binary acknowledgement value of 63 (99 in decimal), the wind speed, the wind direction and an \"end of data\" indicator binary value of 64 (100 in decimal).  A potential response in hex would look like 63, 10, 0163, 64, but each value would not be separated by commas so it would come over the serial port as 5510016364.  That is 10 characters or 5 bytes (8 binary bits/byte).  The first acknowledgement byte of 55 (99 in decimal), the wind speed byte of 10 (16 in decimal), two bytes for wind direction 0163 (355 in decimal), and the terminating 64 byte (100 in decimal).  Note that wind direction requires two bytes because the maximum value that can be represented in 1 byte is FF or decimal 255 and wind direction could range from 0-359.  Because the trigger and terminator are set to 63 and 64 respectively for the acknowledgement and terminating bytes, the variable HexResponse would equal 100163.
 
A hex string like 100163 does not mean much to most of us and ComScript can't fully evaluate hex values with conditional expressions.  Thus, ComScript provides the parse command to convert hex arrays into individual decimal numbers.  In example 3 below, ComScript will convert hex 10 into decimal 16 and hex 0163 into decimal 355, and insert those values into variables WindSpeed and WindDirection respectively.
 
Ex. 3: <parse hexvar="HexResonse" vars="WindSpeed, WindDirection" type="hex2vars" /> Note: no square brackets [ ] around the hexvar attribute "HexResponse", because it is being set, not referenced.
 
So that ComScript knows how many bytes to insert into each variable, the size of WindSpeed and WindDirection must be previously declared with the set command as indicated below.
 
  <set vars="WindSpeed,WindDirection" type="uint8,uint16" />

The type attribute controls the number of bytes to store into the variable (see table below).  A uint8 is an 1 byte unsigned integer and a uint16 is a 2 byte unsigned integer.

Please refer to the BinaryComms and HexDecimalConversion profile examples that can be downloaded from the ComScript web site for more information on binary communications and hex and decimal conversion. 
 
Common Error: ComScript will output the error message "The given key was not present in the dictionary" when parsing hex varaiables into decimal if the hex variables were not defined.  The size of the hex variable must be defined with the set command or in the config.xml file.

Type

Bytes

Range of Values

byte (default)

1

0 to +255

char

2

0 to +65535

int16

2

-32768 to +32767

int32

4

-2,147,483,648 to +2,147,483,647

int64

8

-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807

uint16

2

0 to +65,535

uint32

4

0 to +4,294,967,295

uint64

8

0 to +1.84467440737E+19

float

4

single precision floating point -3.402823e38 to +3.402823e38

double

8

double precision floating point -1.79769313486232e308 to +1.79769313486232e308