CARMA C++
carma::canbus::CanDio Class Reference

Class to control the CARMA specialized Janz CAN/DIO card. More...

#include <carma/canbus/CanDio.h>

Inheritance diagram for carma::canbus::CanDio:
carma::canbus::CanIo carma::canbus::CanOutput carma::canbus::Master carma::antenna::bima::IFCanMaster carma::antenna::ovro::OvroMaster carma::canbus::MasterOfNone carma::clock::ClockMaster carma::downconverter::SldcMaster carma::downconverter::WbdcMaster carma::loberotator::LoberotatorMaster

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...
 
- Public Member Functions inherited from carma::canbus::CanIo
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::Diodio_
 
const long pulseWidth_
 Reset pulsewidth. More...
 
const bool terminate_
 

Detailed Description

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.

Definition at line 48 of file CanDio.h.

Member Typedef Documentation

typedef ::std::pair< int, int > carma::canbus::CanDio::BoardSlotPair

Pair containing boardId (first) and slotId (second).

Definition at line 86 of file CanDio.h.

typedef ::std::pair< BoardSlotPair, bool > carma::canbus::CanDio::DevTermPair

Pair for board & slot (first) and termination setting (second).

Definition at line 91 of file CanDio.h.

Constructor & Destructor Documentation

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.

Parameters
boardIdJanz cPCI carrier board modulbus number (0x0-0xf).
resetPlace modules in a hardware reset state by default.
terminateTerminate both busses if true.
Exceptions
carma::util::ErrorExceptionon failure.
carma::canbus::CanDio::CanDio ( int  boardId,
int  slotId,
bool  reset = true,
bool  terminate = true 
)

Constructor to control a single CAN bus.

Parameters
boardIdJanz cPCI carrier board modulbus number (0x0-0xf).
slotIdMezanine slot id of CAN card (0 or 1).
resetPlace modules in a hardware reset state by default.
terminateTerminate bus if true.
Exceptions
carma::util::ErrorExceptionon failure.
carma::canbus::CanDio::CanDio ( const std::vector< DevTermPair > &  devTermPairs,
bool  reset = true 
)

Constructor to control arbitrary number of CAN busses.

Parameters
devTermPairsBus identifier and termination vector.
resetPlace modules in a hardware reset state by default.
Exceptions
carma::util::ErrorExceptionon failure.

Member Function Documentation

void carma::canbus::CanDio::clearReadQueue ( )
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.

void carma::canbus::CanDio::echoAll ( bool  enable)
virtual

Enable or disable echoing sent messages back through the read interface.

The default implementation is a no-op.

Parameters
enableEcho CAN messages if true, don't if false.

Reimplemented from carma::canbus::CanIo.

carma::canbus::Message carma::canbus::CanDio::getMessage ( )
virtual

Retrieve a CAN message.

This routine should block until a message is available.

Returns
carma::canbus::Message object.

Implements carma::canbus::CanIo.

bool carma::canbus::CanDio::isTerminated ( )

Return termination state.

Returns true if terminated, false otherwise.

void carma::canbus::CanDio::postMessage ( const carma::canbus::Message msg,
carma::canbus::txPriorityType  prio = carma::canbus::NORMAL 
)
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.

Parameters
msgThe carma::canbus::Message to post.
prioPriority of message.

Implements carma::canbus::CanOutput.

void carma::canbus::CanDio::queueMessage ( const Message msg)
protectedvirtual

Queue CAN message to be read for simulation purposes.

By default this method is a no-op.

Parameters
msgMessage 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).

Exceptions
JanzFailExceptionif unable to write to dio board.
void carma::canbus::CanDio::setTimestampEchoLatency ( int  tsLatency,
busIdType  busId 
)
protectedvirtual

Set timestamp echo latency.

By default this method is a no-op.

Parameters
tsLatencyTimestamp latency in microseconds.
busIdBus identifier.

Reimplemented from carma::canbus::CanIo.

Member Data Documentation

const long carma::canbus::CanDio::pulseWidth_
protected

Reset pulsewidth.

In most cases the reset dio lines must be written hi for a minimal amount of time in order for a module's reset circuitry to detect it. This variable defines that minimal pulsewidth time in ms.

Definition at line 143 of file CanDio.h.


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