I am looking to integrate CANopenNode with my application on Linux and somehow it is not quite clear to me what the best way would be.
I tried out the command line examples in the getting started guide - everything worked really well and was clearly explained. However, I got somewhat stuck when looking at how to integrate the stack with my code.
I was originally expecting a library with some API, but I understand that CANopenNode came to Linux from MCUs, so the setup appears to be different. What is the suggested approach? Should I modify the sources in CANopenNode/socketCAN and integrate my application into them?
Basically I am processing data from other sources (i.e. online) and interacting with the CAN bus (reading/writing messages), SDO is also being used.
I would appreciate an advice on how to go about it. Thank you!
Kind regards,
Jin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I saw these ifdefs and was thinking that it must be for "hooking in", but the hooks seem too basic, and I think just replacing the main.c would not yet help, unless something obvious is evading me :)
For instance - how can I get triggered on incoming CAN data? Or what is the proper way to tell CANopenNode to send a CAN message from the application, i.e. tell from another thread? Should I be calling CO_CANCheckSend() from my code? I also see CO_GTWA_write() which implies the ASCII notation, or is the ASCII notation actually the API/interface that I am asking about?
I am struggling to understand the API of CANopenNode so any help what sources to look at or some examples would be greatly appreciated.
Say, I have a thread that gets data from the outside, what's the proper way to propagate this data to the CAN bus? And also what is the proper way to get notified when I receive something from the CAN bus? Is there an "API" in the common sense where I could subscribe to events on the CAN bus or events on the object dictionary or do I "just" hook directly into the code at strategic places?
Or is the idea to use the local socket mode and have an external application communicate and exchange data and events over this socket? I assume that would be in ASCII notation as well?
I am really not sure which way to go, so please suggest an approach which you had in mind when designing the stack, what's the correct way to use it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are talking about CAN. But CANopen is something else, it is higher level protocol build on top of CAN. CANopen is widely used in industrial automation and similar. There are books, which explain CANopen. For basic explanation see README.md file.
OK sorry, I indeed mixed two things together. So raw CAN is outside of CANopenNode, that's clear now. Still, my integration question remains open, for instance if my application needed to support SDO which is implemented in CANopenNode, how did you mean for the integration to happen?
Should applications be using the socket connection and the 309.3 ASCII gateway protocol? Or should they embed CANopenNode code directly?
I did have a look at the docs prior to posting and I saw some examples of new devices targeted for MCU, but with the socketCAN client I'm still missing the understanding if I am supposed just to use the CANopenNode code/linux client as a basis for an application and embed the code, or if there is some API to have a clean cut, be it via some library header and linking of the sources or a socket API?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CANopenNode can also run on simple microcontroller. For example simple CANopen capable sensor, which has multiple parameters configurable. Parameters are ordered in Object Dictionary. SDO server enables access of any own parameter to external CANopen configuration device. Some parameters can be configured for transfer with no protocol overhead (see PDO). There are usually multiple "simple" CANopen devices communicating over CANopen network. They usually exchange PDO-s between themselves.
Linux example of CANopenNode has quite reach configuration. It includes additional SDO client, gateway, etc. It can be used to configure other CANopen devices.
Hi,
I am looking to integrate CANopenNode with my application on Linux and somehow it is not quite clear to me what the best way would be.
I tried out the command line examples in the getting started guide - everything worked really well and was clearly explained. However, I got somewhat stuck when looking at how to integrate the stack with my code.
I was originally expecting a library with some API, but I understand that CANopenNode came to Linux from MCUs, so the setup appears to be different. What is the suggested approach? Should I modify the sources in CANopenNode/socketCAN and integrate my application into them?
Basically I am processing data from other sources (i.e. online) and interacting with the CAN bus (reading/writing messages), SDO is also being used.
I would appreciate an advice on how to go about it. Thank you!
Kind regards,
Jin
It is easiest, if you look into socketCAN/CO_main_basic.c and seek for
You can insert your code via functions there.
Otherwise make your custom main.c file...
Hi Janez,
I saw these ifdefs and was thinking that it must be for "hooking in", but the hooks seem too basic, and I think just replacing the main.c would not yet help, unless something obvious is evading me :)
For instance - how can I get triggered on incoming CAN data? Or what is the proper way to tell CANopenNode to send a CAN message from the application, i.e. tell from another thread? Should I be calling
CO_CANCheckSend()
from my code? I also seeCO_GTWA_write()
which implies the ASCII notation, or is the ASCII notation actually the API/interface that I am asking about?I am struggling to understand the API of CANopenNode so any help what sources to look at or some examples would be greatly appreciated.
Say, I have a thread that gets data from the outside, what's the proper way to propagate this data to the CAN bus? And also what is the proper way to get notified when I receive something from the CAN bus? Is there an "API" in the common sense where I could subscribe to events on the CAN bus or events on the object dictionary or do I "just" hook directly into the code at strategic places?
Or is the idea to use the local socket mode and have an external application communicate and exchange data and events over this socket? I assume that would be in ASCII notation as well?
I am really not sure which way to go, so please suggest an approach which you had in mind when designing the stack, what's the correct way to use it?
You are talking about CAN. But CANopen is something else, it is higher level protocol build on top of CAN. CANopen is widely used in industrial automation and similar. There are books, which explain CANopen. For basic explanation see README.md file.
If you just need CAN in Linux, then you may read the Linux kernel documentation:
https://www.kernel.org/doc/html/latest/networking/can.html
OK sorry, I indeed mixed two things together. So raw CAN is outside of CANopenNode, that's clear now. Still, my integration question remains open, for instance if my application needed to support SDO which is implemented in CANopenNode, how did you mean for the integration to happen?
Should applications be using the socket connection and the 309.3 ASCII gateway protocol? Or should they embed CANopenNode code directly?
I did have a look at the docs prior to posting and I saw some examples of new devices targeted for MCU, but with the socketCAN client I'm still missing the understanding if I am supposed just to use the CANopenNode code/linux client as a basis for an application and embed the code, or if there is some API to have a clean cut, be it via some library header and linking of the sources or a socket API?
CANopenNode can also run on simple microcontroller. For example simple CANopen capable sensor, which has multiple parameters configurable. Parameters are ordered in Object Dictionary. SDO server enables access of any own parameter to external CANopen configuration device. Some parameters can be configured for transfer with no protocol overhead (see PDO). There are usually multiple "simple" CANopen devices communicating over CANopen network. They usually exchange PDO-s between themselves.
Linux example of CANopenNode has quite reach configuration. It includes additional SDO client, gateway, etc. It can be used to configure other CANopen devices.
I currently have no example for simpler Linux based CANopen device. You can see into https://github.com/CANopenNode/CANopenPIC