-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathER031M.py
41 lines (30 loc) · 881 Bytes
/
ER031M.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import time
import serial
import gc
def connection():
global c
global field_controller
try:
field_controller = serial.Serial("/dev/ttyACM0", 19200, timeout=5, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_TWO)
c=1
except serial.SerialException:
print("No connection")
field_controller.close()
c=0
def close_connection():
field_controller.close()
gc.collect()
def field_controller_write(command):
#c, scope = connection()
if c==1:
time.sleep(1) # very important to have timeout here
field_controller.write(command.encode())
else:
print("No Connection")
def field_controller_set_field(*field):
if len(field)==1:
field_controller_write('cf'+str(field)+'\r') ##########
else:
print("Invalid Argument")
def field_controller_command(command):
field_controller_write(command+'\r') ##########