Code Monkey home page Code Monkey logo

Comments (11)

philippoo66 avatar philippoo66 commented on July 19, 2024

ok, I think I got it...
config['p2_timeout'] = 3
worked.

from python-udsoncan.

philippoo66 avatar philippoo66 commented on July 19, 2024

and now the next question:
config['exception_on_negative_response'] = False
has no effect. I'm still getting "ReadDataByIdentifier service execution returned a negative response ConditionsNotCorrect (0x22)" - what am I doing wrong now?

from python-udsoncan.

pylessard avatar pylessard commented on July 19, 2024

Hi
send_request is an internal method of the client, not meant to be used by the user.
Use read_data_by_identifier instead. Look at this example, much cleaner than what you did.

https://udsoncan.readthedocs.io/en/latest/udsoncan/examples.html#reading-a-did-with-readdatabyidentifier

You can find the reason of your issue here: https://github.com/pylessard/python-udsoncan/blob/master/udsoncan/client.py#L404
Each user exposed methods are decorated with @standard_error_management, applying the configuration rules.

from python-udsoncan.

philippoo66 avatar philippoo66 commented on July 19, 2024

Good morning Pier-Yves,

thank you very much for your fast reponse! In our 'main application' we are using the user-exposed read_data_by_identifier and it is working very well and comfortably. But as far as I understood, this method requires a codec which might be a raw codec but which postulates the awareness of the data length?

In my current case this is a scan application where we do not know if the requested datapoint even exists, and if it does, how many bytes it will return. So I used the mentioned solution found by @surt91 (thank you Hendrik!!)

Is there a better way to do this (find out the data length and the existence)?

from python-udsoncan.

pylessard avatar pylessard commented on July 19, 2024

Hmm, I see
There is no method to request a DID without reading it.
There is a non-standard trick requested by a user a while ago that I implemented. I assume he was trying to do the same as you.
You can raise a special exception in the codec length function. The parser will receive that and consume the whole payload. Obviously, you can't do that when reading many DIDs in random order.

https://udsoncan.readthedocs.io/en/latest/udsoncan/helper_classes.html#didcodec

Maybe I could add a peek method that request a DID without decoding the response. That would be cleaner I think

from python-udsoncan.

pylessard avatar pylessard commented on July 19, 2024

On the other hand, you can send the raw request/response yourself, but you will loose some intelligence implemented by the client, like timeout handling and "busy" response handing

Something like this could do (not tested)

dummy_did_config = {
    0x123:'h'   # Dummy codec.  No decode/encode actually happens while crafting the request.
}

req = services.ReadDataByIdentifier.make_request(0x123, dummy_did_config)
conn.send(req)
data = conn.wait_frame(timeout=5)
response = Response.from_payload(data)
# No call to ReadDataByIdentifier.interpret_response().  No decoding of the did happens, so we're good.
if response.positive:
    print("did exist")

from python-udsoncan.

philippoo66 avatar philippoo66 commented on July 19, 2024

thank you! I will give that a try when I will find some time. Currently I'm trapping the negative response exception and am fine with Hendriks solution so far. thank you again very much for your support!!

from python-udsoncan.

pylessard avatar pylessard commented on July 19, 2024

Want to try this branch?
https://github.com/pylessard/python-udsoncan/tree/allow-peek-did

response =  client.test_data_identifier(0x1234)

response.service_data will be None because the response is not parsed

from python-udsoncan.

philippoo66 avatar philippoo66 commented on July 19, 2024

Hi Pier Yves!

Thank you for the work! As soon as possible I will give it a try (right now I have to do some work 'for money'. far behind with...).

Greetings!
Phil

from python-udsoncan.

pylessard avatar pylessard commented on July 19, 2024

I might merge anyway. The feature seems enough.
Reopen if you think it is necessary

from python-udsoncan.

pylessard avatar pylessard commented on July 19, 2024

Fixed in #204

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.