python-udsoncan icon indicating copy to clipboard operation
python-udsoncan copied to clipboard

WIP: Allow to receive multiple responses to one request

Open kayoub5 opened this issue 3 years ago • 3 comments

Helps with https://github.com/pylessard/python-udsoncan/issues/88#issuecomment-1008140928

What's done

  • Allow converting one response to a response list.
  • Populate each response service_data.
  • Handling of NRC Pending Response
  • Allow user to receive all responses even if some of them are erroneous (requires changing the configuration accordingly)

What's not done? (Outside the scope of this PR)

  • Currently the client does not validate the consecutive responses, since the logic exists only in the client method. That logic most likely needs be moved from the client to a Service.validate_response(request, response) method.
  • Timeout handling treats each response independently of the others.
  • Who sent the individual response (in case of functional addressing) is not available due to Connection API limitation.

kayoub5 avatar Feb 26 '22 14:02 kayoub5

Hi, the validation logic is in the client for architecture purpose. The service layer is stateless, so it validate the validity of the payload. The client is aware of what was send previously, so only it can tell if the response is meaningful.

If you need to reuse the validation work, I suggest you move this code into separate functions into the client, maybe by making a GenericClient object. Then you can make 2 inplementation of the client : the one we have and yours that support multiple response. Both would call these validation methods.

Thank you for your work.

pylessard avatar Feb 26 '22 15:02 pylessard

@pylessard The alternative I can think of is to change the standard_error_management method (or add another decorator), that:

  • calls the decorated method (tester_present for example) repeatably
  • suppress request sending during send_request except for the first iteration.
  • The decorated method will then simply receive the next response each time.

This logic requires that the decorated method generates the same request for each call.

As far as I can see, this will work for all currently implemented function with no change to their code, except for unlock_security_access since it calls other methods thus calling send_request more than once, unlock_security_access could simply throw if the client is in functional mode.

kayoub5 avatar Feb 26 '22 16:02 kayoub5

I think that could work!

pylessard avatar Feb 26 '22 17:02 pylessard

This PR has been open for over a year. I guess we should close it?

pylessard avatar Jun 24 '23 15:06 pylessard