File tree 3 files changed +21
-9
lines changed
3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 1
1
from pymate .matenet import MateNET , MateMXDevice
2
2
from time import sleep
3
+ from settings import SERIAL_PORT
3
4
4
5
print "MATE emulator (MX)"
5
6
6
7
7
8
# Create a MateNET bus connection
8
- bus = MateNET ('/dev/ttyUSB0' )
9
+ bus = MateNET (SERIAL_PORT )
10
+
11
+ # Find an MX device on the bus
12
+ port = bus .find_device (MateNET .DEVICE_MX )
9
13
10
14
# Create a new MATE emulator attached to the specified port
11
- mate = MateMXDevice (bus )
15
+ mate = MateMXDevice (bus , port )
12
16
13
17
# Check that an MX unit is attached and is responding
14
18
mate .scan ()
Original file line number Diff line number Diff line change 5
5
#
6
6
7
7
from pymate .matenet import MateNET , MateDevice
8
- from srv1 . settings import SERIAL_PORT
8
+ from settings import SERIAL_PORT
9
9
10
10
print ("MATE Bus Scan" )
11
11
@@ -26,12 +26,18 @@ def print_device(d):
26
26
rev = d .revision
27
27
except Exception as e :
28
28
rev = str (e )
29
-
30
- print ("Port%d: %s (Rev: %s)" % (
31
- d .port ,
32
- MateNET .DEVICE_TYPES [dtype ],
33
- rev
34
- ))
29
+
30
+ if dtype not in MateNET .DEVICE_TYPES :
31
+ print ("Port%d: Unknown device type: %d" % (
32
+ d .port ,
33
+ dtype
34
+ ))
35
+ else :
36
+ print ("Port%d: %s (Rev: %s)" % (
37
+ d .port ,
38
+ MateNET .DEVICE_TYPES [dtype ],
39
+ rev
40
+ ))
35
41
return dtype
36
42
37
43
# The root device
Original file line number Diff line number Diff line change
1
+ #SERIAL_PORT = '/dev/ttyUSB0'
2
+ SERIAL_PORT = 'COM9'
You can’t perform that action at this time.
0 commit comments