Modmata  v0
An arduino communications server using Modbus
Modmata.h
Go to the documentation of this file.
1 /*
2 Modmata
3 Copyright © 2023 char* teamName <shutche@siue.edu>
4 Licensed under LGPL-2.1
5 */
6 
7 /**
8  * @file Modmata.h
9  * @author Sam Hutcherson, Chase Wallendorff, Iris Astrid
10  * @brief Header file for 'Modmata.cpp'
11  * @date 2023-04-04
12  */
13 
14 
15 #include "Functions.h"
16 #include "ModbusSerial.h"
17 
18 #ifndef MODMATA_H
19 #define MODMATA_H
20 
21 #define MAX_REG_COUNT 100
22 
23 /** @brief Modmata namespace */
24 namespace modmata {
25 
26  /** @brief Base class for a host computer to control this (LattePanda's Arduino Leonardo) device */
27  class ModmataClass {
28  public:
29  void begin(int baud);
30  void attach(uint8_t command, struct registers (*fn)(uint8_t argc, uint8_t *argv));
31  void processInput();
32  bool available();
33 
34  private:
35 
36  /** @brief An array of references to callback functions indexed by their function code number.
37  * Use 'Modmata.attach( function_code, &function )' to add your own callback functions */
38  struct registers (*callbackFunctions[100])(uint8_t argc, uint8_t *argv);
39 
40  /** @brief Object representing an interactive Modbus connection over Serial */
41  ModbusSerial mb;
42 
43  };
44 }
45 
46 extern modmata::ModmataClass Modmata;
47 #endif
Header file for 'Functions.cpp'.
A data structure to describe function arguments and return values.
Definition: Functions.h:59
Base class for a host computer to control this (LattePanda's Arduino Leonardo) device.
Definition: Modmata.h:27
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 ove...
Definition: Modmata.cpp:69
struct registers(* callbackFunctions[100])(uint8_t argc, uint8_t *argv)
An array of references to callback functions indexed by their function code number....
Definition: Modmata.h:38
ModbusSerial mb
Object representing an interactive Modbus connection over Serial.
Definition: Modmata.h:41
void processInput()
Read the command and args sent and execute the corresponding callback function, store the results of ...
Definition: Modmata.cpp:77
void begin(int baud)
Begin listening for a Modmata connection over serial/USB.
Definition: Modmata.cpp:31
Modmata namespace.
Definition: Modmata.h:24