I've refactored the use of the serial port, to store the current serial port in a global variable in a module. This is set to the most recent port to receive data, and so we should always be replying to the port that was used to initiate a command. If SECONDARY_SERIAL_PORT is not defined, this should result in no change - if it is, we should be able to communicate on either port.
33 lines
No EOL
755 B
C
33 lines
No EOL
755 B
C
#ifndef MAIN_H
|
|
#include "config.h"
|
|
#include <Arduino.h>
|
|
#include <ComPort.h>
|
|
#ifdef DEBUG_ON
|
|
#define D(x) comPort->println(x)
|
|
#else
|
|
#define D(x)
|
|
#endif
|
|
|
|
#define END_COMMAND \
|
|
{ \
|
|
"", NULL \
|
|
}
|
|
#define CHECK_END_COMMAND(C) check_end_command(C)
|
|
|
|
struct Command
|
|
{
|
|
const char * command;
|
|
void (*run)(String);
|
|
};
|
|
|
|
inline bool check_end_command(Command c) { return strlen(c.command) > 0; }
|
|
inline bool check_end_command(Command * c) {return strlen(c->command) > 0; }
|
|
|
|
const Command end_command = END_COMMAND;
|
|
uint8_t parse_arguments(char ** arguments, String, uint8_t);
|
|
extern void register_module(const Command commands[], void (*loop_fn)(void));
|
|
|
|
void get_version(String);
|
|
void get_modules(String);
|
|
#define MAIN_H
|
|
#endif |