]> git.tdb.fi Git - r2c2.git/blob - source/serial/serial.h
Add a program for serial port control and associated Arduino firmware
[r2c2.git] / source / serial / serial.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef SERIAL_H_
9 #define SERIAL_H_
10
11 #include <msp/core/application.h>
12 #include <msp/io/serial.h>
13 #include "network/client.h"
14
15 class Serial: public Msp::Application
16 {
17 private:
18         Msp::IO::EventDispatcher event_disp;
19         Marklin::Catalogue catalogue;
20         Marklin::Client client;
21         Msp::IO::Serial serial_port;
22         Marklin::NetTrain *train;
23         char rx_buf[3];
24         unsigned rx_fill;
25
26         static Msp::Application::RegApp<Serial> reg;
27
28 public:
29         Serial(int, char **);
30
31 private:
32         virtual void tick();
33         void train_added(Marklin::NetTrain &);
34         void error(const std::string &);
35         void set_train(Marklin::NetTrain *);
36         void next_train();
37         void prev_train();
38         void data_available();
39 };
40
41 #endif