-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with bus.send_periodic #2
Comments
This repository is about datasheets of CAN IP cores, not about general support. I'm not sure if the |
Hi thank you for the prompt reply, as for kernel log: dmesg | grep - i can
|
It doesn't show I'm sure, you'll find a low of documentation, if you search for "how to compile kernel for raspberry pi". |
Hi, i managed to recompile my kernel with CAN_BCM enabled. via resources this link i check the kernel log:
However the same error persist when i try to use the function |
If the BCM is a module it's only loaded if needed, so after you run your test program the first time. Try running as root, if this doesn't work, maybe @hartkopp can help you. |
I see. this is helpful.
|
I tried the original code from #2 (comment) and only changed But
This would be definitely too fast for a real CAN bus. Additionally this looks wrong:
You are creating a busy loop which continuously overwrites the current CAN_BCM setting to establish a periodic send job! You likely wanted to have
which leads to this output of
|
Hello Hartkopp, thank you for the reply! |
Can you please check is it works with a virtual CAN interface in your setup (as I showed above) and check if the CAN traffic is analogue to my candump example? |
Sure, i just tried with your changes, and it's have the same error message. |
Can you please post the output of |
But there are no RX/TX packets on the vcan0 interface. When I run your program on
|
I'm unable to run the code, because when i try to run it, the err code 22 came up. |
Please show the code you're trying to run. This work-for-me: import can
import time
try:
bus = can.interface.Bus(channel = 'vcan0',
bustype = 'socketcan',
bitrate = 500000)
except OSError as e:
print(e)
message = can.Message(arbitration_id=0x37A, data=[0x0A, 0x00, 0x3B, 0x00, 0xFF, 0x0B, 0x00, 0x00], is_extended_id= False)
message1 = can.Message(arbitration_id=0x379, data=[0x0C, 0x00, 0x0A, 0x00, 0xFF, 0x00, 0x0A, 0x00], is_extended_id= False)
message2 = can.Message(arbitration_id=0x372, data=[0x00, 0xD0, 0x50, 0x80, 0xCC, 0x00, 0xAA, 0xB0], is_extended_id= False)
period = 0.1
bus.send_periodic(msgs = message, period = 0.1)
bus.send_periodic(msgs = message1, period = 0.1)
bus.send_periodic(msgs = message2, period = 0.1)
while True:
time.sleep(1) |
But if this would have been started, why are there no RX/TX packets for vcan0 visible? |
I dont think the code manage to get started due to the error. thus no RX/TX packets are out for vcan0 |
Can you create a log with
Mine looks like this:
Interestingly there are Which BTW: please copy/paste from your terminal, no need for screen shots. |
Sure,
as for python-can when i use : apt-cache policy python3-can
but when i use pip show python-can
|
python-can obviously does a TX_READ (0x03) first and then does a TX_SETUP (0x01). |
The strace log has to look like the example from @marckleinebudde |
How can i go about it? Since we both use the same code, could the difference in python library versions or OS that we use affect it? |
Please send a strace output as posted by @marckleinebudde here #2 (comment) |
I'm not too sure if this is the output that you are looking for, as the strace output log is quite long.
|
The interesting part is here:
|
This is the relevant part of the strace log:
As struct bcm_msg_head is 56 bytes (as you can see in Marc's log), I wonder why your setup sends 40/56 bytes instead of 56/72 ... |
It's a 32 bit user space.... |
@YuBer0 What's the output of |
Linux pi 6.1.19-v8+ #1637 SMP PREEMPT Tue Mar 14 11:11:47 GMT 2023 aarch64 GNU/Linux |
my pahole says:
uname -a |
@hartkopp 64 bit kernel with a 32 bit user space. Another issue due to |
Hm, might be. |
A 32 bit ARM kernel has the following layout:
|
and |
Seems it's time to pick up that old thread. |
It seems we have to evaluate if |
@YuBer0 the instant fix for you would be to compile your Kernel as 32 bit Kernel as you have a 32 bit user space on your system. |
@marckleinebudde I'm not sure if this helps as the COMPAT stuff is intended for CMSG handling. But I would be fine to add some analogue code if it doesn't make the situation worse ;-D |
awesome! @hartkopp @marckleinebudde |
I have some prototype code, will test tomorrow. gn8 |
Hey! just tested it out, it's working out perfectly. just wondering do i have to mark this as closed? |
Please leave this open, I want to try to fix 32 bit userspace on 64 bit kernels. |
It doesn't work, as For the |
Thanks for the investigation! The question is if it helps to introduce a The good thing about your investigation: ps. I still wonder if it would be worth the effort or if we better add some documentation to describe this potential problem ... |
Filedescriptors can be passed from one process to another :) So it's not a 100% solution.
Adding documentation is always good, but this is not a potential problem, this is a very real problem on 32 bit userspace on 64 bit kernels. |
But then you would need to pass it to another process that has a different 32/64 architecture - is this a valid problem?
Is it? When I get a RasPi or Debian OS image, then I get a consistent kernel with a consistent user land. And when I install additional packages or compile new stuff they share the identical word size. So it would just lead to problems, if someone copies binaries from a different user land installation, right? |
I assume that you built a 64 bit Kernel when following your referenced process here: #2 (comment) |
We have a $CUSTOMER using a 32 bit user land on a 64 bit kernel (Though they are not using CAN, bus 100G Ethernet). It's a read world use case! |
Hm, wasn't aware of such use-case. |
Feel free to use my WIP code: https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=bcm |
The |
Hi, I'm trying to send CAN messages with the function send_periodic. however i got the error
The code i used is :
When i tried to send it via bus.send it seems to be able to work
Here are some of the configurations that my CAN device is working on
RPI-4B 8GB Ram,
kernel version : 6.1.19-v8+
CAN transceiver device, MCP2515 (modified, changed VP230 for TJA1050)
Upon boot up, RPI did say that it is unable to load spi-dma & bcm2835
I'm pretty new to RPI and CAN devices as well as posting issues on github, so any advice would definitely help! Thanks
The text was updated successfully, but these errors were encountered: