]> git.tdb.fi Git - r2c2.git/blobdiff - source/serial/serial.h
Add a program for serial port control and associated Arduino firmware
[r2c2.git] / source / serial / serial.h
diff --git a/source/serial/serial.h b/source/serial/serial.h
new file mode 100644 (file)
index 0000000..b5427e4
--- /dev/null
@@ -0,0 +1,41 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2010  Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#ifndef SERIAL_H_
+#define SERIAL_H_
+
+#include <msp/core/application.h>
+#include <msp/io/serial.h>
+#include "network/client.h"
+
+class Serial: public Msp::Application
+{
+private:
+       Msp::IO::EventDispatcher event_disp;
+       Marklin::Catalogue catalogue;
+       Marklin::Client client;
+       Msp::IO::Serial serial_port;
+       Marklin::NetTrain *train;
+       char rx_buf[3];
+       unsigned rx_fill;
+
+       static Msp::Application::RegApp<Serial> reg;
+
+public:
+       Serial(int, char **);
+
+private:
+       virtual void tick();
+       void train_added(Marklin::NetTrain &);
+       void error(const std::string &);
+       void set_train(Marklin::NetTrain *);
+       void next_train();
+       void prev_train();
+       void data_available();
+};
+
+#endif