Mercurial > ~darius > hgwebdir.cgi > EG-ZigBee
annotate __init__.py @ 2:1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
- Fix logging of checksum errors.
author | darius@midget.dons.net.au |
---|---|
date | Mon, 29 Oct 2007 10:44:26 +1030 |
parents | c978dbb7e4b8 |
children | afd270964f5b |
rev | line source |
---|---|
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
1 import eg |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
2 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
3 class PluginInfo(eg.PluginInfo): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
4 name = "ZigBee" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
5 author = "Darius" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
6 version = "1.0.0" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
7 description = "Listen for data from a Max Stream ZigBee module" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
8 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
9 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
10 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
11 class Text: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
12 port = "Port:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
13 baudrate = "Baudrate:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
14 bytesize = "Number of bits:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
15 parity = "Parity:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
16 parities = ['No parity', 'Odd', 'Even'] #, 'Mark', 'Space'] |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
17 stopbits = "Stopbits:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
18 flowcontrol = "Flow control:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
19 handshakes = ['None', 'Xon / Xoff', 'Hardware'] |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
20 generateEvents = "Generate events on incoming data" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
21 eventPrefix = "Event prefix:" |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
22 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
23 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
24 import wx |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
25 import threading |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
26 import win32event |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
27 import win32file |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
28 import struct |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
29 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
30 class Serial(eg.RawReceiverPlugin): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
31 canMultiLoad = True |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
32 text = Text |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
33 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
34 def __init__(self): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
35 eg.RawReceiverPlugin.__init__(self) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
36 self.serial = None |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
37 self.buffer = [] |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
38 self.state = 'init' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
39 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
40 def __start__( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
41 self, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
42 port, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
43 baudrate, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
44 bytesize=8, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
45 parity=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
46 stopbits=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
47 handshake=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
48 generateEvents=False, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
49 prefix="Serial", |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
50 ): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
51 xonxoff = 0 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
52 rtscts = 0 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
53 if handshake == 1: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
54 xonxoff = 1 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
55 elif handshake == 2: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
56 rtscts = 1 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
57 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
58 try: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
59 self.serial = eg.SerialPort( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
60 port, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
61 baudrate=baudrate, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
62 bytesize=(5, 6, 7, 8)[bytesize], |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
63 stopbits=(1, 2)[stopbits], |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
64 parity=('N', 'O', 'E')[parity], |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
65 xonxoff=xonxoff, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
66 rtscts=rtscts, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
67 ) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
68 except: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
69 self.serial = None |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
70 raise eg.Exception("Can't open COM port.") |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
71 self.serial.timeout = 1.0 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
72 self.serial.setRTS() |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
73 self.info.eventPrefix = prefix |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
74 self.stopEvent = win32event.CreateEvent(None, 1, 0, None) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
75 self.receiveThread = threading.Thread(target=self.ReceiveThread) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
76 self.receiveThread.start() |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
77 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
78 def __stop__(self): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
79 if self.serial is not None: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
80 if self.receiveThread: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
81 win32event.SetEvent(self.stopEvent) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
82 self.receiveThread.join(1.0) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
83 self.serial.close() |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
84 self.serial = None |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
85 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
86 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
87 def HandleChar(self, ch): |
2
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
88 chint = struct.unpack('B', ch)[0] |
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
89 if (self.state == 'init'): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
90 if (ch != '\x7e'): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
91 return |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
92 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
93 self.state = 'sizemsb' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
94 return |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
95 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
96 elif (self.state == 'sizemsb'): |
2
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
97 self.bufszmsb = chint |
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
98 self.state = 'sizelsb' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
99 return |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
100 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
101 elif (self.state == 'sizelsb'): |
2
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
102 self.bufszlsb = chint |
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
103 self.dataleft = self.bufszmsb << 8 | self.bufszlsb |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
104 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
105 self.state = 'data' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
106 return |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
107 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
108 elif (self.state == 'data'): |
2
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
109 self.buffer.append(chint) |
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
110 self.dataleft = self.dataleft - 1 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
111 if (self.dataleft == 0): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
112 self.state = 'cksum' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
113 return |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
114 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
115 elif (self.state == 'cksum'): |
2
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
116 pktsum = reduce(lambda x, y: x + y, self.buffer) & 0xff |
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
117 rxcksum = chint |
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
118 if (pktsum + rxcksum != 0xff): |
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
119 self.PrintError("Bad checksum, got 0x%02x, expected 0x%02x" % |
2
1e65aca0f39c
- Refactor use of struct.unpack() for greater clarity.
darius@midget.dons.net.au
parents:
0
diff
changeset
|
120 rxcksum, 0xff - pktsum) |
0
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
121 else: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
122 self.PrintError("Triggered event: " + str(self.buffer)) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
123 self.TriggerEvent(str(self.buffer)) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
124 self.buffer = [] |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
125 self.state = 'init' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
126 return |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
127 else: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
128 self.PrintError("Internal error: bad state: " + str(self.state)) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
129 self.state = 'init' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
130 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
131 def ReceiveThread(self): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
132 from win32event import ( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
133 ResetEvent, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
134 MsgWaitForMultipleObjects, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
135 QS_ALLINPUT, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
136 WAIT_OBJECT_0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
137 WAIT_TIMEOUT, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
138 ) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
139 from win32file import ReadFile, AllocateReadBuffer, GetOverlappedResult |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
140 from win32api import GetLastError |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
141 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
142 continueLoop = True |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
143 overlapped = self.serial._overlappedRead |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
144 hComPort = self.serial.hComPort |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
145 hEvent = overlapped.hEvent |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
146 stopEvent = self.stopEvent |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
147 n = 1 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
148 waitingOnRead = False |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
149 buf = AllocateReadBuffer(n) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
150 while continueLoop: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
151 if not waitingOnRead: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
152 ResetEvent(hEvent) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
153 hr, _ = ReadFile(hComPort, buf, overlapped) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
154 if hr == 997: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
155 waitingOnRead = True |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
156 elif hr == 0: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
157 pass |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
158 #n = GetOverlappedResult(hComPort, overlapped, 1) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
159 #self.HandleChar(str(buf)) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
160 else: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
161 self.PrintError("error") |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
162 raise |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
163 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
164 rc = MsgWaitForMultipleObjects( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
165 (hEvent, stopEvent), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
166 0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
167 1000, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
168 QS_ALLINPUT |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
169 ) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
170 if rc == WAIT_OBJECT_0: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
171 n = GetOverlappedResult(hComPort, overlapped, 1) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
172 if n: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
173 self.HandleChar(str(buf)) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
174 #else: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
175 # print "WAIT_OBJECT_0", n, str(buf[:n]) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
176 waitingOnRead = False |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
177 elif rc == WAIT_OBJECT_0+1: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
178 continueLoop = False |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
179 elif rc == WAIT_TIMEOUT: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
180 pass |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
181 else: |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
182 self.PrintError("unknown message") |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
183 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
184 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
185 def Configure( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
186 self, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
187 port=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
188 baudrate=9600, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
189 bytesize=8, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
190 parity=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
191 stopbits=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
192 handshake=0, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
193 generateEvents=False, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
194 prefix="Serial", |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
195 ): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
196 text = self.text |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
197 dialog = eg.ConfigurationDialog(self) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
198 portCtrl = eg.SerialPortChoice(dialog, value=port) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
199 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
200 baudrateCtrl = wx.ComboBox( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
201 dialog, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
202 value=str(baudrate), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
203 choices=[ |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
204 '110', '300', '600', '1200', '2400', '4800', '9600', |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
205 '14400', '19200', '38400', '57600', '115200', |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
206 '128000', '256000' |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
207 ], |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
208 style=wx.CB_DROPDOWN, |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
209 validator=eg.DigitOnlyValidator() |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
210 ) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
211 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
212 bytesizeCtrl = wx.Choice(dialog, choices=['5', '6', '7', '8']) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
213 bytesizeCtrl.SetSelection(8 - 5) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
214 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
215 parityCtrl = wx.Choice(dialog, choices=text.parities) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
216 parityCtrl.SetSelection(parity) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
217 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
218 stopbitsCtrl = wx.Choice(dialog, choices=['1', '2']) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
219 stopbitsCtrl.SetSelection(stopbits) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
220 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
221 handshakeCtrl = wx.Choice(dialog, choices=text.handshakes) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
222 handshakeCtrl.SetSelection(handshake) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
223 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
224 generateEventsCtrl = wx.CheckBox(dialog, label=text.generateEvents) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
225 generateEventsCtrl.SetValue(generateEvents) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
226 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
227 prefixCtrl = wx.TextCtrl(dialog) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
228 prefixCtrl.SetValue(prefix) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
229 prefixCtrl.Enable(generateEvents) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
230 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
231 def OnCheckBox(event): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
232 flag = generateEventsCtrl.GetValue() |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
233 prefixCtrl.Enable(flag) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
234 generateEventsCtrl.Bind(wx.EVT_CHECKBOX, OnCheckBox) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
235 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
236 flags = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
237 mySizer = wx.GridBagSizer(5, 5) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
238 Add = mySizer.Add |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
239 Add(wx.StaticText(dialog, -1, text.port), (0, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
240 Add(portCtrl, (0, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
241 Add(wx.StaticText(dialog, -1, text.baudrate), (1, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
242 Add(baudrateCtrl, (1, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
243 Add(wx.StaticText(dialog, -1, text.bytesize), (2, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
244 Add(bytesizeCtrl, (2, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
245 Add(wx.StaticText(dialog, -1, text.parity), (3, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
246 Add(parityCtrl, (3, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
247 Add(wx.StaticText(dialog, -1, text.stopbits), (4, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
248 Add(stopbitsCtrl, (4, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
249 Add(wx.StaticText(dialog, -1, text.flowcontrol), (5, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
250 Add(handshakeCtrl, (5, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
251 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
252 Add((5, 5), (6, 0), (1, 2), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
253 Add(generateEventsCtrl, (7, 0), (1, 2), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
254 Add(wx.StaticText(dialog, -1, text.eventPrefix), (9, 0), flag=flags) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
255 Add(prefixCtrl, (9, 1), flag=wx.EXPAND) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
256 dialog.sizer.Add(mySizer) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
257 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
258 if dialog.AffirmedShowModal(): |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
259 return ( |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
260 portCtrl.GetValue(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
261 int(baudrateCtrl.GetValue()), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
262 bytesizeCtrl.GetSelection(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
263 parityCtrl.GetSelection(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
264 stopbitsCtrl.GetSelection(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
265 handshakeCtrl.GetSelection(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
266 generateEventsCtrl.GetValue(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
267 prefixCtrl.GetValue(), |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
268 ) |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
269 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
270 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
271 |
c978dbb7e4b8
Commit first version of plugin to parse events from MaxStream ZigBee modules.
darius@inchoate.localdomain
parents:
diff
changeset
|
272 |