aboutsummaryrefslogtreecommitdiff
path: root/test_serial.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_serial.py')
-rwxr-xr-xtest_serial.py41
1 files changed, 14 insertions, 27 deletions
diff --git a/test_serial.py b/test_serial.py
index 1d071d9..8587e19 100755
--- a/test_serial.py
+++ b/test_serial.py
@@ -5,10 +5,8 @@ import time # For sleep, clock, time and perf_counter
from datetime import datetime, timedelta
# ser = serial.Serial('COM4', 115200, timeout=1)
-# ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=1)
-ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
-# sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser), line_buffering=True, newline='\r\n')
-
+ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=1)
+# ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
# ser.write(b'dofile("bits_converging.lua")\r')
# ser.write(b'dofile("microwire.lua")\r')
@@ -19,30 +17,17 @@ ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
# ser.write(b'settings = set_lmx2487_to_Frequency (startfreq, settings)\r')
-# ser.write(b'\rprint(2+2)\r')
-# ser.write(b'print(node.heap())\r')
-# s = ser.read(100)
-
-# print("1st reply")
-# print(s)
-# line = ser.readline()
-# print(line)
-# line = ser.readline()
-# print(line)
-# line = ser.readline()
-# print(line)
-# line = ser.readline()
-# print(line)
def sendSerialCmd(cmd):
- start = datetime.now()
+ # start = datetime.now()
ser.write(bytes(cmd+'\r','ascii'))
- # sio.write(cmd+'\r')
- line = ser.read_until(terminator=b'> ')
- print(line)
- stop = datetime.now()
- runTime = (stop-start).seconds + float((stop-start).microseconds)/1000000
- print("Command: " + cmd + " runtime %s seconds." % (runTime) )
+ resp = ser.read_until(terminator=b'> ')
+ resp = resp.decode('utf-8')
+ # print(resp)
+ # stop = datetime.now()
+ # runTime = (stop-start).seconds + float((stop-start).microseconds)/1000000
+ # print("Command: " + cmd + " runtime %s seconds." % (runTime) )
+ return resp
sendSerialCmd("print(2+3)")
@@ -50,8 +35,10 @@ line = ser.readline()
print(line)
start = datetime.now()
-for i in range(1,10):
- sendSerialCmd("print(node.heap())")
+# resp = sendSerialCmd("print(node.heap())")
+# resp = sendSerialCmd(""); # empty command
+resp = sendSerialCmd("Sb, muSb= rtctime.get(); print(4); Se, muSe =rtctime.get(); print(\"execution time: \" .. muSe-muSb .. \" muS\")")
+print(resp)
stop = datetime.now()
runTime = (stop-start).seconds + float((stop-start).microseconds)/1000000
print("runtime %s seconds." % (runTime) )