AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
toucan_vscp_canal.hpp
Go to the documentation of this file.
1//================================================================================================
9//================================================================================================
10#ifndef TOUCAN_VSCP_CANAL_PLUGIN_HPP
11#define TOUCAN_VSCP_CANAL_PLUGIN_HPP
12
13#include <string>
14
15#include "isobus/hardware_integration/canal.h"
16
20
21namespace isobus
22{
23 //================================================================================================
27 //================================================================================================
29 {
30 public:
35 TouCANPlugin(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate = 250);
36
41 explicit TouCANPlugin(std::string deviceName);
42
44 virtual ~TouCANPlugin();
45
48 bool get_is_valid() const override;
49
51 void close() override;
52
54 void open() override;
55
59 bool read_frame(isobus::CANMessageFrame &canFrame) override;
60
64 bool write_frame(const isobus::CANMessageFrame &canFrame) override;
65
71 bool reconfigure(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate = 250);
72
75 std::uint32_t get_serial_number() const;
76
77 private:
82 void generate_device_name(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate);
83
84 std::string name;
85 std::uint32_t handle = 0;
86 std::uint32_t openResult = CANAL_ERROR_NOT_OPEN;
88 };
89}
90#endif // TOUCAN_VSCP_CANAL_PLUGIN_HPP
An abstraction between this CAN stack and any hardware layer.
A base class for a CAN driver. Can be derived into your platform's required interface.
A classical CAN frame, with 8 data bytes.
An abstract base class for a CAN driver.
A CAN frame for interfacing with a hardware layer, like socket CAN or other interface.
An interface for using a Rusoku TouCAN device via the VSCP CANAL api.
virtual ~TouCANPlugin()
The destructor for TouCANPlugin.
std::uint32_t currentlyConfiguredSerialNumber
The serial number of the device that is being used.
void close() override
Closes the connection to the hardware.
TouCANPlugin(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate=250)
Constructor for a TouCAN hardware plugin object.
std::string name
A configuration string that is used to connect to the hardware through the CANAL api.
bool write_frame(const isobus::CANMessageFrame &canFrame) override
Writes a frame to the bus (synchronous)
std::uint32_t handle
The handle that the driver returns to us for the open hardware.
void open() override
Connects to the hardware.
void generate_device_name(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate)
Generates a device name string for the TouCAN device.
std::uint32_t openResult
Stores the result of the call to begin CAN communication. Used for is_valid check later.
std::uint32_t get_serial_number() const
Returns the currently configured serial number of the device which will be used to connect to the har...
bool reconfigure(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate=250)
Changes previously set configuration parameters. Only works if the device is not open.
bool read_frame(isobus::CANMessageFrame &canFrame) override
Returns a frame from the hardware (synchronous), or false if no frame can be read.
bool get_is_valid() const override
Returns if the connection with the hardware is valid.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...