C++ class the CAN USB adapter CANUSB. More...
#include <inc/CANUSB.h>
Public Member Functions | |
bool | CANBusOpen () |
Check whether the CAN bus is open or not. | |
CANUSB (std::string *serial_port_name, boost::function< void(std::string *)> f) | |
Constructor. | |
bool | closeCANBus () |
Close the CAN bus. | |
CANUSB_BitRate | getCANBitRate () |
Get the current bit rate. | |
int | getSerialNumber () |
Get the serial number. | |
int | getVersion () |
Get the version. | |
bool | openCANBus (CANUSB_BitRate bit_rate) |
Open the CAN bus. | |
bool | reset () |
Reset. | |
bool | setCANBitRate (CANUSB_BitRate bit_rate) |
Set the bit rate. | |
bool | transmitExtendedFrame (std::string *frame) |
Transmit extended frame. | |
bool | transmitStandardFrame (std::string *frame) |
Transmit standard frame. | |
~CANUSB () | |
Destructor. | |
Private Member Functions | |
void | newFrameCallback (std::string *frame) |
New CAN frame callback. | |
Private Attributes | |
CANUSB_BitRate | bit_rate_ |
Bit rate. | |
bool | open_ |
CAN bus state. | |
boost::function< void(std::string *) | receivedFrameCallback ) |
Callback function. | |
cereal::CerealPort | serial_port_ |
Serial port. |
CANUSB::CANUSB | ( | std::string * | serial_port_name, |
boost::function< void(std::string *)> | f | ||
) |
Constructor.
Definition at line 52 of file CANUSB.cpp.
CANUSB::~CANUSB | ( | ) |
Destructor.
Definition at line 66 of file CANUSB.cpp.
bool CANUSB::CANBusOpen | ( | ) | [inline] |
bool CANUSB::closeCANBus | ( | ) |
Close the CAN bus.
This call closes the CAN bus.
bit_rate | Bit rate of the serial port. |
Definition at line 123 of file CANUSB.cpp.
CANUSB_BitRate CANUSB::getCANBitRate | ( | ) | [inline] |
int CANUSB::getSerialNumber | ( | ) |
Get the serial number.
Definition at line 259 of file CANUSB.cpp.
int CANUSB::getVersion | ( | ) |
Get the version.
Definition at line 251 of file CANUSB.cpp.
void CANUSB::newFrameCallback | ( | std::string * | frame | ) | [private] |
New CAN frame callback.
This function allows to receive CAn frames.
frame | Data frame to receive. |
Definition at line 266 of file CANUSB.cpp.
bool CANUSB::openCANBus | ( | CANUSB_BitRate | bit_rate | ) |
Open the CAN bus.
This opens the CAN bus with the desired baud rate.
bit_rate | Bit rate of the serial port. |
Definition at line 73 of file CANUSB.cpp.
bool CANUSB::reset | ( | ) |
Reset.
Resets the CANUSB.
Definition at line 155 of file CANUSB.cpp.
bool CANUSB::setCANBitRate | ( | CANUSB_BitRate | bit_rate | ) |
Set the bit rate.
Sets the USB2-F-7001 bit rate. Values are 10Kbp2 20Kbps 50Kbps 100Kbps 125Kbps 250Kbps 500Kbps 800Kbps 1000Kbps
Definition at line 181 of file CANUSB.cpp.
bool CANUSB::transmitExtendedFrame | ( | std::string * | frame | ) |
Transmit extended frame.
This function allows to send an extended CAN frame.
frame | Extended data frame to send. |
Definition at line 243 of file CANUSB.cpp.
bool CANUSB::transmitStandardFrame | ( | std::string * | frame | ) |
Transmit standard frame.
This function allows to send a standard CAN frame.
frame | Standard data frame to send. |
Definition at line 208 of file CANUSB.cpp.
CANUSB_BitRate CANUSB::bit_rate_ [private] |
bool CANUSB::open_ [private] |
boost::function<void(std::string*) CANUSB::receivedFrameCallback) [private] |
cereal::CerealPort CANUSB::serial_port_ [private] |