Modmata  v0
An arduino communications server using Modbus
Public Member Functions | Private Attributes | List of all members
modmata::ModmataClass Class Reference

Base class for a host computer to control this (LattePanda's Arduino Leonardo) device. More...

#include <Modmata.h>

Collaboration diagram for modmata::ModmataClass:
Collaboration graph
[legend]

Public Member Functions

void begin (int baud)
 Begin listening for a Modmata connection over serial/USB. More...
 
void attach (uint8_t command, struct registers(*fn)(uint8_t argc, uint8_t *argv))
 Assign a function to a command number. Standard commands have default functions, but those can be overwritten here, or more commands can be added. More...
 
void processInput ()
 Read the command and args sent and execute the corresponding callback function, store the results of which in holding functions to be communicated with the host.
 
bool available ()
 

Private Attributes

struct registers(* callbackFunctions [100])(uint8_t argc, uint8_t *argv)
 An array of references to callback functions indexed by their function code number. Use 'Modmata.attach( function_code, &function )' to add your own callback functions.
 
ModbusSerial mb
 Object representing an interactive Modbus connection over Serial.
 

Detailed Description

Base class for a host computer to control this (LattePanda's Arduino Leonardo) device.

Definition at line 27 of file Modmata.h.

Member Function Documentation

◆ attach()

void ModmataClass::attach ( uint8_t  command,
struct registers(*)(uint8_t argc, uint8_t *argv)  fn 
)

Assign a function to a command number. Standard commands have default functions, but those can be overwritten here, or more commands can be added.

Parameters
commandThe modbus command being assigned a function
fnA pointer to the function to be called when the command is recieved

Definition at line 69 of file Modmata.cpp.

References callbackFunctions.

◆ available()

bool ModmataClass::available ( )

Update modbus registers and check if a command has been received

Remarks
Will return false unless there is a Command function code besides IDLE in Hreg 0 and there was data received since the last time mb.task() was called
Returns
True or false

Definition at line 121 of file Modmata.cpp.

References mb.

◆ begin()

void ModmataClass::begin ( int  baud)

Begin listening for a Modmata connection over serial/USB.

Remarks
This is configured to be used between a host computer and Arduino Leonardo using a USB connector (hardwired in the case of the LattePanda Delta 3.) The Leonardo is different from most other Arduinos in the usage of the serial connection, so if you modify this code, please keep that in mind.
Parameters
baudSet the baud rate of the listening serial connection

Definition at line 31 of file Modmata.cpp.

References callbackFunctions, and mb.


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