Reset Workaround for Disch TPUART interface
[bcusdk.git] / eibd / backend / tpuartserial.h
blob58282e1c5c824383a62d711fa48512b8205b741e
1 /*
2 EIBD eib bus access and management daemon
3 Copyright (C) 2005-2010 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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;
57 bool ackallgroup;
58 bool ackallindividual;
59 bool dischreset;
61 /** process a recevied frame */
62 void RecvLPDU (const uchar * data, int len);
63 void Run (pth_sem_t * stop);
64 public:
65 TPUARTSerialLayer2Driver (const char *dev, eibaddr_t addr, int flags,
66 Trace * tr);
67 ~TPUARTSerialLayer2Driver ();
68 bool init ();
70 void Send_L_Data (LPDU * l);
71 LPDU *Get_L_Data (pth_event_t stop);
73 bool addAddress (eibaddr_t addr);
74 bool addGroupAddress (eibaddr_t addr);
75 bool removeAddress (eibaddr_t addr);
76 bool removeGroupAddress (eibaddr_t addr);
78 bool enterBusmonitor ();
79 bool leaveBusmonitor ();
80 bool openVBusmonitor ();
81 bool closeVBusmonitor ();
83 bool Open ();
84 bool Close ();
85 eibaddr_t getDefaultAddr ();
86 bool Connection_Lost ();
87 bool Send_Queue_Empty ();
90 #endif