VMX-pi C++ HAL Library for Raspberry Pi
VMX-pi Robotics Controller & Vision/Motion Processor
|
The VMXCAN class provides a hardware-abstraction of the VMX-pi CAN functionality. More...
#include <VMXCAN.h>
Public Types | |
enum | VMXCANMode { VMXCAN_OFF, VMXCAN_CONFIG, VMXCAN_NORMAL, VMXCAN_LISTEN, VMXCAN_LOOPBACK } |
Enumeration of VMX CAN operational modes. More... | |
Public Member Functions | |
bool | SendMessage (VMXCANMessage &msg, int32_t periodMs, VMXErrorCode *errcode=0) |
Enqueues the CAN message for transmission onto the CAN bus to which the VMX device is currently connected. More... | |
bool | OpenReceiveStream (VMXCANReceiveStreamHandle &streamHandle, uint32_t messageID, uint32_t messageMask, uint32_t maxMessages, VMXErrorCode *errcode=0) |
Opens a new CAN receive stream. More... | |
bool | ReadReceiveStream (VMXCANReceiveStreamHandle streamHandle, VMXCANTimestampedMessage *messages, uint32_t messagesToRead, uint32_t &messagesRead, VMXErrorCode *errcode=0) |
Reads CAN messages which were recently received by the receive stream. More... | |
bool | CloseReceiveStream (VMXCANReceiveStreamHandle streamHandle, VMXErrorCode *errcode=0) |
Closes a previously-opened CAN Receive Stream, and releases any HW Filter Resources, if any. More... | |
bool | GetCANBUSStatus (VMXCANBusStatus &bus_status, VMXErrorCode *errcode=0) |
Retrieve the current CAN Bus status and statistics. More... | |
bool | Reset (VMXErrorCode *errcode=0) |
Reset the VMX CAN Transceiver and Protocol Controller. More... | |
bool | FlushTxFIFO (VMXErrorCode *errcode=0) |
Empty the VMX CAN transmit buffer. More... | |
bool | FlushRxFIFO (VMXErrorCode *errcode=0) |
Empty the VMX CAN receive buffer. More... | |
bool | SetMode (VMXCANMode mode, VMXErrorCode *errcode=0) |
Set the VMX CAN Protocol Transceiver/Protocol Controller Mode: More... | |
bool | GetMode (VMXCANMode &mode, VMXErrorCode *errcode=0) |
Retreieve the current VMX CAN Transceiver/Controller mode. More... | |
bool | ClearErrors (VMXErrorCode *errcode=0) |
If any VMX CAN errors are reported by the firmware, they are cleared. More... | |
bool | RetrieveAllCANData (VMXErrorCode *errcode=0) |
Retrieve the recently-received CAN Bus messages from the VMX CAN receivequeue. More... | |
void | DisplayMasksAndFilters () |
Diagnostic message which prints the current CAN Protocol Controller's Mask and filters. | |
Friends | |
class | VMXPi |
The VMXCAN class provides a hardware-abstraction of the VMX-pi CAN functionality.
enum VMXCAN::VMXCANMode |
Enumeration of VMX CAN operational modes.
bool VMXCAN::ClearErrors | ( | VMXErrorCode * | errcode = 0 | ) |
If any VMX CAN errors are reported by the firmware, they are cleared.
All VMX CAN errors are transient ~except~ the HW RX Overflow condition. If this condition exists, this method will clear it.
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::CloseReceiveStream | ( | VMXCANReceiveStreamHandle | streamid, |
VMXErrorCode * | errcode = 0 |
||
) |
Closes a previously-opened CAN Receive Stream, and releases any HW Filter Resources, if any.
streamid | Handle of VMXCANReceiveStream to close | |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::FlushRxFIFO | ( | VMXErrorCode * | errcode = 0 | ) |
Empty the VMX CAN receive buffer.
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::FlushTxFIFO | ( | VMXErrorCode * | errcode = 0 | ) |
Empty the VMX CAN transmit buffer.
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::GetCANBUSStatus | ( | VMXCANBusStatus & | bus_status, |
VMXErrorCode * | errcode = 0 |
||
) |
Retrieve the current CAN Bus status and statistics.
[out] | bus_status | The current status/statistics, returned by this method. |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::GetMode | ( | VMXCANMode & | mode, |
VMXErrorCode * | errcode = 0 |
||
) |
Retreieve the current VMX CAN Transceiver/Controller mode.
[out] | mode | The current mode. |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::OpenReceiveStream | ( | VMXCANReceiveStreamHandle & | session_handle, |
uint32_t | messageID, | ||
uint32_t | messageMask, | ||
uint32_t | maxMessages, | ||
VMXErrorCode * | errcode = 0 |
||
) |
Opens a new CAN receive stream.
session_handle | A handle to the newly-created stream | |
messageID | The CAN message ID to receive messages from | |
messageMask | The CAN message mask to receive messages from | |
maxMessages | The maximum number of received messages held within the stream | |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::ReadReceiveStream | ( | VMXCANReceiveStreamHandle | streamid, |
VMXCANTimestampedMessage * | messages, | ||
uint32_t | messagesToRead, | ||
uint32_t & | messagesRead, | ||
VMXErrorCode * | errcode = 0 |
||
) |
Reads CAN messages which were recently received by the receive stream.
streamid | Handle to the CAN receive stream to read messages from | |
[out] | messages | Buffer to read received messages into |
messagesToRead | The maximum number of messages to read into the memory pointed to by the messages parameter | |
[out] | messagesRead | The actual number of messages read into the memory pointed to by the messages parameter |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::Reset | ( | VMXErrorCode * | errcode = 0 | ) |
Reset the VMX CAN Transceiver and Protocol Controller.
Note this method will block for 10ms after resetting the controller.
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::RetrieveAllCANData | ( | VMXErrorCode * | errcode = 0 | ) |
Retrieve the recently-received CAN Bus messages from the VMX CAN receivequeue.
Received messages are place into the receive stream queue whose messageID filter matches each message.
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::SendMessage | ( | VMXCANMessage & | msg, |
int32_t | periodMs, | ||
VMXErrorCode * | errcode = 0 |
||
) |
Enqueues the CAN message for transmission onto the CAN bus to which the VMX device is currently connected.
msg | The message to be transmitted at the ID specified within the message. | |
periodMs | If non-zero, the message is periodically retransmitted after this number of milliseconds. | |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::SetMode | ( | VMXCANMode | mode, |
VMXErrorCode * | errcode = 0 |
||
) |
Set the VMX CAN Protocol Transceiver/Protocol Controller Mode:
mode | The requested CAN mode | |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |