AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
isobus::TouCANPlugin Class Reference

An interface for using a Rusoku TouCAN device via the VSCP CANAL api. More...

#include <toucan_vscp_canal.hpp>

Inheritance diagram for isobus::TouCANPlugin:
[legend]
Collaboration diagram for isobus::TouCANPlugin:
[legend]

Public Member Functions

 TouCANPlugin (std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate=250)
 Constructor for a TouCAN hardware plugin object.
 
 TouCANPlugin (std::string deviceName)
 Constructor for a TouCAN hardware plugin object.
 
virtual ~TouCANPlugin ()
 The destructor for TouCANPlugin.
 
bool get_is_valid () const override
 Returns if the connection with the hardware is valid.
 
void close () override
 Closes the connection to the hardware.
 
void open () override
 Connects to the hardware.
 
bool read_frame (isobus::CANMessageFrame &canFrame) override
 Returns a frame from the hardware (synchronous), or false if no frame can be read.
 
bool write_frame (const isobus::CANMessageFrame &canFrame) override
 Writes a frame to the bus (synchronous)
 
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.
 
std::uint32_t get_serial_number () const
 Returns the currently configured serial number of the device which will be used to connect to the hardware.
 

Private Member Functions

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.
 

Private Attributes

std::string name
 A configuration string that is used to connect to the hardware through the CANAL api.
 
std::uint32_t handle = 0
 The handle that the driver returns to us for the open hardware.
 
std::uint32_t openResult = CANAL_ERROR_NOT_OPEN
 Stores the result of the call to begin CAN communication. Used for is_valid check later.
 
std::uint32_t currentlyConfiguredSerialNumber = 0
 The serial number of the device that is being used.
 

Detailed Description

An interface for using a Rusoku TouCAN device via the VSCP CANAL api.

Definition at line 28 of file toucan_vscp_canal.hpp.

Constructor & Destructor Documentation

◆ TouCANPlugin() [1/2]

isobus::TouCANPlugin::TouCANPlugin ( std::int16_t deviceID,
std::uint32_t serialNumber,
std::uint16_t baudRate = 250 )

Constructor for a TouCAN hardware plugin object.

Parameters
[in]deviceIDThe id to use for this device
[in]serialNumberThe serial number of the CAN adapter to connect with
[in]baudRateThe baud rate in thousands (250K baud would mean you need to pass in 250)

Definition at line 20 of file toucan_vscp_canal.cpp.

Here is the call graph for this function:

◆ TouCANPlugin() [2/2]

isobus::TouCANPlugin::TouCANPlugin ( std::string deviceName)
explicit

Constructor for a TouCAN hardware plugin object.

Parameters
[in]deviceNameThe channel to use. This string has a very specific structure that isn't defined anywhere except the source code for this specific CANAL implementation.
Attention
Only use this if you know what you are doing, otherwise use the other constructor.

Definition at line 25 of file toucan_vscp_canal.cpp.

◆ ~TouCANPlugin()

isobus::TouCANPlugin::~TouCANPlugin ( )
virtual

The destructor for TouCANPlugin.

Definition at line 30 of file toucan_vscp_canal.cpp.

Member Function Documentation

◆ close()

void isobus::TouCANPlugin::close ( )
overridevirtual

Closes the connection to the hardware.

Implements isobus::CANHardwarePlugin.

Definition at line 39 of file toucan_vscp_canal.cpp.

◆ generate_device_name()

void isobus::TouCANPlugin::generate_device_name ( std::int16_t deviceID,
std::uint32_t serialNumber,
std::uint16_t baudRate )
private

Generates a device name string for the TouCAN device.

Parameters
[in]deviceIDThe id to use for this device
[in]serialNumberThe serial number of the CAN adapter to connect with
[in]baudRateThe baud rate in thousands (250K baud would mean you need to pass in 250)

Definition at line 114 of file toucan_vscp_canal.cpp.

Here is the caller graph for this function:

◆ get_is_valid()

bool isobus::TouCANPlugin::get_is_valid ( ) const
overridevirtual

Returns if the connection with the hardware is valid.

Returns
true if connected, false if not connected

Implements isobus::CANHardwarePlugin.

Definition at line 34 of file toucan_vscp_canal.cpp.

Here is the caller graph for this function:

◆ get_serial_number()

std::uint32_t isobus::TouCANPlugin::get_serial_number ( ) const

Returns the currently configured serial number of the device which will be used to connect to the hardware.

Returns
The currently configured serial number of the device

Definition at line 109 of file toucan_vscp_canal.cpp.

◆ open()

void isobus::TouCANPlugin::open ( )
overridevirtual

Connects to the hardware.

Implements isobus::CANHardwarePlugin.

Definition at line 45 of file toucan_vscp_canal.cpp.

◆ read_frame()

bool isobus::TouCANPlugin::read_frame ( isobus::CANMessageFrame & canFrame)
overridevirtual

Returns a frame from the hardware (synchronous), or false if no frame can be read.

Parameters
[in,out]canFrameThe CAN frame that was read
Returns
true if a CAN frame was read, otherwise false

Implements isobus::CANHardwarePlugin.

Definition at line 60 of file toucan_vscp_canal.cpp.

◆ reconfigure()

bool isobus::TouCANPlugin::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.

Parameters
[in]deviceIDThe id to use for this device
[in]serialNumberThe serial number of the CAN adapter to connect with
[in]baudRateThe baud rate in thousands (250K baud would mean you need to pass in 250)
Returns
True if the configuration was changed, otherwise false (if the device is open false will be returned)

Definition at line 97 of file toucan_vscp_canal.cpp.

Here is the call graph for this function:

◆ write_frame()

bool isobus::TouCANPlugin::write_frame ( const isobus::CANMessageFrame & canFrame)
overridevirtual

Writes a frame to the bus (synchronous)

Parameters
[in]canFrameThe frame to write to the bus
Returns
true if the frame was written, otherwise false

Implements isobus::CANHardwarePlugin.

Definition at line 82 of file toucan_vscp_canal.cpp.

Member Data Documentation

◆ currentlyConfiguredSerialNumber

std::uint32_t isobus::TouCANPlugin::currentlyConfiguredSerialNumber = 0
private

The serial number of the device that is being used.

Definition at line 87 of file toucan_vscp_canal.hpp.

◆ handle

std::uint32_t isobus::TouCANPlugin::handle = 0
private

The handle that the driver returns to us for the open hardware.

Definition at line 85 of file toucan_vscp_canal.hpp.

◆ name

std::string isobus::TouCANPlugin::name
private

A configuration string that is used to connect to the hardware through the CANAL api.

Definition at line 84 of file toucan_vscp_canal.hpp.

◆ openResult

std::uint32_t isobus::TouCANPlugin::openResult = CANAL_ERROR_NOT_OPEN
private

Stores the result of the call to begin CAN communication. Used for is_valid check later.

Definition at line 86 of file toucan_vscp_canal.hpp.


The documentation for this class was generated from the following files: