Hi,
I am using a dual peak PC-104 board on my embedded Linux system. I have installed the peak drivers on my target device and have my two can ports working in chardev mode, installed as /dev/pcan8 and /dev/pcan9.
Today I got my own code running using the supplied driver, so far so good, I have implemented a basic control and test application for my target which is talking to 6 CANBus four channel hydraulic valve controllers. However, I am wondering if there is a way to install a "message received" callback procedure, instead of having to poll for received messages?
CAN Message callback procedure?
CAN Message callback procedure?
Matt Denton
Micromagic Systems - www.micromagicsystems.com
Hexapod Robot - www.hexapodrobot.com
Micromagic Systems - www.micromagicsystems.com
Hexapod Robot - www.hexapodrobot.com
Re: CAN Message callback procedure?
Hi,
thanks for the info. With our chardev Linux driver its possible to open the device in blocking or non blocking mode. So when you use blocking mode the CAN_Read function will only return when there are new messages in the buffer. So this will be similar to a receive event under Windows.
h = LINUX_CAN_Open("/dev/pcan32", O_RDWR); // blocking
h = LINUX_CAN_Open('/dev/pcan0', O_NONBLOCK); //O_NONBLOCK
best solution will be to create a separate thread for the CAN_Read than.
regards
Michael
thanks for the info. With our chardev Linux driver its possible to open the device in blocking or non blocking mode. So when you use blocking mode the CAN_Read function will only return when there are new messages in the buffer. So this will be similar to a receive event under Windows.
h = LINUX_CAN_Open("/dev/pcan32", O_RDWR); // blocking
h = LINUX_CAN_Open('/dev/pcan0', O_NONBLOCK); //O_NONBLOCK
best solution will be to create a separate thread for the CAN_Read than.
regards
Michael
Last edited by M.Maidhof on Thu 4. Nov 2010, 15:24, edited 1 time in total.
Re: CAN Message callback procedure?
Hi Michael,
That is exactly what I have at the moment, I opened the port in on blocking pode, and poll it within a separate thread. Just wanted a slightly more elegant solution.
That is exactly what I have at the moment, I opened the port in on blocking pode, and poll it within a separate thread. Just wanted a slightly more elegant solution.
Matt Denton
Micromagic Systems - www.micromagicsystems.com
Hexapod Robot - www.hexapodrobot.com
Micromagic Systems - www.micromagicsystems.com
Hexapod Robot - www.hexapodrobot.com
Re: CAN Message callback procedure?
Hi,
but when using the blocking mode its not polling, polling is only possible in non blocking mode!
regards
Michael
but when using the blocking mode its not polling, polling is only possible in non blocking mode!
regards
Michael
Re: CAN Message callback procedure?
Ok,
I guess that depends how you describe "polling" My definition of polling is having to call a function such as LINUX_CAN_Read... to find out if it has a CAN message for you. As opposed to having a callback / signal handler tell you that a message is ready.
I guess that depends how you describe "polling" My definition of polling is having to call a function such as LINUX_CAN_Read... to find out if it has a CAN message for you. As opposed to having a callback / signal handler tell you that a message is ready.
Matt Denton
Micromagic Systems - www.micromagicsystems.com
Hexapod Robot - www.hexapodrobot.com
Micromagic Systems - www.micromagicsystems.com
Hexapod Robot - www.hexapodrobot.com