You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I wanted to parse dbc messages from a .dbc file using DbcParser.
In my file CycleTime is defined as:
BA_DEF_ BO_ "GenMsgCycleTime" FLOAT 0 300000; // [ms]
public static bool CycleTime(this Message message, out int cycleTime)
{
cycleTime = 0;
if (message.CustomProperties.TryGetValue("GenMsgCycleTime", out var property))
{
cycleTime = property.IntegerCustomProperty.Value;
return true;
}
else
return false;
}
It doesn't take into account that it could be defined as a FLOAT, so in parsing as:
BA_ "GenMsgCycleTime" BO_ 298 20.000.
It will report an error and will not run.
I modified the code a bit to make it able to read FLOAT type cycletime:
public static bool CycleTime(this Message message, out int cycleTime)
{
cycleTime = 0;
if (message.CustomProperties.TryGetValue("GenMsgCycleTime", out var property))
{
if (property.IntegerCustomProperty != null)
{
cycleTime = property.IntegerCustomProperty.Value;
return true;
}
else if (property.FloatCustomProperty != null)
{
cycleTime = (int)property.FloatCustomProperty.Value;
return true;
}
}
return false;
}
Finally, good luck with your work, and thank you.
The text was updated successfully, but these errors were encountered:
Hello,
I wanted to parse dbc messages from a .dbc file using DbcParser.
In my file CycleTime is defined as:
BA_DEF_ BO_ "GenMsgCycleTime" FLOAT 0 300000; // [ms]
But the function in
It doesn't take into account that it could be defined as a FLOAT, so in parsing as:
BA_ "GenMsgCycleTime" BO_ 298 20.000.
It will report an error and will not run.
I modified the code a bit to make it able to read FLOAT type cycletime:
Finally, good luck with your work, and thank you.
The text was updated successfully, but these errors were encountered: