pylessard / python-udsoncan

Python implementation of UDS (ISO-14229) standard.
MIT License
586 stars 202 forks source link

filePathAndNameLength shall be encoded on 2 bytes for 0x38 service #50

Closed wanam closed 4 years ago

wanam commented 4 years ago

Hello @pylessard ,

According to the ISO, in service 0x38, the parameter “filePathAndNameLength” should be encoded on 2 bytes in the Request Message Definition.

image

This is not the case in your implementation, on RequestFileTransfer.py file, here.

        path_ascii = path.encode('ascii')
        if len(path_ascii) > 0xFF:
            raise ValueError('Path length must be smaller or equal than 255 bytes when encoded in ASCII')

Max path length parameter should be 0xFFFF (65535 bytes).

As a consequence here, since our path is encoded in less than 0xFF, we continue to build a corrupted request:

        data += len(path_ascii).to_bytes(1, 'big')
        data += path_ascii](url)

So the first byte of the path will be stripped on the ECU side as the second byte of path length.

I hope the issue is clear, let me know if you need any further information.

pylessard commented 4 years ago

Will verify and fix today

pylessard commented 4 years ago

All done, Release is published : v1.12.1

Thank you for your feedback