GithubHelp home page GithubHelp logo

Comments (7)

pylessard avatar pylessard commented on August 21, 2024

Interesting.
Can you share some code? Or at least your configuration

from python-udsoncan.

IDC-Dragon avatar IDC-Dragon commented on August 21, 2024

I was digging a bit deeper meanwhile.

Having multiple PythonIsoTpConnection open means each has a running rxthread_task(). They seem to compete for the received CAN payload. What I see is that a call to self.isotp_layer.process() discards the packet because of address mismatch. So, a thread for another ECU has fetched the FirstFrame.

Am I using this conceptually wrong? Is it meant to allow multiple active connections? In that case, the receiver socket should have a filter, or one central receiver thread has to dispatch the packets to the instances.

from python-udsoncan.

pylessard avatar pylessard commented on August 21, 2024

That's a very good question. I think each of your bus object should filter for the correct ID so that they do not consume the CAN message for other connections (I am assuming that this is the behaviour python-can when setting a filter).

Having a central dispatcher might be the most straight-forward option. You can use the QueueConnection for that, but I think correctly filtering is cleaner.

Maybe it would be relevant that a filter is automatically set based on the IsoTP stack parameters.
I will investigate later.

I'd be curious to hear what @christiansandberg think of this.

In any case, sharing your configuration may help.

from python-udsoncan.

IDC-Dragon avatar IDC-Dragon commented on August 21, 2024

I have now changed my code to create an individual bus object per ECU, with a filter set to the Rx address. This works for me.
A central dispatcher might be lighter to the CPU, but is more difficult to code. IIRC the tread has short timeouts, wakes up often. With many of those, it's a lot of polling.

from python-udsoncan.

pylessard avatar pylessard commented on August 21, 2024

Thanks for the feedback.
Do you think udsoncan or can-isotp should be altered in any way to better handle that use case?

from python-udsoncan.

IDC-Dragon avatar IDC-Dragon commented on August 21, 2024

Dunno, my case might be exotic. Maybe the documentation could tell the caveat. I was especially puzzled because IsoTPSocketConnection worked, PythonIsoTpConnection didn't.
Their setup syntax is different, however. IsoTPSocketConnection gets a bus name and can do all the socket setup by itself, vs. PythonIsoTpConnection operates somewhat lower. You can't set filters or other sockopts when the socket is already bound.
Nevermind, IMHO you may close this. Thanks a lot for the fine piece of Python!

from python-udsoncan.

pylessard avatar pylessard commented on August 21, 2024

PythonIsoTpConnection is pretty much a shortcut for not having to setup the socket. You can always use the SocketConnection if you want to do some fancy sockopt setting. I don't think your setup is exotic, I think it would be common to have many UDS channel on the same CAN bus.

And you are correct, the handling of message is different in the kernel module v.s. what python-can does. When using the PythonIsoTpConnection, there an instance of socket per connections and the kernel-module does the dispatching to give a copy of the CAN messagse to each socket unless there's a filter. You'd have to code a dispatching mechanism yourself to get something similar with python-can.

I'll add a warning in the documentation regarding this potential issue. I might also add an function call to get the correct mask from the address object. something like my_address.get_can_filter_mask()

Will close this issue
Thanks for the input.

from python-udsoncan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.