summaryrefslogtreecommitdiffstats
path: root/serial_rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'serial_rx.c')
-rw-r--r--serial_rx.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/serial_rx.c b/serial_rx.c
index 6165a01..340420b 100644
--- a/serial_rx.c
+++ b/serial_rx.c
@@ -9,14 +9,15 @@
#include "sia.h"
-extern int new_block (int fd, SIA_Block *b, int log, const char *email);
+extern int new_block (int fd, SIA_Block *b, int log, const char *email, const char *state_file, const char *mqtt_host);
+extern void dump_state (const char *);
//extern void periodic_task(void);
static int usage (const char *name)
{
fprintf (stderr, "Usage:\n");
- fprintf (stderr, "%s [ -l ] [ -b baud ] -p serial_device [ -m email address ]\n\n", name);
+ fprintf (stderr, "%s [ -l ] [ -b baud ] -p serial_device [ -e email address ] [ -s state_file ] [ -m mqtt_host ]\n\n", name);
fprintf (stderr, "baud defaults to 9600\n");
return 1;
@@ -32,13 +33,15 @@ int main (int argc, char *argv[])
SIA_Block b;
ssize_t red;
int log = 0;
- const char *email = NULL;
unsigned char buf[SIA_MAX_BLOCK_LENGTH];
unsigned ptr = 0;
+ const char *email = NULL;
+ const char *state_file = NULL;
+ const char *mqtt_host = NULL;
- while ((opt = getopt (argc, argv, "p:b:lm:")) != -1) {
+ while ((opt = getopt (argc, argv, "p:b:le:s:m:")) != -1) {
switch (opt) {
case 'p':
port = optarg;
@@ -48,10 +51,18 @@ int main (int argc, char *argv[])
baud = atoi (optarg);
break;
- case 'm':
+ case 'e':
email = optarg;
break;
+ case 's':
+ state_file = optarg;
+ break;
+
+ case 'm':
+ mqtt_host = optarg;
+ break;
+
case 'l':
log++;
break;
@@ -73,6 +84,9 @@ int main (int argc, char *argv[])
set_blocking (fd);
+ if (state_file)
+ dump_state (state_file);
+
for (;;) {
red = read (fd, &buf[ptr], 1);
@@ -95,7 +109,7 @@ int main (int argc, char *argv[])
break;
default: /*Valid block */
- new_block (fd, &b, log, email);
+ new_block (fd, &b, log, email, state_file, mqtt_host);
ptr = 0;
break;
}