Open apolak opened 4 months ago
Hi Aleksander, thanks for reporting this and providing all the details. We will go over this in more details and get back to you.
If you happen to have the fix at hand, feel free to open a PR.
Thanks once again!
If you happen to have the fix at hand, feel free to open a PR.
@nenadilic84 Thanks for the quick response. I don't have a fix at hand, unfortunately. I think that a general solution would require changes to IoT FleetWise data model - namely, the CanSignal data type - to be able to convey that the signal value is something else than a signed or unsigned integer that you scale and translate, like SIG_VALTYPE_
does. Data type information from the signal catalog is not rich enough as we have three different binary representations of double values and we need to be able to distinguish between them.
@apolak Thanks for the additional context. It's not clear from the DBC spec what value '3'
for SIG_VALTYPE_
means. Perhaps they added a reserved value for future expansion but didn't document it. Do you have any usecase that you need to use that value for? - I note you said "three different binary representations of double values".
@hefroy I think the value 3 is either a reserved value or an error in the specification. The three representations that I had in mind are:
signed or unsigned integer with scale factor (SIG_VALTYPE_
optional) - this is the only representation that works today:
BO_ 1 Latitude: 4 Vector__XXX
SG_ Latitude : 0|32@1- (1e-6,0) [-90|90] "degrees" Vector__XXX
SIG_VALTYPE_ 1 Latitude : 0;
32-bit IEEE 754 number:
BO_ 1 Latitude: 4 Vector__XXX
SG_ Latitude : 0|32@1+ (1,0) [-90|90] "degrees" Vector__XXX
SIG_VALTYPE_ 1 Latitude : 1;
64-bit IEEE 754 number:
BO_ 1 Latitude: 8 Vector__XXX
SG_ Latitude : 0|64@1+ (1,0) [-90|90] "degrees" Vector__XXX
SIG_VALTYPE_ 1 Latitude : 2;
Is your feature request related to a problem? Please describe.
CAN databases support IEEE 754 signal values. However, Edge Agent doesn't seem to support this type of signals. In turn, collecting them is not possible. Please see the code below: https://github.com/aws/aws-iot-fleetwise-edge/blob/28f44607f8c0333f408e3a0e7b5628b5846491b9/src/CANDecoder.cpp#L111-L146
In this code, all signals of type float or double are considered to be scaled integers. IEEE 754 numbers are treated as signed 64-bit integers, then converted to double using simple casting.
For example, double value 2.3 is encoded as 0x4002666666666666. The signal is of type double in the signal catalog. However, Edge Agent decodes it as 4612361558371493478 and then casts it to double. As a result, the value stored by AWS IoT FleetWise is 4612361558371493478.0 instead of 2.3.
Describe the solution you'd like
Edge Agent should be able to correctly decode signal values that are 32-bit or 64-bit IEEE 754 numbers. This may require changes to the DecoderManifest in order to be able to identify these types of signals.
Describe alternatives you've considered
Additional context
In DBC files, you can use
SIG_VALTYPE_
keyword to specify that the signal value is a 32-bit or 64-bit IEEE 754 number:Please see the example below: