CARMA C++
|
Class to control the CARMA specialized Janz CAN/DIO card. More...
#include <carma/canbus/CanDio.h>
Public Types | |
typedef ::std::pair< int, int > | BoardSlotPair |
Pair containing boardId (first) and slotId (second). More... | |
typedef ::std::pair < BoardSlotPair, bool > | DevTermPair |
Pair for board & slot (first) and termination setting (second). More... | |
Public Member Functions | |
CanDio () | |
Default constructor. More... | |
CanDio (int boardId, bool reset=true, bool terminate=true) | |
Constructor to control both CAN busses on a single board. More... | |
CanDio (int boardId, int slotId, bool reset=true, bool terminate=true) | |
Constructor to control a single CAN bus. More... | |
CanDio (const std::vector< DevTermPair > &devTermPairs, bool reset=true) | |
Constructor to control arbitrary number of CAN busses. More... | |
void | echoAll (bool enable) |
Enable or disable echoing sent messages back through the read interface. More... | |
std::map< busIdType, carma::canbus::busStatusType > | getBusStatus () |
carma::canbus::Message | getMessage () |
Retrieve a CAN message. More... | |
bool | isTerminated () |
Return termination state. More... | |
void | postMessage (const carma::canbus::Message &msg, carma::canbus::txPriorityType prio=carma::canbus::NORMAL) |
Post a CAN message. More... | |
void | reset () |
Reset. More... | |
![]() | |
virtual BusStatusMap | getBusStatus () const |
Retrieve bus statistics. More... | |
virtual | ~CanIo () |
Virtual destructor. More... | |
Protected Member Functions | |
void | clearReadQueue () |
Clear any underlying read buffers. More... | |
void | queueMessage (const Message &msg) |
Queue CAN message to be read for simulation purposes. More... | |
void | setTimestampEchoLatency (int tsLatency, busIdType busId) |
Set timestamp echo latency. More... | |
Protected Attributes | |
std::auto_ptr < carma::canbus::CanIo > | cio_ |
std::auto_ptr< carma::canbus::Dio > | dio_ |
const long | pulseWidth_ |
Reset pulsewidth. More... | |
const bool | terminate_ |
Class to control the CARMA specialized Janz CAN/DIO card.
This class controls a very specific hardware setup used in CARMA and described below. For more general usage of arbitrary CAN or TTL devices, use the CanIo and/or Dio variants.
This class controls the composite Janz CARMA compact PCI carrier board. The cPCI carrier board contains 4 mezanine daughter boards - from top to bottom, these are 2 x vmod-ican3 CAN cards, an in-house RJ45 breakout board and a vmod-ttl digital IO board. Signals from the CAN and DIO boards are rerouted and combined through the backplane to the RJ45 card which serves as the primary physical interface. The Dio lines control hardware reset functionality of CARMA CAN modules.
The cPCI carrier board is identified by it's unique 'modulbus' number. The modulbus number is set via a hex switch on the carrier board. Older carrier boards instead contain a rom chip clearly labeled 'Modbus X'. Particular mezanine slots are labeled on the front panel as 'MODULbus N'. Janz ambiguously uses the term modulbus to refer to both the board and/or a specific slot. We take care to use the term 'board' to refer to the cPCI carrier board id (e.g. the hex switch identifier) and 'slot' to refer to the specific mezanine slot.
typedef ::std::pair< int, int > carma::canbus::CanDio::BoardSlotPair |
typedef ::std::pair< BoardSlotPair, bool > carma::canbus::CanDio::DevTermPair |
carma::canbus::CanDio::CanDio | ( | ) |
Default constructor.
This constructor is for use when emulating the underlying Janz hardware. If no Janz hardware exists, use this constructor. All Can or Dio write routines will write to /dev/null.
carma::canbus::CanDio::CanDio | ( | int | boardId, |
bool | reset = true , |
||
bool | terminate = true |
||
) |
Constructor to control both CAN busses on a single board.
boardId | Janz cPCI carrier board modulbus number (0x0-0xf). |
reset | Place modules in a hardware reset state by default. |
terminate | Terminate both busses if true. |
carma::util::ErrorException | on failure. |
carma::canbus::CanDio::CanDio | ( | int | boardId, |
int | slotId, | ||
bool | reset = true , |
||
bool | terminate = true |
||
) |
Constructor to control a single CAN bus.
boardId | Janz cPCI carrier board modulbus number (0x0-0xf). |
slotId | Mezanine slot id of CAN card (0 or 1). |
reset | Place modules in a hardware reset state by default. |
terminate | Terminate bus if true. |
carma::util::ErrorException | on failure. |
carma::canbus::CanDio::CanDio | ( | const std::vector< DevTermPair > & | devTermPairs, |
bool | reset = true |
||
) |
Constructor to control arbitrary number of CAN busses.
devTermPairs | Bus identifier and termination vector. |
reset | Place modules in a hardware reset state by default. |
carma::util::ErrorException | on failure. |
|
protectedvirtual |
Clear any underlying read buffers.
Useful for startup when we want to begin from a known reset state. Default implementation is a no-op.
Reimplemented from carma::canbus::CanIo.
|
virtual |
Enable or disable echoing sent messages back through the read interface.
The default implementation is a no-op.
enable | Echo CAN messages if true, don't if false. |
Reimplemented from carma::canbus::CanIo.
|
virtual |
Retrieve a CAN message.
This routine should block until a message is available.
Implements carma::canbus::CanIo.
bool carma::canbus::CanDio::isTerminated | ( | ) |
Return termination state.
Returns true if terminated, false otherwise.
|
virtual |
Post a CAN message.
Send a carma::canbus::Message to a single or multiple CANbusses as specified by the Message::setBusId method. To send to all CAN busses use the carma::canbus::ALL_BUSSES constant.
msg | The carma::canbus::Message to post. |
prio | Priority of message. |
Implements carma::canbus::CanOutput.
|
protectedvirtual |
Queue CAN message to be read for simulation purposes.
By default this method is a no-op.
msg | Message object to queue. |
Reimplemented from carma::canbus::CanIo.
void carma::canbus::CanDio::reset | ( | ) |
Reset.
Resets the CANbus using Dio and clears the CAN message read queue. This assures that users will retrieve only messages that were sent after this method was called (i.e. no old messages will remain in CAN read queue).
JanzFailException | if unable to write to dio board. |
|
protectedvirtual |
Set timestamp echo latency.
By default this method is a no-op.
tsLatency | Timestamp latency in microseconds. |
busId | Bus identifier. |
Reimplemented from carma::canbus::CanIo.
|
protected |