SourceForge.net Logo

Home- Data Collection- Data Mining- GPL Software- Services- FAQ- Tips

XML Encoded Data

The XML RS232 output looks something like this.
*<w,0,2>552</w,0,2><w,0,1>576</w,0,1><w,0,0>32771</w,0,0>
<n,0,0>3200</n,0,0><n,0,1>502</n,0,1>$
The string is sent to the client PC once per second.

Encoding Scheme

*<Data Type,Station,Element>value</Data Type,Station,Element>$

Data Types
b - Bit        bit using 0 or 1
w - Word       encodes 16 bits using integer values between 0 and 65535
n - Number     Number (float)
Station

0 to 255

Element
Bit      0 to 240
Word     0 to 15
Number   0 to 255
Value
Bit      0 to 1 
Word     0 to 65535
Number   -3.4E+38 to 3.4E+38
Both bit and word data types are used to send bit data. Bit data contains the status of a bit (0 or 1). Word data contains the status (0 or 1) of 16 different bits using a decimal number between 0 and 65535. The same conversion can be done by changing numbering systems on a scientific calculator. Word values are converted from decimal to binary when received.

This example XML string encodes the status of 3 bits from station 3.
*<b,3,0>1</b,3,0><b,3,1>1</b,3,1><b,3,2>0</b,3,2>$
Station 3 bit status
bit element    76543210
data                011
This example XML string encodes the status of 16 bits from station 5.
*<w,5,0>239</w,5,0>$
Station 3 bit status
bit element   15      8     7      0
data           00000000     11101111
This example XML stream encodes the status of 32 bits from station 5.
*<w,5,0>239</w,5,0><w,5,1>32859</w,5,1>$
Station 3 bit status
bit element   32      24   23      16    15      8     7      0
data           10000000     01011011      00000000     11101111
Because word type data contains 16 bits, t word element shifts the bit position by 16

The example XML stream encodes the status of 48 bits and 2 numbers from station 0.
*<w,0,2>552</w,0,2><w,0,1>576</w,0,1><w,0,0>32771</w,0,0>
<n,0,0>3200</n,0,0><n,0,1>502</n,0,1>$
Station 0 bit status
element   47      40   39      32   31      24  23      16   15      8     7      0
data       00000010     00101000     00000010    01000000     10000000     00000011
Station 0 number values
element    0        1
data      32000    502
Different station numbers can be mixed into the stream.

Home- Data Collection- Data Mining- GPL Software- Services- FAQ- Tips

SourceForge.net Logo

http://sourceforge.net/projects/frontiertech/