A CAN Request contains a send CAN message and an (expected) answer CAN message. More...
#include <CANRequest.hpp>
Public Member Functions | |
CANRequest (CANMessage *_write, CANMessage *_expect, Seconds _timeout=0) | |
Write a message to the bus and expect a repsonse with a given CobId and possibly data. | |
bool | sendTo (CANBusInterface *_bus) |
Sends the request to a bus and listens for the answer containing the expected cobId. | |
void | process (const CANMessage *msg) |
This method instructs the CANDeviceInterface instance to process a certain CANMessage. | |
void | abort () |
Abort the reception of an answer. | |
bool | isReceived () const |
Returns true if a message with the expected CobId was received. | |
bool | isExpired () const |
Returns true if the timeout expired. | |
bool | isExactMatch () const |
Returns true if a message was received with an exact match of the expected CANMessage. | |
bool | matchDataByte (unsigned int pos) const |
Returns true if databyte pos matches the expected value. | |
bool | matchDataByte (unsigned int start, unsigned int end) const |
Returns true if databytes start to end matches the expected value. | |
CANMessage * | getReceivedMessage () |
Returns the received message. | |
Protected Attributes | |
CANBusInterface * | bus |
CANMessage * | write |
CANMessage * | expected |
CANMessage * | result |
CANMessage | result_cache |
TimeService::ticks | timestamp |
Seconds | timeout |
A CAN Request contains a send CAN message and an (expected) answer CAN message.
It acts like a CANDeviceInterface on the virtual CANBusInterface and sends a request on it. It then listens until it receives a message with the same Cob Id.
Definition at line 51 of file CANRequest.hpp.
bool isExactMatch | ( | ) | const [inline] |
Returns true if a message was received with an exact match of the expected CANMessage.
An Exact match is when the CobId, DLC and data are equal to the expected values.
Definition at line 140 of file CANRequest.hpp.
bool matchDataByte | ( | unsigned int | start, | |
unsigned int | end | |||
) | const [inline] |
Returns true if databytes start to end matches the expected value.
start and end should be numbers from 0 to 7, denoting the byte positions.
Definition at line 164 of file CANRequest.hpp.
References CANMessage::getData().
void process | ( | const CANMessage * | msg | ) | [inline, virtual] |
This method instructs the CANDeviceInterface instance to process a certain CANMessage.
You are not the owner of msg.
msg | The message to be processed by this instance. |
Implements CANListenerInterface.
Definition at line 81 of file CANRequest.hpp.
References CANRequest::abort(), and CANRequest::isExpired().