Implement connectionless management client
[bcusdk.git] / eibd / backend / tpuartserial.h
blob1c1528e0f40e06832bdd2b0f2e79dd4c4dff9ae6
1 /*
2 EIBD eib bus access and management daemon
3 Copyright (C) 2005-2009 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef TPUART_SERIAL_H
21 #define TPUART_SERIAL_H
22 #include <termios.h>
23 #include "lowlatency.h"
24 #include "layer2.h"
26 /** TPUART user mode driver */
27 class TPUARTSerialLayer2Driver:public Layer2Interface, private Thread
29 /** old serial config */
30 low_latency_save sold;
31 /** old termios state */
32 struct termios old;
33 /** file descriptor */
34 int fd;
35 /** debug output */
36 Trace *t;
37 /** default EIB address */
38 eibaddr_t addr;
39 /** state */
40 int mode;
41 /** vbusmonitor mode */
42 int vmode;
43 /** semaphore for inqueue */
44 pth_sem_t in_signal;
45 /** semaphore for outqueue */
46 pth_sem_t out_signal;
47 /** input queue */
48 Queue < LPDU * >inqueue;
49 /** output queue */
50 Queue < LPDU * >outqueue;
51 /** event to wait for outqueue */
52 pth_event_t getwait;
53 /** my individual addresses */
54 Array < eibaddr_t > indaddr;
55 /** my group addresses */
56 Array < eibaddr_t > groupaddr;
58 /** process a recevied frame */
59 void RecvLPDU (const uchar * data, int len);
60 void Run (pth_sem_t * stop);
61 public:
62 TPUARTSerialLayer2Driver (const char *dev, eibaddr_t addr, Trace * tr);
63 ~TPUARTSerialLayer2Driver ();
64 bool init ();
66 void Send_L_Data (LPDU * l);
67 LPDU *Get_L_Data (pth_event_t stop);
69 bool addAddress (eibaddr_t addr);
70 bool addGroupAddress (eibaddr_t addr);
71 bool removeAddress (eibaddr_t addr);
72 bool removeGroupAddress (eibaddr_t addr);
74 bool enterBusmonitor ();
75 bool leaveBusmonitor ();
76 bool openVBusmonitor ();
77 bool closeVBusmonitor ();
79 bool Open ();
80 bool Close ();
81 eibaddr_t getDefaultAddr ();
82 bool Connection_Lost ();
83 bool Send_Queue_Empty ();
86 #endif