Implement connectionless management connection in the client library
[bcusdk.git] / eibd / backend / bcu1serial.h
blob4f86c01b7f089af7385eab83f4071f5e5e4007e4
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 BCU1SERIAL_H
21 #define BCU1SERIAL_H
23 #include <termios.h>
24 #include "lowlatency.h"
25 #include "lowlevel.h"
27 /** PEI16 / BCU1 user mode driver */
28 class BCU1SerialLowLevelDriver:public LowLevelDriverInterface, private Thread
30 /** file descriptor */
31 int fd;
32 /** old termios settings */
33 struct termios told;
34 /** old serial port settings */
35 low_latency_save sold;
36 /** debug output */
37 Trace *t;
38 /** semaphore for inqueue */
39 pth_sem_t in_signal;
40 /** semaphore for outqueue */
41 pth_sem_t out_signal;
42 /** input queue */
43 Queue < CArray > inqueue;
44 /** output queue */
45 Queue < CArray * >outqueue;
46 /** semaphore to wait for outqueue */
47 pth_event_t getwait;
48 /** semaphore to signal empty sendqueue */
49 pth_sem_t send_empty;
51 /** gets the serial port line status */
52 int getstat ();
53 /** sets the serial port line status */
54 void setstat (int v);
55 /** runs a start sync of a byte exchange */
56 bool startsync ();
57 /** finishes the byte exchange */
58 bool endsync ();
59 /** exchange two bytes*/
60 bool exchange (uchar c, uchar & result, pth_event_t stop);
61 void Run (pth_sem_t * stop);
62 public:
63 BCU1SerialLowLevelDriver (const char *device, Trace * tr);
64 ~BCU1SerialLowLevelDriver ();
65 bool init ();
67 void Send_Packet (CArray l);
68 bool Send_Queue_Empty ();
69 pth_sem_t *Send_Queue_Empty_Cond ();
70 CArray *Get_Packet (pth_event_t stop);
71 void SendReset ();
72 bool Connection_Lost ();
73 EMIVer getEMIVer ();
77 #endif