CANRequest Class Reference

A CAN Request contains a send CAN message and an (expected) answer CAN message. More...

#include <CANRequest.hpp>

Inheritance diagram for CANRequest:
CANDeviceInterface CANListenerInterface

List of all members.

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.
CANMessagegetReceivedMessage ()
 Returns the received message.

Protected Attributes

CANBusInterfacebus
CANMessagewrite
CANMessageexpected
CANMessageresult
CANMessage result_cache
TimeService::ticks timestamp
Seconds timeout

Detailed Description

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.


Member Function Documentation

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.

Parameters:
msg The message to be processed by this instance.
Invariant:
Only this may be removed from the CANBusInterface during process.

Implements CANListenerInterface.

Definition at line 81 of file CANRequest.hpp.

References CANRequest::abort(), and CANRequest::isExpired().


The documentation for this class was generated from the following file:
Generated on Thu Dec 23 15:05:29 2010 for OrocosComponentLibrary by  doxygen 1.6.3