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 Types

enum  NodeStatus {
  PowerOff, Initialisation, PreOperational, Stopped,
  Operational
}
 The CANOpen State Diagram of a Device.

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.
unsigned int nodeId () const
 Returns the node ID of this device.
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.

Public Attributes

NodeStatus status
 The state of this device.

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 52 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 141 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(), CANMessage::getExtId(), CANMessage::getStdId(), CANRequest::isExpired(), CANMessage::isExtended(), and CANMessage::isStandard().


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

Generated on Tue Aug 25 14:09:55 2009 for OrocosComponentLibrary by  doxygen 1.5.8