|
mergCanBus
|
#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... | |
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.
| 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.
| canId | is the can id of the message. |
| opc | is the opc code. |
| nodeNumber | is the node number. |
| eventNumber | is the event number. |
| data | is the message data itself. |
| priority | is CAN priority. |
|
virtual |
Destructor
| byte Message::accExtraData | ( | ) |
Return how many bytes of extra data has the ON event.
| 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.
| nodeNumber | Node number of the message |
| longEvent | Indication of Long or Short event. True means long event. |
| eventNumber | Event number |
| numDataBytes | Number 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 |
| msgdata | The 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. |
| void Message::createOnEvent | ( | unsigned int | nodeNumber, |
| bool | longEvent, | ||
| unsigned int | eventNumber, | ||
| byte | numDataBytes, | ||
| byte * | msgdata | ||
| ) |
Create a ON event message.
| nodeNumber | Node number of the message |
| longEvent | Indication of Long or Short event. True means long event. |
| eventNumber | Event number |
| numDataBytes | Number 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 |
| msgdata | The 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. |
| byte Message::functionValue | ( | ) |
Get the function value for DCC messages
| byte Message::getAccExtraData | ( | byte | idx | ) |
Get the extra data byte on an ON or OFF event.
| byte Message::getAvailableEventsLeft | ( | ) |
Get the space left to store events
| byte Message::getByte | ( | byte | pos | ) |
Used to get the data fields directly
| pos | Byte position. |
| byte Message::getCanId | ( | ) |
Get the Can id from the header.
| byte Message::getCanMessageSize | ( | ) |
Get the message size. Extract it from the can frame.
| byte Message::getConsist | ( | ) |
Get the consist value for DCC messages
| unsigned int Message::getCV | ( | ) |
Get the decoder id for DCC messages
| unsigned int Message::getCVMode | ( | ) |
Get the cv mode value for DCC messages
| unsigned int Message::getCVValue | ( | ) |
Get the cv value for DCC messages
|
inline |
Get the 8 bytes CAN message buffer. The user can also get specific values using other methods.
| unsigned int Message::getDecoder | ( | ) |
Get the decoder id for DCC messages
| unsigned int Message::getDeviceNumber | ( | ) |
Get the device number
| byte Message::getEngineFlag | ( | ) |
Get the engine flags for DCC messages
| byte Message::getEventIndex | ( | ) |
Get the event index EN# field
| unsigned int Message::getEventNumber | ( | ) |
Get the event number
| byte Message::getEventVar | ( | ) |
Get the event variable EV field
| byte Message::getEventVarIndex | ( | ) |
Get the event variable index EV# field
| byte Message::getFunctionNumber | ( | ) |
Get the function number Fn for DCC messages
|
inline |
Get the 8 bytes CAN header buffer. The user can also get specific values using other methods.
| byte Message::getMessageSize | ( | ) |
Get the CBUS message size. Extract it from the opc.
| unsigned int Message::getNodeNumber | ( | ) |
Get the node number
| byte Message::getNodeVariable | ( | ) |
Get the node variable NV field
| byte Message::getNodeVariableIndex | ( | ) |
Get the node variable index NV# field
|
inline |
Get the number of bytes parameter in the message.
| 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
| byte Message::getParameter | ( | ) |
Get the parameter Para field
|
inline |
Get the message priority in the Can header.
|
inline |
Get the CAN RTR parameter. Set after reading the CAN header.
| byte Message::getSession | ( | ) |
Get the loc session for DCC messages
| byte Message::getSpeedDir | ( | ) |
Get the speed direction for DCC messages
| byte Message::getStatus | ( | ) |
Get the status field
| byte Message::getStoredEvents | ( | ) |
Get the amount of stored events
|
inline |
Get the message type.
| bool Message::isAccOff | ( | ) |
Check the if it is an OFF message. Major event in CBUS.
| bool Message::isAccOn | ( | ) |
Check the if it is an ON message. Major event in CBUS.
| bool Message::isLongEvent | ( | ) |
Check the if it is an OFF message. Major event in CBUS.
| bool Message::isShortEvent | ( | ) |
Check the if it is an ON message. Major event in CBUS.
|
inline |
Set the can id in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| canId | is the can ID |
|
inline |
Set the message size NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| The | message size |
|
inline |
Set the DCC CV value in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| val | is the DCC CV value |
| void Message::setDataBuffer | ( | byte | val[CANDATA_SIZE] | ) |
Set the can buffer.
| val | A 8 bytes array. |
|
inline |
Set the decoder value NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| val | is the decoder value |
|
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.
| val | is the device number |
|
inline |
Set event number to be used on message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| val | is the event number |
| void Message::setHeaderBuffer | ( | byte | val[HEADER_SIZE] | ) |
Set the header buffer.
| val | A 8 bytes array. |
|
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.
| val | is the node number |
|
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.
| val | is the number of bytes |
|
inline |
Set the opc in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| opc | is the opc |
|
inline |
Set the message priority in the CAN header NOT USED. At the moment the messages are being assembled outside and loaded by setHeaderBuffer.
| val | is the priority |
|
inline |
Set the session value in the message NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| val | is the session value |
|
inline |
Set the message type NOT USED. At the moment the messages are being assembled outside and loaded by setDataBuffer.
| val | is the message type |