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 | CANBusBitrate { CAN_BUS_BITRATE_1MBPS, CAN_BUS_BITRATE_500KBPS, CAN_BUS_BITRATE_250KBPS } |
enum | VMXCANMode { VMXCAN_OFF, VMXCAN_CONFIG, VMXCAN_NORMAL, VMXCAN_LISTEN, VMXCAN_LOOPBACK } |
Enumeration of VMX CAN operational modes. More... | |
Public Member Functions | |
void | DisplayMasksAndFilters () |
Diagnostic message which prints the current CAN Protocol Controller's Mask and filters. | |
bool | SendMessage (VMXCANMessage &msg, int32_t periodMs, VMXErrorCode *errcode) |
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) |
Opens a new CAN receive stream. More... | |
bool | ReadReceiveStream (VMXCANReceiveStreamHandle streamHandle, VMXCANTimestampedMessage *messages, uint32_t messagesToRead, uint32_t &messagesRead, VMXErrorCode *errcode) |
Reads CAN messages which were recently received by the receive stream. More... | |
bool | CloseReceiveStream (VMXCANReceiveStreamHandle streamHandle, VMXErrorCode *errcode) |
Closes a previously-opened CAN Receive Stream, and releases any HW Filter Resources, if any. More... | |
bool | GetCANBUSStatus (VMXCANBusStatus &bus_status, VMXErrorCode *errcode) |
Retrieve the current CAN Bus status and statistics. More... | |
bool | Reset (VMXErrorCode *errcode) |
Reset the VMX CAN Transceiver and Protocol Controller. More... | |
bool | ResetBusBitrate (VMXCAN::CANBusBitrate can_bus_bitrate, VMXErrorCode *errcode) |
bool | FlushTxFIFO (VMXErrorCode *errcode) |
Empty the VMX CAN transmit buffer. More... | |
bool | FlushRxFIFO (VMXErrorCode *errcode) |
Empty the VMX CAN receive buffer. More... | |
bool | SetMode (VMXCANMode mode, VMXErrorCode *errcode) |
Set the VMX CAN Protocol Transceiver/Protocol Controller Mode: More... | |
bool | GetMode (VMXCANMode ¤t_mode, VMXErrorCode *errcode) |
Retreieve the current VMX CAN Transceiver/Controller mode. More... | |
bool | ClearErrors (VMXErrorCode *errcode) |
If any VMX CAN errors are reported by the firmware, they are cleared. More... | |
bool | RetrieveAllCANData (uint64_t sys_timestamp, VMXErrorCode *errcode) |
Retrieve the recently-received CAN Bus messages from the VMX CAN receivequeue. More... | |
bool | EnableReceiveStreamBlackboard (VMXCANReceiveStreamHandle streamHandle, bool enable, VMXErrorCode *errcode) |
bool | IsReceveStreamBlackboardEnabled (VMXCANReceiveStreamHandle streamHandle, bool &enabled, VMXErrorCode *errcode) |
bool | GetBlackboardEntry (VMXCANReceiveStreamHandle streamid, uint32_t messageID, VMXCANTimestampedMessage &msg, uint64_t &sys_timestamp, bool &already_retrieved, VMXErrorCode *errcode) |
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 | ) |
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 | ||
) |
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 | ) |
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 | ) |
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 | ||
) |
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 | ||
) |
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 | ||
) |
Opens a new CAN receive stream.
session_handle | A handle to the newly-created stream | |
messageID | The CAN message ID to receive messages from. If standard (11-bit) IDs are to be acquired, the VMXCAN_IS_FRAME_11BIT bit must be set; if this bit is not set, only extended (29-bit) IDs will be acquired. | |
messageMask | The CAN message mask to receive messages from. If standard (11-bit) IDs are to be acquired the VMXCAN_IS_FRAME_11BIT bit must be set; if this bit is not set, only extended (29-bit) IDs will be acquired. | |
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 | ||
) |
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 | ) |
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 | ( | uint64_t | sys_timestamp, |
VMXErrorCode * | errcode | ||
) |
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 | ||
) |
Enqueues the CAN message for transmission onto the CAN bus to which the VMX device is currently connected.
The message is placed into a Fifo and transmitted as soon as possible.
This function is re-entrant and thus may be called from multiple contexts.
msg | The message to be transmitted at the ID specified within the message. Note that unless the periodMs parameter is negative, the data bytes and length in the message must be valid. | |
periodMs | If >= 0, the message is set immediately. Additionally, if greater than zero, the message (and its data) is periodically retransmitted after this number of milliseconds. If zero, the message is only transmitted once. If less than zero, any previously-requested periodic message retranmsittal for this CAN ID will be cancelled. | |
[out] | errcode | Pointer to the VMXErrorCode to be returned in case of error; may be null |
bool VMXCAN::SetMode | ( | VMXCANMode | mode, |
VMXErrorCode * | errcode | ||
) |
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 |