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

Act as server and parse python-can messages #211

Closed
Upgreydd opened this issue Feb 14, 2024 · 6 comments
Closed

Act as server and parse python-can messages #211

Upgreydd opened this issue Feb 14, 2024 · 6 comments

Comments

@Upgreydd
Copy link

Hey,
I'm trying to act as a server-side with udsoncan but I'm facing some issues related to parsing.
I'm receiving can message with data:

0x716 [8] 03 22 d1 00 00 00 00 00

arbitration_id [DLC] DATA, where 03 - is msg length, 22 - service, d1 00 is content and 00 00 00 00 is padding.
When I try to use: Request.from_payload() it cannot parse because the service is on the second position, not the first. I can of course use data[1:] to pass this failure, but then I'm trying to do a response like:

resp = Response(req.service, code=Response.Code.PositiveResponse, data=bytes.fromhex("01")
can_msg = can.Message(arbitration_id=0x71E, dlc=8, data=resp.get_payload())
bus.send(can_msg)

What I'm sending is:

0x71E [8] 62 01

What I'm expecting to send is:

0x71E [8] 03 62 d1 00 01

I'm not very familiar with can, but the lacking parts in the payload are length (03) and service (d1 00)
What I did do wrong?

@pylessard
Copy link
Owner

Hi
You are passing an isotp payload directly to the UDS layer. You are lacking a layer of interpretation. The first byte is meant to be consumed by that isotp (transport layer). You can look at my other project for an implementation of that layer. If you input the whole Can message on one side, you will received the UDS payload on the other

Let me know if I can help, you have some doc reading to do first I believe :)

@Upgreydd
Copy link
Author

Upgreydd commented Feb 14, 2024

@pylessard thank you - but which one project you're talking about? :D Can you please point me some example or code line to get familiar with? I think you're talking about python-isotp.

@pylessard
Copy link
Owner

I have 2 projects, the other one is called python-can-isotp. Which implements the isotp protocol as per above comment.
There are plenty of examples in the documentation, start there

@Upgreydd
Copy link
Author

Upgreydd commented Feb 14, 2024

@pylessard sorry for asking stupid questions, but as I understand I need to implement custom rxfn and txfn functions in isotp transport layer? Or totally avoid using isotp and implement own wrapper to handle this translation between isotp and uds?

@pylessard
Copy link
Owner

Don't hack it. Isotp headers are not always 1 byte.

You need a custom rxfn/txfn if you have specialized hardware. If you use python-can, the work is already done. See this example : https://udsoncan.readthedocs.io/en/latest/udsoncan/examples.html#using-uds-over-python-can

@Upgreydd
Copy link
Author

@pylessard Thank you mate :* Probably have all what I need. Have a nice evening.

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

2 participants