|
| | MergCBUS (byte num_node_vars, byte num_events, byte num_events_vars, byte max_device_numbers) |
| | Constructor Create the internal buffers. Initiate the memory management and transport object. More...
|
| |
|
virtual | ~MergCBUS () |
| | Destructor Not used.
|
| |
| void | skipMessage (message_type msg) |
| | Set to skip processing certain message. More...
|
| |
| void | processMessage (message_type msg) |
| | Set to process certain message. More...
|
| |
| unsigned int | run () |
| | Method that deals with the majority of messages and behavior. Auto enummeration, query requests and config messages. If a custom function is set it calls it for every non automatic message. More...
|
| |
|
bool | hasMessageToHandle () |
| |
| MergNodeIdentification * | getNodeId () |
| | Get a reference to node identification. More...
|
| |
| bool | initCanBus (unsigned int port, unsigned int rate, unsigned int retries, unsigned int retryIntervalMilliseconds) |
| | Set the port number for SPI communication. Set the CBUS rate and initiate the transport layer. More...
|
| |
|
void | setUserHandlerFunction (userHandlerType f) |
| | Set the user function to handle other messages.
|
| |
|
void | setDebug (bool debug) |
| | Put in debug mode.
|
| |
| void | sendERRMessage (byte code) |
| | Send the error message with the code. More...
|
| |
|
bool | hasThisEvent () |
| | Check it the received event is a learned event. For the messages ACONs,ACOFs,ASONs,ASOFs. Should be called after reading the can bus.
|
| |
| bool | readCanBus () |
| | Read the can bus from the circular buffer and load the data in the message object. More...
|
| |
| bool | readCanBus (byte buf_num) |
| | Read the can bus and load the data in the message object. More...
|
| |
| bool | readCanBus (byte *msg, byte *header, byte *length, byte buf_num) |
| | Read the can bus and return the buffer. More...
|
| |
|
void | printSentMessage () |
| | Print the message to be sent to serial. Used for debug.
|
| |
|
void | printReceivedMessage () |
| | Print the received message buffer to serial. Used for debug.
|
| |
|
void | setSlimMode () |
| | Set the node to slim mode.
|
| |
|
void | setFlimMode () |
| | Set the node to flim mode.
|
| |
|
byte | getNodeMode () |
| | Get the node mode.
|
| |
| void | setUpNewMemory () |
| | Reset EEPROM. More...
|
| |
|
void | dumpMemory () |
| | Print all EEPROM values.
|
| |
| void | setLeds (byte green, byte yellow) |
| | Set the CBUS modules stardard leds. More...
|
| |
|
void | setPushButton (byte pb) |
| | Set the CBUS modules stardard push button.
|
| |
| void | setStdNN (unsigned int val) |
| | Set the standard node number for slim mode. The user of this library has to create its own way of letting a customer set a node number in SLIM mode. If a standard value is not set and a push button is set then the library will use the value 0 if it is a consumer and 4444 if it is a producer. More...
|
| |
| unsigned int | getStdNN () |
| | Get the standard node number. More...
|
| |
|
void | saveNodeFlags () |
| |
|
void | sendMessage (Message *msg) |
| |
| bool | isAccOn () |
| |
| bool | isAccOff () |
| |
|
bool | eventMatch () |
| |
| unsigned int | getEventIndex (Message *msg) |
| | Get the Index in memory of an event. More...
|
| |
| byte | getNodeVar (byte varIndex) |
| | Get node variable by index. More...
|
| |
| byte | getEventVar (Message *msg, byte varIndex) |
| | Get the variable of a learned event. More...
|
| |
| void | setDeviceNumber (unsigned int val, byte port) |
| | Set the device number for a specific port. More...
|
| |
| unsigned int | getDeviceNumber (byte port) |
| | Get the device number for a specific port. More...
|
| |
|
byte | getDeviceNumberIndex () |
| |
|
state | getNodeState () |
| |
|
byte | sendOnEvent (bool longEvent, unsigned int event) |
| |
|
byte | sendOffEvent (bool longEvent, unsigned int event) |
| |
|
byte | sendOnEvent1 (bool longEvent, unsigned int event, byte var1) |
| |
|
byte | sendOffEvent1 (bool longEvent, unsigned int event, byte var1) |
| |
|
byte | sendOnEvent2 (bool longEvent, unsigned int event, byte var1, byte var2) |
| |
|
byte | sendOffEvent2 (bool longEvent, unsigned int event, byte var1, byte var2) |
| |
|
byte | sendOnEvent3 (bool longEvent, unsigned int event, byte var1, byte var2, byte var3) |
| |
|
byte | sendOffEvent3 (bool longEvent, unsigned int event, byte var1, byte var2, byte var3) |
| |
|
void | setTimerInterval (long value) |
| |
|
long | getTimerInterval () |
| |
| void | cbusRead () |
| | Read the can bus message and put in circular buffer. Used by the timer the buffer is 1 byte for the message size.1 byte for RTR, 4 bytes for header. 8 bytes to max message. More...
|
| |
A general class that support the MergCBUS protocol. The class is used to all operations regarding the protocol, but is flexible enough to allow you to use general can messages. It uses a modified version of mcp_can.h, that included the CAN header manipulation and RTR messages. When using the CBUS the user has to set the node information: -The manufacturer ID as a HEX numeric (If the manufacturer has a NMRA number this can be used) -Minor code version as an alphabetic character (ASCII) -Manufacturer’s module identifier as a HEX numeric -Number of supported events as a HEX numeric -Number of Event Variables per event as a HEX numeric -Number of supported Node Variables as a HEX numeric -Major version as a HEX numeric. (can be 0 if no major version allocated) -Node Flags You has to start the CAN by calling initCanBus(...); If your board follows the Merg boards with on push button and red and yellow leds, you can specify then with setLeds() and setPushButton() If you want the library to take care of a lot of stuff, you need to define your user function that implements the node logic and tell the lib about it calling setUserHandlerFunction() and on the arduino loop() call the run() method. See the examples. If you want to take care of all messages by yourself just read the messages using readCanBus() or readCanBus(header[],data[]) and use the getMessage() to get a wrapper over the can message.