Giter Club home page Giter Club logo

canopendemo's Introduction

CANopenDemo {#readmeCANopenDemo}

CANopenDemo includes demo program with CANopenNode, tutorial and testing tools.

It is based on CANopenNode, which is free and open source CANopen Stack and is included as a git submodule.

CANopen is the internationally standardized (EN 50325-4) (CiA301) CAN-based higher-layer protocol for embedded control system. For more information on CANopen see http://www.can-cia.org/

CANopenDemo homepage is https://github.com/CANopenNode/CANopenDemo

Getting or updating the project

Clone the project from git repository and get submodules:

git clone https://github.com/CANopenNode/CANopenDemo.git
cd CANopenDemo
git submodule update --init --recursive

There are several git submodules in CANopenDemo, see file .gitmodules. Some submodules, like CANopenLinux includes own git submodule CANopenNode, which is also updated with the above command.

If repositories are clean, the project can be updated by the following commands:

cd CANopenDemo
git pull
git submodule update --init --recursive

Object Dictionary Editor

Use CANopenEditor to edit the object dictionary. Binaries are available, editor runs also in Linux with mono. Just run the EDSEditor.exe as a GUI application. You can open the demoDevice.xdd file, make changes according to your needs, export demoDevice.eds or demoDevice.md file, generate C source files for object dictionary (OD.h and OD.c), etc.

CANopen demoDevice

CANopen demoDevice can run on different target devices. It contains object dictionary with most common communication parameters and some additional manufacturer specific and device profile parameters. Simple example program run from application interface and shows some principles of CANopenNode usage.

See demo/README.md.

CANopenLinux

CANopenLinux is a CANopen stack running on Linux devices. It has full CANopen functionality with additional CANopen ASCII command interface (gateway) It can be used as a commander for other CANopen devices: NMT master, LSS master, SDO client, etc.

See CANopenLinux/README.md.

Tutorial

CANopen testing

Tests on Running CANopen network are implemented with two CANopenNode devices, running on CAN interface. First is CANopenLinux device with gateway interface, second is CANopen demoDevice.

Tests are run in Linux command line with Bash Automated Testing System - BATS, which is included in CANopenDemo as three git submodules.

See test/README.md.

Html documentation

CANopenNode.github.io is a git submodule with html documentation for CANopenDemo, CANopenNode and other devices. It is available also online at https://canopennode.github.io. Documentation is generated by doxygen. Documentation is generated separately for: CANopenNode, CANopenLinux (+ other target devices) and CANopenDemo. There are some links in the menu between different documentations. CANopenNode also contains tagfile which enables links to it from CANopenLinux and CANopenDemo.

To update the documentation of the CANopenNode.github.io install tools and generate all files:

sudo apt install doxygen graphviz pdf2svg
./update_docs.sh

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

canopendemo's People

Contributors

canopennode avatar jacobq avatar ttmut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

canopendemo's Issues

Provide an example working with two CAN interfaces

Hello.
Could you provide an example of code working with two CAN IFs ?
I have Linux x86-64 PC with PCIe dual CAN card.
Interfaces are can0 and can1.
I have two ODs (OD1.c, OD1.h, OD2.c, OD2.h)
OPT += -DCO_MULTIPLE_OD in Makefile.
What to do next?
Example code in "demo" directory cannot be compiled with 'OPT += -DCO_MULTIPLE_OD'

BR

Bitrate Setting Not Functioning as Expected

I've been using CANOpenNode for a few months now, and I'm currently trying to set up the bitrate using the command lss_conf_bitrate <table_selector=0> <table_index>. Initially, when I run the command with cocomm "lss_conf_bitrate 0 0", I receive the following error:

ERROR:102 #Request not processed due to internal state.

To troubleshoot, I switched the state to selective mode using the command cocomm "lss_switch_sel 0x00000000 0x00000001 0x00000000 0x00000003". After doing this, I tried running the cocomm "lss_conf_bitrate 0 0" command again. However, this time I encountered a different error:

ERROR:103 #Time-out.

Any guidance on resolving these issues would be greatly appreciated.

The domain demo program failed to read

Hi!
I put the domain demo application file on my device A, and then I used the SDO reader function on another device B to read the domain, but I found that it failed to read 1024 bytes, I changed here

static OD_size_t dataSize = 512

And it worked.

I wonder if the SDO read failed because 1,024 bytes were too many and the fifo was full?

Configure TPDO 3 in demoDevice

Hello there,

I am following https://github.com/CANopenNode/CANopenDemo/blob/master/tutorial/PDO.md and running two demo devices (giving them node id 4 and 5, both devices in operational and made the node 1 as commander device and running "cocomm" utility) and was able to do the following:
cocomm "4 w 0x1802 1 u32 0x80000000"
cocomm "4 w 0x1A02 0 u8 0"
cocomm "4 w 0x1A02 1 u32 0x21100120"
cocomm "4 w 0x1A02 0 u8 1"
cocomm "4 w 0x1802 1 u32 0x00000384"

change the value at 0x2110[1]: cocomm "4 w 0x2110 1 u32 0xAABBCCDD" I can see TPDO 0x384 triggered (on candump)

But when I tried to map TPDO x384 to any sub-index (other than 1) let say sub-index 3 of 0x2110; for instance:
cocomm "4 w 0x1802 1 u32 0x80000000"
cocomm "4 w 0x1A02 0 u8 0"
cocomm "4 w 0x1A02 1 u32 0x21100320" (Note: changed the sub-index here from 1 to 3)
cocomm "4 w 0x1A02 0 u8 1"
cocomm " w 0x1802 1 u32 0x00000384"

and change the value of this variable,
cocomm "4 w 0x2110 3 u32 0x11223344"
it did not trigger the TPDO, it seems it only trigger the TPDO3 when I change something in 0x2110[1] not at 0x2110[3]

Am I missing some PDOs fundamental here? Can't we jump to any subindex of any variable (0x2110) in my case or will trigger only happen if sub-index 1 value is changed and it will also bring the other sub-index value (sub-index 3 in this case) with it, because that I can see on candump but if I only do cocomm "4 w 0x2110 3 u32 0x_differnet_value_now" I dont see any TPDO from 0x384.

Thanks,

PDO tutorial doesn't work

Hello.
I am following the PDO configuration tutorial however PDO's are not produced by the demo device.

What I have done so far:

  • start candump can0
  • run demo device ./demoLinuxDevice can0
  • start canopend with stdin interface ./canopend can0 -i 1 -c stdio and send commands based on tutorial

Outputs:

  • demo device
./demoLinuxDevice can0
./demoLinuxDevice[30528]: CANopen device, Node ID = 0x00, starting
./demoLinuxDevice[30528]: CAN Interface "can0" RX buffer set to 477 messages (212992 Bytes)
./demoLinuxDevice[30528]: CANopen NMT state changed to: "initializing" (0)
./demoLinuxDevice[30528]: CANopen device, Node ID = 0x04, communication reset
./demoLinuxDevice[30528]: CANopen device, Node ID = 0x04, running ...
./demoLinuxDevice[30528]: CANopen NMT state changed to: "pre-operational" (127)
  • canopend
./canopend can0 -i 1 -c stdio
./canopend[30531]: CANopen device, Node ID = 0x00, starting
./canopend[30531]: CANopen command interface on "standard IO" started
./canopend[30531]: CAN Interface "can0" RX buffer set to 477 messages (212992 Bytes)
./canopend[30531]: CANopen NMT state changed to: "initializing" (0)
./canopend[30531]: CANopen device, Node ID = 0x01, communication reset
./canopend[30531]: CANopen device, Node ID = 0x01, running ...
./canopend[30531]: CANopen NMT state changed to: "pre-operational" (127)
./canopend[30531]: CANopen Emergency message from node 0x01: errorCode=0x5000, errorRegister=0x01, errorBit=0x2F, infoCode=0x00000004
set node 4
[0] OK
preop                                          #preoperational mode
[0] OK
w 0x1802 1 u32 0x80000000
[0] OK
w 0x1A02 0 u8 0
[0] OK
w 0x1A02 1 u32 0x21100120
[0] OK
w 0x1A02 0 u8 1
[0] OK
w 0x1802 1 u32 0x00000384
[0] OK
w 0x1802 5 u16 500                   #start imer every 500ms
[0] OK
start                                            #transition to operational mode
[0] OK
  • candump
candump can0
  can0  704   [1]  00
  can0  084   [8]  00 50 01 2F 24 00 00 00
  can0  701   [1]  00
  can0  081   [8]  00 50 01 2F 04 00 00 00
  can0  000   [2]  80 04
  can0  604   [8]  23 02 18 01 00 00 00 80
  can0  584   [8]  60 02 18 01 00 00 00 00
  can0  604   [8]  2F 02 1A 00 00 00 00 00
  can0  584   [8]  60 02 1A 00 00 00 00 00
  can0  604   [8]  23 02 1A 01 20 01 10 21
  can0  584   [8]  60 02 1A 01 00 00 00 00
  can0  604   [8]  2F 02 1A 00 01 00 00 00
  can0  584   [8]  60 02 1A 00 00 00 00 00
  can0  604   [8]  23 02 18 01 84 03 00 00
  can0  584   [8]  60 02 18 01 00 00 00 00
  can0  604   [8]  2B 02 18 05 F4 01 00 00
  can0  584   [8]  60 02 18 05 00 00 00 00
  can0  000   [2]  01 04

Please note that there are no PDOs captured by candump. There should be 384 PDOs.

Is there any missing step to start the production of PDOs? Am I doing something incorrectly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.