-
Notifications
You must be signed in to change notification settings - Fork 9
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
Loading / Decoding does not respect / account for signal multiplexing. #44
Comments
@bit-dream I do not mind making a pr to fix this issue, however would love to hear your thoughts / feedback first. |
@agent6262 Great writeup on the current multiplexing issue. It was always my intent to support both simple and extended multiplexing, I just have not gotten around to actually implementing it yet. Here's another reference to multiplexing written up by Vector themselves as an addition to the already good sources you posted: In terms of making a PR to actually fix the issue, I'm more than happy to let you take on the challenge. Some of my initial thoughts:
I'm not sure how much of this you want to tackle. You are more than welcome to take on the entire thing. If you are wanting some support, I can help out where needed (for instance if you are not comfortable with TSPeg and want me to handle that aspect of it I can). In general, I'm pretty flexible when it comes to this project. Modify what you need to modify, change/rearrange what you need to, to get the feature working. |
I went ahead and assigned you to this issue. Additionally, I made a really quick and dirty .dbc file that does extended multiplexing that uses the simple example in that Vector link I posted above. Feel free to use your own files for testing if you have better ones, but did want to just throw one out there in case you needed something to test against. (GitHub apparently doesn't allow .dbc extensions, so just posting the code below)
|
Providing some further context on SG_MUL_VAL_ from the Vector documentation: Extended multiplexing allows defining more than one multiplexer switch within one message. Further it allows the usage of more than one multiplexer switch value for each multiplexed signal. extended multiplexing = {multiplexed signal} ; Sample:
Note the line |
Going to keep this open and submit one more pr fixing SG_MUL_VAL_ parsing. There needs to be more tests and I do believe there are edge cases not accounted for. |
Is your feature request related to a problem? Please describe.
When attempting to decode a multiplexed signal (like OBDII) all signals are attempted to be decoded and returned.
Describe the solution you'd like
when decoding a multiplexed can frame the only signal(s) returned should be the multiplexed ones.
Example:
Describe alternatives you've considered
I was on the fence of not even using dbc decoding. however since i would also have to decode dbc files it makes sense to just contribute here and not re invent the wheel.
Additional context
Here is a very good explanation form csselectronics.com
Multiplexing is sometimes used in CAN bus communication, with perhaps the most known example being within OBD2 communication. Consider for example the below OBD2 response frames:
Here, both response frames carry 1 byte of data in byte 3, yet despite the CAN ID being identical, the interpretation of the data differs between the two frames. This is because byte 2 serves as a multiplexer, specifying which OBD2 PID the data is coming from.
To handle this in a DBC file context, the below syntax can be applied:
Here, the M in the Service signal serves as the 'multiplexor signal'. In this case, it toggles which OBD2 service mode is used (mode 01, 02, ...). The signal S1 is multiplexed by Service, which is evident from the SG_MUL_VAL_ field where the two are grouped.
As evident, the signal S1 has the value m1 after the signal name, which means that if the Service signal takes the value 1, the data reflects the OBD2 service mode 01.
The above is referred to as simple multiplexing. But CAN DBC files also support extended multiplexing, where a multiplexed signal (in this case S1) can also be a multiplexor and thus control the interpretation of other parts of the data payload. To see this, note that S1 takes the same role as Service in the syntax, adding an M after m1 and being grouped with the two OBD2 PIDs, speed and throttle position.
Extended multiplexing works as before: If S1 takes the value 13 (HEX 0D), it means that only signals that are A) part of the S1 group and B) have a multiplexer switch value of 13 should be taken into account. In this example, it means that byte 4 reflects data for vehicle speed. If byte 3 equals 17 (HEX 11), byte 4 reflects data for the throttle position instead.
The text was updated successfully, but these errors were encountered: