Skip to content
Snippets Groups Projects
Commit 00107fc0 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

Values better?

parent 3878f336
Branches
No related tags found
No related merge requests found
......@@ -70,7 +70,13 @@ Shopbot/0.1 mil steps/10x microstep = 78,740 steps/s
<img src=threads.png width=75%><br>
# [multiprocessing](serialtimetest.2.multi.py)
# [multiprocessing Events](serialtimetest.2.multi.py)
<img src=multi-event.png width=75%><br>
<img src=multi-event.1.png width=75%><br>
# [multiprocessing Values](serialtimetest.2.multi.py)
<img src=multi-values.png width=75%><br>
<img src=multi-values.1.png width=75%><br>
serialtimetest/multi-values.1.png

22.5 KiB

serialtimetest/multi-values.png

20.6 KiB

......@@ -9,10 +9,7 @@
# must be preserved. The work is provided as is; no
# warranty is provided, and users accept all liability.
#
#import serial,sys,time,signal,multiprocessing
import sys,time,signal,multiprocessing
import serial,sys,time,signal,multiprocessing
if (len(sys.argv) != 5):
print("command line: serialtest.2.multi.py port1 port2 speed delay")
sys.exit()
......@@ -20,15 +17,12 @@ device1 = sys.argv[1]
device2 = sys.argv[2]
baud = int(sys.argv[3])
delay = float(sys.argv[4])
'''
print('open '+device1+' at '+str(baud)+' delay '+str(delay))
port0 = serial.Serial(device1,baudrate=baud,timeout=0)
print('open '+device2+' at '+str(baud)+' delay '+str(delay))
port1 = serial.Serial(device2,baudrate=baud,timeout=0)
msg = b"\x00"
ports = [port0,port1]
'''
'''
#
# event version
......@@ -75,11 +69,11 @@ def worker(id,val):
while (1):
if (val.value == 0):
break
print(id,val.value)
ports[id].write(msg)
while (1):
if (val.value == 1):
break
print(id,val.value)
ports[id].write(msg)
#
# alarm event handler
#
......@@ -95,7 +89,6 @@ p0 = multiprocessing.Process(target=worker,args=(0,val,))
p0.start()
p1 = multiprocessing.Process(target=worker,args=(1,val,))
p1.start()
#
# start alarm
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment