1 %{
2 #include "ctb-0.16/serportx.h"
3 %}
4 
5 %include iobase.i
6 
7 namespace ctb {
8 
9 enum Parity
10 {
11     ParityNone,
12     ParityOdd,
13     ParityEven,
14     ParityMark,
15     ParitySpace
16 };
17 
18 enum SerialLineState
19 {
20     LinestateDcd = 0x040,
21     LinestateCts = 0x020,
22     LinestateDsr = 0x100,
23     LinestateDtr = 0x002,
24     LinestateRing = 0x080,
25     LinestateRts = 0x004,
26     LinestateNull = 0x000
27 };
28 
29 struct SerialPort_DCS
30 {
31     int baud;
32     Parity parity;
33     unsigned char wordlen;
34     unsigned char stopbits;
35     bool rtscts;
36     bool xonxoff;
37     char buf[16];
38     SerialPort_DCS();
39     ~SerialPort_DCS();
40     char* GetSettings();
41 };
42 
43 struct SerialPort_EINFO
44 {
45     int brk;
46     int frame;
47     int overrun;
48     int parity;
49     SerialPort_EINFO();
50     ~SerialPort_EINFO();
51 };
52 
53 enum {
54     CTB_SER_GETEINFO = CTB_SERIAL,
55     CTB_SER_GETBRK,
56     CTB_SER_GETFRM,
57     CTB_SER_GETOVR,
58     CTB_SER_GETPAR,
59     CTB_SER_GETINQUE,
60     CTB_SER_SETPAR,
61 };
62 
63 class SerialPort_x : public IOBase
64 {
65 protected:
66     SerialPort_DCS m_dcs;
67     char m_devname[SERIALPORT_NAME_LEN];
68 public:
69     SerialPort_x();
70     virtual ~SerialPort_x();
71     const char* ClassName();
72     virtual int ChangeLineState(SerialLineState flags) = 0;
73     virtual int ClrLineState(SerialLineState flags) = 0;
74     virtual int GetLineState() = 0;
75     virtual char* GetSettingsAsString();
76     virtual int Ioctl(int cmd,void* args);
77     virtual int SendBreak(int duration) = 0;
78     virtual int SetBaudrate(int baudrate) = 0;
79     virtual int SetLineState(SerialLineState flags) = 0;
80     virtual int SetParityBit( bool parity ) = 0;
81     static bool IsStandardRate( long rate );
82 };
83 
84 };
85