mergCanBus
 All Classes Functions Typedefs
Message Class Reference

#include <Message.h>

Public Member Functions

 Message ()
 
 Message (unsigned int canId, unsigned int opc, unsigned int nodeNumber, unsigned int eventNumber, byte data[CANDATA_SIZE], unsigned int priority)
 
virtual ~Message ()
 
byte getByte (byte pos)
 
byte * getDataBuffer ()
 Get the 8 bytes CAN message buffer. The user can also get specific values using other methods. More...
 
void setDataBuffer (byte val[CANDATA_SIZE])
 
byte * getHeaderBuffer ()
 Get the 8 bytes CAN header buffer. The user can also get specific values using other methods. More...
 
void setHeaderBuffer (byte val[HEADER_SIZE])
 
byte getCanId ()
 
void setCanId (byte val)
 Set the can id in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
byte getOpc ()
 
void setOpc (byte val)
 Set the opc in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
message_type getType ()
 Get the message type. More...
 
void setType (message_type val)
 Set the message type NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
unsigned int getEventNumber ()
 
void setEventNumber (unsigned int val)
 Set event number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
unsigned int getNodeNumber ()
 
void setNodeNumber (unsigned int val)
 Set the node number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
unsigned int getDeviceNumber ()
 
void setDeviceNumber (unsigned int val)
 Set the device number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
byte getPriority ()
 Get the message priority in the Can header. More...
 
void setPriority (byte val)
 Set the message priority in the CAN header NOT USED. At the moment the messages are being assembled outside and loaded by setHeaderBuffer. More...
 
byte getMessageSize ()
 
unsigned int getNumBytes ()
 Get the number of bytes parameter in the message. More...
 
void setNumBytes (unsigned int val)
 Set the number of bytes parameter in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
void setRTR ()
 Set the CAN RTR parameter. Set after reading the CAN header.
 
void unsetRTR ()
 Unset the CAN RTR parameter.
 
bool getRTR ()
 Get the CAN RTR parameter. Set after reading the CAN header. More...
 
void setSession (byte val)
 Set the session value in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
byte getSession ()
 
unsigned int getDecoder ()
 
void setDecoder (unsigned int val)
 Set the decoder value NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
unsigned int getCV ()
 
void setCV (unsigned int val)
 Set the DCC CV value in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
unsigned int getCVMode ()
 
unsigned int getCVValue ()
 
byte getConsist ()
 
byte getSpeedDir ()
 
byte getEngineFlag ()
 
byte getAvailableEventsLeft ()
 
byte getStoredEvents ()
 
byte getFunctionNumber ()
 
byte functionValue ()
 
byte getStatus ()
 
byte getParaIndex ()
 
byte getParameter ()
 
byte getNodeVariableIndex ()
 
byte getNodeVariable ()
 
byte getEventIndex ()
 
byte getEventVarIndex ()
 
byte getEventVar ()
 
void clear ()
 
void setDebug (bool val)
 Force the code to print debug messages to the serial interface if value is True.
 
byte getCanMessageSize ()
 
void setCanMessageSize (byte val)
 Set the message size NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer. More...
 
bool isAccOn ()
 
bool isAccOff ()
 
bool isLongEvent ()
 
bool isShortEvent ()
 
byte accExtraData ()
 
byte getAccExtraData (byte idx)
 
void createOnEvent (unsigned int nodeNumber, bool longEvent, unsigned int eventNumber, byte numDataBytes, byte *data)
 Create a ON event message. More...
 
void createOffEvent (unsigned int nodeNumber, bool longEvent, unsigned int eventNumber, byte numDataBytes, byte *data)
 Create a OFF event message. More...
 

Detailed Description

The Message class holds the detailed information about a can message. If works as a wrapper class over the can bus message. It extracts the information from the message based on the semantics of the message OPC. Still in fase of modification and cleanning.

Constructor & Destructor Documentation

Message::Message ( )

Constructor Clear the internal buffers and load the basic configuration.

Message::Message ( unsigned int  canId,
unsigned int  opc,
unsigned int  nodeNumber,
unsigned int  eventNumber,
byte  data[CANDATA_SIZE],
unsigned int  priority 
)

Creates a message to be sent. Not being used. NOT USED AT THIS VERSION.

Parameters
canIdis the can id of the message.
opcis the opc code.
nodeNumberis the node number.
eventNumberis the event number.
datais the message data itself.
priorityis CAN priority.
Message::~Message ( )
virtual

Destructor

Member Function Documentation

byte Message::accExtraData ( )

Return how many bytes of extra data has the ON event.

Returns
The number of extra bytes depending on the message type. ACON,ACOF=0 ; ACON1,ACOF1=1; ACON2,ACOF2=2; ACON3,ACOF1=3
void Message::clear ( )

Clear the internal structure.

void Message::createOffEvent ( unsigned int  nodeNumber,
bool  longEvent,
unsigned int  eventNumber,
byte  numDataBytes,
byte *  msgdata 
)

Create a OFF event message.

Parameters
nodeNumberNode number of the message
longEventIndication of Long or Short event. True means long event.
eventNumberEvent number
numDataBytesNumber of extra bytes in the message. It defines the type of On event should be created: 0 means +ACOF or ASOF 1 means +ACOF1 or ASOF1 2 means +ACOF2 or ASOF2 3 means +ACOF3 or ASOF3
msgdataThe extra data to be added according to the Number of extra bytes. There is no check if the msgdata is set or not. So be sure to set it if the number of extra bytes > 1.
Returns
void Message::createOnEvent ( unsigned int  nodeNumber,
bool  longEvent,
unsigned int  eventNumber,
byte  numDataBytes,
byte *  msgdata 
)

Create a ON event message.

Parameters
nodeNumberNode number of the message
longEventIndication of Long or Short event. True means long event.
eventNumberEvent number
numDataBytesNumber of extra bytes in the message. It defines the type of On event should be created: 0 means +ACON or ASON 1 means +ACON1 or ASON1 2 means +ACON2 or ASON2 3 means +ACON3 or ASON3
msgdataThe extra data to be added according to the Number of extra bytes. There is no check if the msgdata is set or not. So be sure to set it if the number of extra bytes > 1.
Returns
byte Message::functionValue ( )

Get the function value for DCC messages

Returns
a 1 byte integer.
byte Message::getAccExtraData ( byte  idx)

Get the extra data byte on an ON or OFF event.

Returns
Return the extra byte. The index is between 1 and 3
byte Message::getAvailableEventsLeft ( )

Get the space left to store events

Returns
a 1 byte integer.
byte Message::getByte ( byte  pos)

Used to get the data fields directly

Parameters
posByte position.
byte Message::getCanId ( )

Get the Can id from the header.

Returns
message size.
byte Message::getCanMessageSize ( )

Get the message size. Extract it from the can frame.

Returns
message size.
byte Message::getConsist ( )

Get the consist value for DCC messages

Returns
a 1 byte integer.
unsigned int Message::getCV ( )

Get the decoder id for DCC messages

Returns
a 2 byte integer.
unsigned int Message::getCVMode ( )

Get the cv mode value for DCC messages

Returns
a 1 byte integer.
unsigned int Message::getCVValue ( )

Get the cv value for DCC messages

Returns
a 1 byte integer.
byte* Message::getDataBuffer ( )
inline

Get the 8 bytes CAN message buffer. The user can also get specific values using other methods.

Returns
Pointer to the CAN message.
unsigned int Message::getDecoder ( )

Get the decoder id for DCC messages

Returns
a 2 byte integer.
unsigned int Message::getDeviceNumber ( )

Get the device number

Returns
a 16 bit integer.
byte Message::getEngineFlag ( )

Get the engine flags for DCC messages

Returns
a 1 byte integer.
byte Message::getEventIndex ( )

Get the event index EN# field

Returns
a 1 byte integer.
unsigned int Message::getEventNumber ( )

Get the event number

Returns
a 16 bit integer.
byte Message::getEventVar ( )

Get the event variable EV field

Returns
a 1 byte integer.
byte Message::getEventVarIndex ( )

Get the event variable index EV# field

Returns
a 1 byte integer.
byte Message::getFunctionNumber ( )

Get the function number Fn for DCC messages

Returns
a 1 byte integer.
byte* Message::getHeaderBuffer ( )
inline

Get the 8 bytes CAN header buffer. The user can also get specific values using other methods.

Returns
Pointer to the CAN header.
byte Message::getMessageSize ( )

Get the CBUS message size. Extract it from the opc.

Returns
message size.
unsigned int Message::getNodeNumber ( )

Get the node number

Returns
a 16 bit integer.
byte Message::getNodeVariable ( )

Get the node variable NV field

Returns
a 1 byte integer.
byte Message::getNodeVariableIndex ( )

Get the node variable index NV# field

Returns
a 1 byte integer.
unsigned int Message::getNumBytes ( )
inline

Get the number of bytes parameter in the message.

Returns
The number of bytes
byte Message::getOpc ( )

first byte contains the opc and the number of bytes in the message the first 3 bits are the number of bytes the 5 last bits are the OPC

byte Message::getParaIndex ( )

Get the parameter index Para# field

Returns
a 1 byte integer.
byte Message::getParameter ( )

Get the parameter Para field

Returns
a 1 byte integer.
byte Message::getPriority ( )
inline

Get the message priority in the Can header.

Returns
The priority
bool Message::getRTR ( )
inline

Get the CAN RTR parameter. Set after reading the CAN header.

Returns
True if the RTR is set else returns False.
byte Message::getSession ( )

Get the loc session for DCC messages

Returns
a byte.
byte Message::getSpeedDir ( )

Get the speed direction for DCC messages

Returns
a 1 byte integer.
byte Message::getStatus ( )

Get the status field

Returns
a 1 byte integer.
byte Message::getStoredEvents ( )

Get the amount of stored events

Returns
a 1 byte integer.
message_type Message::getType ( )
inline

Get the message type.

Returns
The message type message_type
bool Message::isAccOff ( )

Check the if it is an OFF message. Major event in CBUS.

Returns
True if is and OFF event, false if not
bool Message::isAccOn ( )

Check the if it is an ON message. Major event in CBUS.

Returns
True if is and On event, false if not
bool Message::isLongEvent ( )

Check the if it is an OFF message. Major event in CBUS.

Returns
True if is and OFF event, false if not
bool Message::isShortEvent ( )

Check the if it is an ON message. Major event in CBUS.

Returns
True if is and On event, false if not
void Message::setCanId ( byte  val)
inline

Set the can id in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
canIdis the can ID
void Message::setCanMessageSize ( byte  val)
inline

Set the message size NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
Themessage size
void Message::setCV ( unsigned int  val)
inline

Set the DCC CV value in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the DCC CV value
void Message::setDataBuffer ( byte  val[CANDATA_SIZE])

Set the can buffer.

Parameters
valA 8 bytes array.
void Message::setDecoder ( unsigned int  val)
inline

Set the decoder value NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the decoder value
void Message::setDeviceNumber ( unsigned int  val)
inline

Set the device number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the device number
void Message::setEventNumber ( unsigned int  val)
inline

Set event number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the event number
void Message::setHeaderBuffer ( byte  val[HEADER_SIZE])

Set the header buffer.

Parameters
valA 8 bytes array.
void Message::setNodeNumber ( unsigned int  val)
inline

Set the node number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the node number
void Message::setNumBytes ( unsigned int  val)
inline

Set the number of bytes parameter in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the number of bytes
void Message::setOpc ( byte  val)
inline

Set the opc in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
opcis the opc
void Message::setPriority ( byte  val)
inline

Set the message priority in the CAN header NOT USED. At the moment the messages are being assembled outside and loaded by setHeaderBuffer.

Parameters
valis the priority
void Message::setSession ( byte  val)
inline

Set the session value in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the session value
void Message::setType ( message_type  val)
inline

Set the message type NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.

Parameters
valis the message type

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