Skip to content
Snippets Groups Projects
Commit fc4551bf authored by Neil Gershenfeld (test)'s avatar Neil Gershenfeld (test)
Browse files

start comm

parent 1ba429af
No related branches found
No related tags found
No related merge requests found
Pipeline #11041 passed
//
// ring.SerialUSB.ino
//
// SerialUSB communication ring test
//
// Neil Gershenfeld 3/31/21
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge this project. Copyright is retained and
// must be preserved. The work is provided as is; no
// warranty is provided, and users accept all liability.
//
void setup() {
SerialUSB.begin(0);
}
void loop() {
while (true) {
if (SerialUSB.available()) {
SerialUSB.write(1+SerialUSB.read());
}
}
}
#!/usr/bin/env python
#
# ring.pySerial.py
#
# pySerial communication ring test
#
# Neil Gershenfeld 3/31/21
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge this project. Copyright is retained and
# must be preserved. The work is provided as is; no
# warranty is provided, and users accept all liability.
#
import serial,sys,time
nloop = 10
if (len(sys.argv) != 3):
print("command line: ring.pyserial.py serial_port port_speed")
sys.exit()
port = sys.argv[1]
speed = int(sys.argv[2])
ser = serial.Serial(port,speed)
ser.flushInput()
x = 0
start = time.time()
for i in range(nloop):
while True:
ser.write(x.to_bytes(1,byteorder='big'))
x = int.from_bytes(ser.read(1),byteorder='big')
if (x == 0):
break
end = time.time()
print(f"byte ring cycles per second: {nloop*256/(end-start):6.3g}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment