ardupilot/libraries/AP_CANManager
Andrew Tridgell 1723cca023 AP_CANManager: fixed owner of SLCAN UART
this broke when we moved to the unified AP_HAL locking system for
UARTs. The SLCAN code relied on the fact that the thread owner check
was not done for the read_locked() path. Now that we have a higher
level consistent API that check is done and SLCAN broke
2023-08-02 17:44:39 +10:00
..
AP_CAN.h AP_CANManager: move and rename CAN Driver_Type enumeration 2023-04-20 08:53:46 +10:00
AP_CANDriver.cpp AP_CANManager: move and rename CAN Driver_Type enumeration 2023-04-20 08:53:46 +10:00
AP_CANDriver.h AP_CANManager: remove unneccesary includes of AP_Vehicle_Type.h 2022-11-02 18:35:48 +11:00
AP_CANIfaceParams.cpp AP_CANManager: correct parameter metadata error 2022-03-14 08:18:13 +11:00
AP_CANManager.cpp AP_CANManager: move and rename CAN Driver_Type enumeration 2023-04-20 08:53:46 +10:00
AP_CANManager.h AP_CANManager: correct gate on definition of AP_CANManager class 2023-04-20 08:53:46 +10:00
AP_CANManager_config.h AP_CANManager: add and use option to compile SLCAN support out of code 2023-03-15 19:08:09 +11:00
AP_CANSensor.cpp AP_CANManager: move and rename CAN Driver_Type enumeration 2023-04-20 08:53:46 +10:00
AP_CANSensor.h AP_CANManager: move and rename CAN Driver_Type enumeration 2023-04-20 08:53:46 +10:00
AP_SLCANIface.cpp AP_CANManager: fixed owner of SLCAN UART 2023-08-02 17:44:39 +10:00
AP_SLCANIface.h AP_CANManager: add and use option to compile SLCAN support out of code 2023-03-15 19:08:09 +11:00
README.md AP_CANManager: remove CANTester 2023-04-18 11:43:58 +10:00

README.md

Testing And Debugging

Testing under SITL

https://github.com/linux-can/can-utils contains a nice set of utility to do CAN related testings on Linux system. I used Ubuntu for this development, for Ubuntu systems you can simply download this tool using sudo apt-get install can-utils

Following are the common commands that can be used while testing or developing:

  • Create Virtual CAN Interface:
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
sudo ip link add dev vcan1 type vcan
sudo ip link set up vcan1
  • Route one CANSocket to another
sudo modprobe can-gw
sudo cangw -A -s vcan0 -d vcan1 -e
sudo cangw -A -s vcan1 -d vcan0 -e
  • Delete routes
sudo cangw -D -s vcan0 -d vcan1 -e
sudo cangw -D -s vcan1 -d vcan0 -e
  • Route SLCAN to VCAN, this allows connecting CAN devices to SITL run via CAN Adapter like the one running in Ardupilot itself.
sudo modprobe slcan
sudo slcan_attach -f -s8 -o /dev/ttyACM0
sudo slcand ttyACM0 slcan0
sudo ifconfig slcan0 up
sudo cangw -A -s vcan0 -d slcan0 -e
sudo cangw -A -s slcan0 -d vcan0 -e
  • Dump can messages:
sudo candump vcan0