Sample event constructs

Send a "Start-event"

Class = 30 (0x1E) Control
Type = 7 "Start"      http://www.vscp.org/wiki/doku.php?id=vscp_specification_class_30
Data byte 0 is  don't care
Data byte 1 is  zone
Data byte 2 is sub-zone

as a CAN message this looks like

id = 0x1e0701
data byte 0 = 0x00
data byte 1 = 0x01 for zone = 1
data byte 2 = 0x30 for sub-zone = 0x30

How the id is used is described here
http://www.vscp.org/wiki/doku.php?id=vscp_specification_-_vscp_level_i_over_can
Look at the table Format of the 29 bit CAN identifier in VSCP From this you see that the above event comes from node 0x01 (looking at it from the back), the type is 0x07, the class is 0x1e, its not a hardcoded id, and the priority is zero (highest priority).

Send temperature event

Class = 10 (0x0A) Control
Type = 6 "temperature"     http://www.vscp.org/wiki/doku.php?id=vscp_specification_class_10
Data byte 0 is  datacoding
Data byte 1 -7 is the value depending on data coding

The data coding byte tells how the value is presented. It is specified here
http://www.vscp.org/wiki/doku.php?id=vscp_specification_data_coding

As you can see you can specify the temperature in different ways

bit 5,6,7

Bit format Not useful for a temperature

Byte format Use one byte to represent the temperature. No decimals available.

String format Represent the temperature as a string “25” is two byte 0x32, 0x35

Integer format Represent the temperature as an integer. For 25 degrees same as byte format but for 3000 degrees two bytes is used 0x0b, 0xb8

Normalized integer Possible to represent a temperature with decimals. 25.00 degrees becomes 2500 = 0x09c4. The normalizer byte should have bit 7 set for a value less then zero so it should be zero here. The decimal point has been shifted two steps so the normalizer byte becomes 0x02. In total we get 0x02 0x09 0xc4. Note that the bytes after the normalizer byte are in two's complement form to be able to handle negative values.

Floating point The temperature is coded as a floating point value.

Bits 3,4 tells how the data should be interpreted. If you look at temperature
http://www.vscp.org/wiki/doku.php?id=vscp_specification_class_10 you see that the default unit is Kelvin (bit3 = 0, bit4=0) but degrees celsius can be specified (bit3=1, but4=0) or Fahrenheit (bit3=0, bit4=1).

Bits 0,1,2 is the index of the sensor for modules that have more then one sensor.

So if we have 25,37 degrees Celsius we get

id = 0a0601 (from node 1, highest priority (should normally be lower).
data byte 0 = b10001000 = 0x88  data coding)
data byte 1 = 0x02  Value > 0, two decimal points
data byte 2 = 0x09
data byte 3 = 0x35   0x0935 = decimal 2537
 
howto/sample_event_constructs.txt · Last modified: 2014/03/27 06:23 (external edit)
[unknown button type]
 
Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki