Re: CAN ISO-TP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 06.05.21 um 20:01 schrieb Oliver Hartkopp:
>> I tried to simplify example where I use python wrappers and other
>> things and manage to get minimal example:
>>
>> /import socket as s
>> socket = s.socket(s.AF_CAN, s.SOCK_DGRAM, s.CAN_ISOTP)
>> socket.bind(("vcan0", 1, 2))
>> socket.send(b"AAAAAAAAA")
>> socket.send(b"AAAAAAAAA")/
>> /
>> /
>> It's working perfectly, even if I don't open receiver socket. It just
>> timeout and there is no issue.
> 
> But this should raise an issue as you send 9 bytes which would need
> segmentation.
> 
> This should only work with CAN FD frames with a single frame.
> 
> Can you create a candump log from vcan0 to see, what's going on the bus?
> 
>> I tried to run my application on RPI, when module is already included
>> with kernel version Linux raspberrypi 5.10.17-v7+ #1403 SMP Mon Feb 22
>> 11:29:51 GMT 2021 armv7l GNU/Linux.
>>
>> I run above code and first send is working (no receiver as well),
>> timeout, but second one is printing
>>
>> OSError: [Errno 70] Communication error on send
> 
> That's interesting! We are currently working on creating that kind of
> feedback.
> 
> https://lore.kernel.org/linux-can/97e2ddd5-cc8b-9c7b-6198-2eceee39dfd4@xxxxxxxxxxxx/
> 
> 
> So how is Python getting this information?
> 
> Regards,
> Oliver

Hi,

that seems to be my topic.

1. Feel free to use my python module.

https://gitlab.com/Menschel/socketcan#using-a-canisotpsocket

It is in regular pypi and I push new releases from time to time.

pip install socketcan

Don't forget to increase txqueuelen.
https://gitlab.com/Menschel/socketcan#can-isotp-overflows-when-the-tx-queue-is-too-small

2. Concerning errors, they are returned through the socket to user space
and raise OSError by Errno in socket.Socket() class.
If a subclass is implemented for that Errno, that subclass is raised
instead, for example TimeoutError.

The reported scenario may be a delayed stderr message, means it happens
on first attempt and is printed on second attempt.
There are such things when using "python -i".

There is an easy way to verify such a thing. Wrap your socket.send()
statements into a print() statement this will print the number of bytes
sent and these numbers will be printed after the error message.

Regards,
Patrick



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux