Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbcparser parses factor incorrectly #21

Closed
ozzdemir opened this issue Feb 26, 2020 · 11 comments
Closed

dbcparser parses factor incorrectly #21

ozzdemir opened this issue Feb 26, 2020 · 11 comments

Comments

@ozzdemir
Copy link

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

@rkollataj
Copy link
Member

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.

@ozzdemir
Copy link
Author

ozzdemir commented Feb 26, 2020

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.

@rkollataj
Copy link
Member

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

image

@ozzdemir
Copy link
Author

ozzdemir commented Feb 27, 2020

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.

@ozzdemir
Copy link
Author

ozzdemir commented Feb 28, 2020

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.

@ozzdemir
Copy link
Author

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.

@ozzdemir ozzdemir reopened this Feb 28, 2020
@rkollataj
Copy link
Member

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.

rkollataj added a commit that referenced this issue Mar 1, 2020
… functions may produce wrong results

Signed-off-by: Remigiusz Kołłątaj <[email protected]>
@rkollataj rkollataj mentioned this issue Mar 1, 2020
@rkollataj
Copy link
Member

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

@ozzdemir
Copy link
Author

ozzdemir commented Mar 2, 2020

#22 does solve the problem.

btaczala pushed a commit that referenced this issue Mar 11, 2020
… functions may produce wrong results (#22)

Signed-off-by: Remigiusz Kołłątaj <[email protected]>
@btaczala
Copy link
Collaborator

#22 merged. I'm closing this ticket

@mrclgl
Copy link

mrclgl commented Jun 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants