Skip to content

Commit

Permalink
make test software dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuni38317 committed Oct 22, 2022
1 parent 3f37658 commit 49245ce
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 177 deletions.
File renamed without changes.
96 changes: 48 additions & 48 deletions software/serial_read.py → test_software/serial_read.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
from serial import Serial
from struct import unpack
import time

ser=Serial("COM16",1500000,timeout=1.0)
waitlittle = .1 #seconds

#This is a _minimal_ set of example commands needed to send to a board to initialize it properly
commands = [
[0, 20], #Set board id to 0
[135, 0, 100], #serialdelaytimerwait of 100
[122, 0, 10], #number of samples 10
[123, 0], #send increment
[124, 3], #downsample 3
[125, 1], #tickstowait 1
[136, 2, 32, 0, 0, 255, 200], # io expanders on (!)
[136, 2, 32, 1, 0, 255, 200], # io expanders on (!)
[136, 2, 33, 0, 0, 255, 200], #, io expanders on (!)
[136, 2, 33, 1, 0, 255, 200], # io expanders on (!)
[136, 2, 32, 18, 240, 255, 200], # init
[136, 2, 32, 19, 15, 255, 200], # init (and turn on ADCs!)
[136, 2, 33, 18, 0, 255, 200], # init
[136, 2, 33, 19, 0, 255, 200], # init
[131, 8, 0], # adc offset
[131, 6, 16], #offset binary output
# [131, 6, 80], #test pattern output
[131, 4, 36], #300 Ohm termination A
[131, 5, 36], #300 Ohm termination B
[131, 1, 0], #not multiplexed
[136, 3, 96, 80, 136, 22, 0], # channel 0 , board 0 calib
[136, 3, 96, 82, 136, 22, 0], # channel 1 , board 0 calib
[136, 3, 96, 84, 136, 22, 0], # channel 2 , board 0 calib
[136, 3, 96, 86, 136, 22, 0], # channel 3 , board 0 calib
]

for command in commands:
ser.write(bytearray(command))
time.sleep(waitlittle)

# OK, we're set up! Now we can read events and get good data out.
ser.write(bytearray([100, 10])) # arm trigger and get an event
result = ser.read(40)
byte_array = unpack('%dB' % len(result), result)

for i in range(0,4):
print byte_array[ 10*i : 10*i + 10 ] # print out the 4 channels

ser.close()
from serial import Serial
from struct import unpack
import time

ser=Serial("COM16",1500000,timeout=1.0)
waitlittle = .1 #seconds

#This is a _minimal_ set of example commands needed to send to a board to initialize it properly
commands = [
[0, 20], #Set board id to 0
[135, 0, 100], #serialdelaytimerwait of 100
[122, 0, 10], #number of samples 10
[123, 0], #send increment
[124, 3], #downsample 3
[125, 1], #tickstowait 1
[136, 2, 32, 0, 0, 255, 200], # io expanders on (!)
[136, 2, 32, 1, 0, 255, 200], # io expanders on (!)
[136, 2, 33, 0, 0, 255, 200], #, io expanders on (!)
[136, 2, 33, 1, 0, 255, 200], # io expanders on (!)
[136, 2, 32, 18, 240, 255, 200], # init
[136, 2, 32, 19, 15, 255, 200], # init (and turn on ADCs!)
[136, 2, 33, 18, 0, 255, 200], # init
[136, 2, 33, 19, 0, 255, 200], # init
[131, 8, 0], # adc offset
[131, 6, 16], #offset binary output
# [131, 6, 80], #test pattern output
[131, 4, 36], #300 Ohm termination A
[131, 5, 36], #300 Ohm termination B
[131, 1, 0], #not multiplexed
[136, 3, 96, 80, 136, 22, 0], # channel 0 , board 0 calib
[136, 3, 96, 82, 136, 22, 0], # channel 1 , board 0 calib
[136, 3, 96, 84, 136, 22, 0], # channel 2 , board 0 calib
[136, 3, 96, 86, 136, 22, 0], # channel 3 , board 0 calib
]

for command in commands:
ser.write(bytearray(command))
time.sleep(waitlittle)

# OK, we're set up! Now we can read events and get good data out.
ser.write(bytearray([100, 10])) # arm trigger and get an event
result = ser.read(40)
byte_array = unpack('%dB' % len(result), result)

for i in range(0,4):
print byte_array[ 10*i : 10*i + 10 ] # print out the 4 channels

ser.close()
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
from serial import Serial
from struct import unpack
import time

serialtimeout=10.0
ser=Serial("COM5",1500000,timeout=serialtimeout)
waitlittle = .1 #seconds

#This is a _minimal_ set of example commands needed to send to a board to initialize it properly
commands = [
[0, 20], #Set board id to 0
[135, 0, 100], #serialdelaytimerwait of 100
[122, 0, 10], #number of samples 10
[123, 0], #send increment
[124, 3], #downsample 3
[125, 1], #tickstowait 1
[136, 2, 32, 0, 0, 255, 200], # io expander 1A on - use as outputs
[136, 2, 32, 1, 0, 255, 200], # io expander 1B on - use as outputs
[136, 2, 33, 0, 0, 255, 200], # io expander 2A on - use as outputs
[136, 2, 33, 1, 255, 255, 200], # io expander 2B on - use as inputs !
[136, 2, 33, 13, 255, 255, 200], # io expander 2B enable pull-up resistors!
[136, 2, 32, 18, 240, 255, 200], # init
[136, 2, 32, 19, 15, 255, 200], # init (and turn on ADCs!)
[136, 2, 33, 18, 0, 255, 200], # init
# [136, 2, 33, 19, 0, 255, 200], # init
[131, 8, 0], # adc offset
[131, 6, 16], #offset binary output
# [131, 6, 80], #test pattern output
[131, 4, 36], #300 Ohm termination A
[131, 5, 36], #300 Ohm termination B
[131, 1, 0], #not multiplexed
[136, 3, 96, 80, 136, 22, 0], # channel 0 , board 0 calib
[136, 3, 96, 82, 136, 22, 0], # channel 1 , board 0 calib
[136, 3, 96, 84, 136, 22, 0], # channel 2 , board 0 calib
[136, 3, 96, 86, 136, 22, 0], # channel 3 , board 0 calib
]

for command in commands:
ser.write(bytearray(command))
time.sleep(waitlittle)

# OK, we're set up! Now we can read events and get good data out.

oldtime=time.time()
boa=0 # board to get ID from
ser.write(bytearray([30+boa, 142])) #request the unique ID
rslt = ser.read(8)
byte_array = unpack('%dB'%len(rslt),rslt) #Convert serial data to array of numbers
uniqueID = ''.join(format(x, '02x') for x in byte_array)
print "got uniqueID",uniqueID,"for board",boa," in",round((time.time()-oldtime)*1000.,2),"ms"

oldtime=time.time()
boa=0 # board to get firmware version from
ser.write(bytearray([30+boa, 147])) #request the firmware version
ser.timeout=0.1; rslt = ser.read(1); ser.timeout=serialtimeout # reduce the serial timeout temporarily, since the old firmware versions will return nothing for command 147
byte_array = unpack('%dB'%len(rslt),rslt)
firmwareversion=0
if len(byte_array)>0: firmwareversion=byte_array[0]
print "got firmwareversion",firmwareversion,"for board",boa,"in",round((time.time()-oldtime)*1000.,2),"ms"

oldtime=time.time()
for i in range(2):
ser.write(bytearray([146, 33, 19, 0]))# #request the IO expander data from 2B for board 0
rslt = ser.read(1)
#print "result is length",len(rslt)
if len(rslt)>0:
byte_array = unpack('%dB'%len(rslt),rslt)
print i,byte_array[0]
print "got i2c data in",round((time.time()-oldtime)*1000./2.,2),"ms"

ser.write(bytearray([100, 10])) # arm trigger and get an event
rslt = ser.read(40)#[0:10]
byte_array = unpack('%dB'%len(rslt),rslt)

for i in range(4):
print byte_array[10*i : 10*i+10] # print out the 4 channels

ser.close()
from serial import Serial
from struct import unpack
import time

serialtimeout=10.0
ser=Serial("COM5",1500000,timeout=serialtimeout)
waitlittle = .1 #seconds

#This is a _minimal_ set of example commands needed to send to a board to initialize it properly
commands = [
[0, 20], #Set board id to 0
[135, 0, 100], #serialdelaytimerwait of 100
[122, 0, 10], #number of samples 10
[123, 0], #send increment
[124, 3], #downsample 3
[125, 1], #tickstowait 1
[136, 2, 32, 0, 0, 255, 200], # io expander 1A on - use as outputs
[136, 2, 32, 1, 0, 255, 200], # io expander 1B on - use as outputs
[136, 2, 33, 0, 0, 255, 200], # io expander 2A on - use as outputs
[136, 2, 33, 1, 255, 255, 200], # io expander 2B on - use as inputs !
[136, 2, 33, 13, 255, 255, 200], # io expander 2B enable pull-up resistors!
[136, 2, 32, 18, 240, 255, 200], # init
[136, 2, 32, 19, 15, 255, 200], # init (and turn on ADCs!)
[136, 2, 33, 18, 0, 255, 200], # init
# [136, 2, 33, 19, 0, 255, 200], # init
[131, 8, 0], # adc offset
[131, 6, 16], #offset binary output
# [131, 6, 80], #test pattern output
[131, 4, 36], #300 Ohm termination A
[131, 5, 36], #300 Ohm termination B
[131, 1, 0], #not multiplexed
[136, 3, 96, 80, 136, 22, 0], # channel 0 , board 0 calib
[136, 3, 96, 82, 136, 22, 0], # channel 1 , board 0 calib
[136, 3, 96, 84, 136, 22, 0], # channel 2 , board 0 calib
[136, 3, 96, 86, 136, 22, 0], # channel 3 , board 0 calib
]

for command in commands:
ser.write(bytearray(command))
time.sleep(waitlittle)

# OK, we're set up! Now we can read events and get good data out.

oldtime=time.time()
boa=0 # board to get ID from
ser.write(bytearray([30+boa, 142])) #request the unique ID
rslt = ser.read(8)
byte_array = unpack('%dB'%len(rslt),rslt) #Convert serial data to array of numbers
uniqueID = ''.join(format(x, '02x') for x in byte_array)
print "got uniqueID",uniqueID,"for board",boa," in",round((time.time()-oldtime)*1000.,2),"ms"

oldtime=time.time()
boa=0 # board to get firmware version from
ser.write(bytearray([30+boa, 147])) #request the firmware version
ser.timeout=0.1; rslt = ser.read(1); ser.timeout=serialtimeout # reduce the serial timeout temporarily, since the old firmware versions will return nothing for command 147
byte_array = unpack('%dB'%len(rslt),rslt)
firmwareversion=0
if len(byte_array)>0: firmwareversion=byte_array[0]
print "got firmwareversion",firmwareversion,"for board",boa,"in",round((time.time()-oldtime)*1000.,2),"ms"

oldtime=time.time()
for i in range(2):
ser.write(bytearray([146, 33, 19, 0]))# #request the IO expander data from 2B for board 0
rslt = ser.read(1)
#print "result is length",len(rslt)
if len(rslt)>0:
byte_array = unpack('%dB'%len(rslt),rslt)
print i,byte_array[0]
print "got i2c data in",round((time.time()-oldtime)*1000./2.,2),"ms"

ser.write(bytearray([100, 10])) # arm trigger and get an event
rslt = ser.read(40)#[0:10]
byte_array = unpack('%dB'%len(rslt),rslt)

for i in range(4):
print byte_array[10*i : 10*i+10] # print out the 4 channels

ser.close()
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from serial import Serial
from struct import unpack
import time

serialtimeout=1.0
ser=Serial("/dev/ttyUSB0",1500000,timeout=serialtimeout)

#This is a _minimal_ test of sending a python command

i=0
while i<2000:
ser.write(bytearray([201]));
time.sleep(1)
i=i+1

ser.close()
from serial import Serial
from struct import unpack
import time

serialtimeout=1.0
ser=Serial("/dev/ttyUSB0",1500000,timeout=serialtimeout)

#This is a _minimal_ test of sending a python command

i=0
while i<2000:
ser.write(bytearray([201]));
time.sleep(1)
i=i+1

ser.close()
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
from serial import Serial
from struct import unpack
import time

serialtimeout=1.0
ser=Serial("COM5",1500000,timeout=serialtimeout)
waitlittle = .1 #seconds

#This is a _minimal_ set of example commands needed to send to a board to initialize it properly

ser.write(chr(0)); ser.write(chr(20)) #set board id to 0
time.sleep(waitlittle)
ser.write(chr(135)); ser.write(chr(0)); ser.write(chr(100)); #serialdelaytimerwait of 100
time.sleep(waitlittle)

oldtime=time.time()
boa=0 # board to get ID from
ser.write(chr(30+boa)) #make the next board active (serial_passthrough 0)
ser.write(chr(142)) #request the unique ID
rslt = ser.read(8)
byte_array = unpack('%dB'%len(rslt),rslt) #Convert serial data to array of numbers
uniqueID = ''.join(format(x, '02x') for x in byte_array)
print "got uniqueID",uniqueID,"for board",boa," in",round((time.time()-oldtime)*1000.,2),"ms"

oldtime=time.time()
boa=0 # board to get firmware version from
ser.write(chr(30+boa)) #make the next board active (serial_passthrough 0)
ser.write(chr(147)) #request the firmware version byte
ser.timeout=0.1; rslt = ser.read(1); ser.timeout=serialtimeout # reduce the serial timeout temporarily, since the old firmware versions will return nothing for command 147
byte_array = unpack('%dB'%len(rslt),rslt)
firmwareversion=0
if len(byte_array)>0: firmwareversion=byte_array[0]
print "got firmwareversion",firmwareversion,"for board",boa,"in",round((time.time()-oldtime)*1000.,2),"ms"

ser.close()
from serial import Serial
from struct import unpack
import time

serialtimeout=1.0
ser=Serial("COM5",1500000,timeout=serialtimeout)
waitlittle = .1 #seconds

#This is a _minimal_ set of example commands needed to send to a board to initialize it properly

ser.write(chr(0)); ser.write(chr(20)) #set board id to 0
time.sleep(waitlittle)
ser.write(chr(135)); ser.write(chr(0)); ser.write(chr(100)); #serialdelaytimerwait of 100
time.sleep(waitlittle)

oldtime=time.time()
boa=0 # board to get ID from
ser.write(chr(30+boa)) #make the next board active (serial_passthrough 0)
ser.write(chr(142)) #request the unique ID
rslt = ser.read(8)
byte_array = unpack('%dB'%len(rslt),rslt) #Convert serial data to array of numbers
uniqueID = ''.join(format(x, '02x') for x in byte_array)
print "got uniqueID",uniqueID,"for board",boa," in",round((time.time()-oldtime)*1000.,2),"ms"

oldtime=time.time()
boa=0 # board to get firmware version from
ser.write(chr(30+boa)) #make the next board active (serial_passthrough 0)
ser.write(chr(147)) #request the firmware version byte
ser.timeout=0.1; rslt = ser.read(1); ser.timeout=serialtimeout # reduce the serial timeout temporarily, since the old firmware versions will return nothing for command 147
byte_array = unpack('%dB'%len(rslt),rslt)
firmwareversion=0
if len(byte_array)>0: firmwareversion=byte_array[0]
print "got firmwareversion",firmwareversion,"for board",boa,"in",round((time.time()-oldtime)*1000.,2),"ms"

ser.close()
File renamed without changes.

0 comments on commit 49245ce

Please sign in to comment.