... | ... | @@ -146,13 +146,63 @@ Observations: |
|
|
## Signed and Unsigned Signals
|
|
|
A signed signal can be sent by simply applying a negative offset to a signal. Let's add a signed signal to the previous message.
|
|
|
|
|
|
**Example**
|
|
|
**Example 1**
|
|
|
```
|
|
|
BO_ 500 IO_DEBUG: 4 IO
|
|
|
SG_ IO_DEBUG_test_unsigned : 0|8@1+ (1,0) [0|0] "" DBG
|
|
|
SG_ IO_DEBUG_test_signed : 8|8@1- (1,-128) [0|0] "" DBG
|
|
|
```
|
|
|
|
|
|
**Signal Layout**
|
|
|
|
|
|
- `x` denotes "start" position
|
|
|
- `<-` indicates most significant bits, and end of the signal
|
|
|
|
|
|
```
|
|
|
Bit
|
|
|
|
|
|
7 6 5 4 3 2 1 0
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
0 |<-----------------------------x|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
+-- IO_DEBUG_test_unsigned
|
|
|
B +---+---+---+---+---+---+---+---+
|
|
|
y 1 |<-----------------------------x|
|
|
|
t +---+---+---+---+---+---+---+---+
|
|
|
e +-- IO_DEBUG_test_signed
|
|
|
|
|
|
```
|
|
|
|
|
|
**Example 2**
|
|
|
```
|
|
|
BO_ 200 SENSOR_SONARS: 4 SENSOR
|
|
|
SG_ SENSOR_SONARS_left : 0|10@1+ (1,0) [0|800] "inch" DRIVER
|
|
|
SG_ SENSOR_SONARS_right : 10|10@1+ (1,0) [0|0] "inch" DRIVER
|
|
|
SG_ SENSOR_SONARS_middle : 20|10@1+ (1,0) [0|0] "inch" DRIVER
|
|
|
```
|
|
|
|
|
|
**Signal Layout**
|
|
|
|
|
|
```
|
|
|
Bit
|
|
|
|
|
|
7 6 5 4 3 2 1 0
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
0 |------------------------------x|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
1 |----------------------x|<------|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
B +-- SENSOR_SONARS_left
|
|
|
y +---+---+---+---+---+---+---+---+
|
|
|
t 2 |--------------x|<--------------|
|
|
|
e +---+---+---+---+---+---+---+---+
|
|
|
+-- SENSOR_SONARS_right
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
3 | | |<----------------------|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
|
+-- SENSOR_SONARS_middle
|
|
|
```
|
|
|
|
|
|
Observations
|
|
|
* ```@1-```: Defines that ```IO_DEBUG_test_signed``` signal is little-endian, and signed.
|
|
|
|
... | ... | @@ -203,7 +253,7 @@ To make sense of this, you have to re-arrange the bytes as Big Endian to form a |
|
|
```
|
|
|
<--------- byte 0 ----------> <--------- byte 1 ----------> <--------- byte 2 ---------->
|
|
|
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
|
|
|
offset = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
|
|
offset = 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
|
|
|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
|
|
| | | | | | | |<-m|---|---|---|---|---|---|---|---|---|---|---|---|---|---|-l*| |
|
|
|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
... | ... | @@ -225,14 +275,14 @@ The formula to find the span of this signal is: |
|
|
|
|
|
```
|
|
|
BO_ 505 BIG_ENDIAN2: 8 IO
|
|
|
SG_ BIG_ENDIAN2_16bit_msb_b4 : 12|16@0+ (1,0) [0|0] "" DBG
|
|
|
SG_ BIG_ENDIAN2_16bit : 12|16@0+ (1,0) [0|0] "" DBG
|
|
|
```
|
|
|
|
|
|
Signal Overlay (byte 0 is omitted):
|
|
|
```
|
|
|
<--------- byte 1 ----------> <--------- byte 2 ----------> <--------- byte 3 ---------->
|
|
|
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
|
|
|
offset = 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
|
u64 offset 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32
|
|
|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
|
|
| | | |<-msb--------------|-------------------------------|------lsb-*| | | | | |
|
|
|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
... | ... | |