GENIVI/CANdb

dbcparser parses factor incorrectly

ozzdemir opened this issue · 11 comments

I use "ford_cgea1_2_bodycan_2011.dbc" for testing CDS, it succesfuly parses (actually it is the reason I am using it, from this issue). I was trying to send signal using CanSignalSender, but cansignalencoder gave the following error.

[cds] [error] [signalToRaw():cansignalencoder_p.cpp@104] Factor for HvacEvap_Te_Offst signal is 0! Singal encoding failed.

I tracked error a little bit and found out that factor of can message is parsed incorrectly as 0. Then checked other messages and found that all factors are parsed as integers (by observing CanSignalData block) and they are floor'ed. Table can be seen in the figure below.

image
The message I am playing is the one with id 0x326 and it is given below.

BO_ 806 Compressor_Req: 8 XXX
SG_ HvacEvap_Te_Rq : 33|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX
SG_ HvacEvap_Te_Actl : 17|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX
SG_ HvacAirCond_B_Rq : 7|1@0+ (1,0) [0|0] "" XXX
SG_ HvacEvap_Te_Offst : 1|10@0+ (0.125,-50.0) [0|0] "Degrees C" XXX

Which version of CANdevStudio are you using? There was a fix for floating point factors here: 8dfed1a

This fix should be a part of version 1.0 already.

I use version 1.0 release. I built from source with a more recent version, but only peakcan and tinycan were existed as CanDevice backend. That's why I still use standalone version of the v1.0.0.

It works for me with CANdb 8dfed1a that is set by default.

image

After your response, I've been trying to build from source and I succeeded eventually. I tested with 8dfed1a but no change. I also used the revisions that can be seen below which are latest ones, still no change. Factors are still incorrect. I can't find any valid reason.
image
image

Sorry, my response took some time since I had problems with Qt installations.

I have found the culprit which was the std::stof (used in dbcparser) as mentioned here. std::stof was using "," decimal point separator due to my locale settings.

Using std::setlocale(LC_ALL, "C"); inside DBCParser::parse() before everything else solved problem, but it should be used in initialization I guess. Since I'm not that familiar with the project and its initialization procedure, I did not create a pull request.

I would never expect that locale settings can have impact on CANdb functionality... good work in figuring this out!

I will create fix for this. Thanks.

@ozzdemir Let me know if #22 fixes your problem.

#22 does solve the problem.

#22 merged. I'm closing this ticket

For me this issue still occurs. I'm using Ubuntu 18.04. and compiled CANdevStudio from source (GENIVI/CANdevStudio@f580097) which should already have the fix (CANdb commit 054c7ff)

Switching my system locale from "German" to "United States" fixes the issue and the factors are parsed correctly.