hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.29k stars 602 forks source link

[USB 2 CAN] - issue with data being zeros or anything other than 8 #36

Closed hardbyte closed 8 years ago

hardbyte commented 9 years ago

Originally reported by: Brian Thorne (Bitbucket: hardbyte, GitHub: hardbyte)



hardbyte commented 9 years ago

Original comment by Brian Thorne (Bitbucket: hardbyte, GitHub: hardbyte):


Great, thanks.

hardbyte commented 9 years ago

Original comment by Joshua Villyard (Bitbucket: jvmotivps, GitHub: Unknown):


The issue should be fixed in pull request 15 on the Recv. There was no bug on the transmit. It just was not very clear how it functioned. Added documentation to explain why the code pads the data with additional zeros.

hardbyte commented 9 years ago

Original comment by Joshua Villyard (Bitbucket: jvmotivps, GitHub: Unknown):


The Recv function is where the issue is at. It adds extra zeros at the end when it is not supposed to be there. So when I sent from the PCAN the data 01020304 it gave 0102030400000000 on the USB2CAN. The transmit although sends 8 length with extra zeros to the interface, however when the length is different, say 4, only the first 4 data is sent on the network.

Here is a wireshark file of sending data of different lengths.

It is not overly obvious on the Transmit. The wireshark file when you look at the raw data only shows that the USB2CAB device sent the amount of data that was requested to send and no extra data.

hardbyte commented 9 years ago

Original comment by Tynan McAuley (Bitbucket: tymcauley, GitHub: tymcauley):


Hey @jvmotivps, correct me if I'm wrong, but this issue has been resolved, right? There was a comment here about this being a problem, but I'm pretty sure that's outdated. The code should be able to deal with any length messages.