A C++ study project that provides a flexible and extensible framework for working with CAN (Controller Area Network) communication in automotive and industrial applications. It supports both raw CAN and ISO-TP (ISO 15765-2) protocols.
- Support for raw CAN and ISO-TP protocols
- Easy-to-use interface for sending and receiving CAN messages
- Configurable CAN filters
- Timeout support for read operations
CanDevice
: Abstract base class for CAN devicesRawCanDevice
: Implementation for raw CAN protocolIsoTpCanDevice
: Implementation for ISO-TP protocolCanDeviceFactory
: Factory for CanDevice creationCanMessage
: Class representing CAN messages
Here's a basic example of how to use the library:
#include "RawCanDevice.h"
#include "CanMessage.h"
int main() {
RawCanDevice can("can0");
can.Open();
CanMessage::Data data{0x01, 0x02, 0x03, 0x04};
CanMessage message(0x123, data);
can.Send(message);
CanMessage received_message;
if (can.Read(received_message, 1000)) {
// Process received message
}
can.Close();
return 0;
}
- Simple interface
- Raw Protocol
- Basic Iso-TP Protocol
- Full Iso-TP Protocol
- Error handling
- Exemple of usage
- Unit Tests
- Integration Tests
- Opening a virtual CAN bus
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
- Dump Iso-Tp data
#Txid #Rxid
isotpdump -s 111 -d 321 vcan0
- Send Iso-Tp data
#Rxid #Txid
echo 11 12 13 14 15 16 | isotpsend -s 321 -d 111 vcan0