annotate __init__.py @ 3:afd270964f5b default tip

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