I want to send a message periodically using socketCAN with this device
I created a small script to achieve this which looks like this:
import os
import time
msg = "1FF#FFFFF00000000000"
os.system("sudo slcand -o -c -f -s6 /dev/serial/by-id/*CANtact* can0")
os.system("sudo ifconfig can0 up")
os.system("sudo ifconfig can0 txqueuelen 1000") # this does not help
start = time.time()
while True:
if round(time.time() - start, 1) % 60 == 0.:
print(str(int((time.time() - start) / 60)) + " minutes")
os.system("cansend can0 " + msg)
time.sleep(0.1)
I was already doing some research and found that for some people it worked to set the txqueuelen. However, that did not help me. The output of this script looks like this:
0 minutes
1 minutes
[...]
15 minutes
16 minutes
18 minutes
write: No buffer space available
write: No buffer space available
write: No buffer space available
write: No buffer space available
write: No buffer space available
write: No buffer space available
[and so on]
The device stops sending those messages before that error occurs. The indicator LED for in- and outgoing traffic stops blinking around 10 seconds to a few minutes before error message appears. Also, I cannot read anything on the receiving side. The time it takes until the buffer is full varies gravely, between a few minutes and a few hours. Usually within 10-20 min though.
I had the thought that there might be something like a receiving buffer and because I never read from that that it just fills up. But I do not know whether this is actually the case and also not how to test it or how to flush the buffer or reset it or whatever. I only need to send my messages. I do not care about anything else.
The only solution afterwards is to restart my Raspberry Pi which powers the device.