diff --git a/comm/SerialUSB/ring.SerialUSB.ino b/comm/SerialUSB/ring.SerialUSB.ino new file mode 100644 index 0000000000000000000000000000000000000000..bbd5f9e9206925823d14c8aac196d836451dc6c2 --- /dev/null +++ b/comm/SerialUSB/ring.SerialUSB.ino @@ -0,0 +1,25 @@ +// +// 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()); + } + } + } diff --git a/comm/pySerial/ring.pySerial.py b/comm/pySerial/ring.pySerial.py new file mode 100755 index 0000000000000000000000000000000000000000..560aafd4dc9802eb89c1347864830298e57e66c0 --- /dev/null +++ b/comm/pySerial/ring.pySerial.py @@ -0,0 +1,38 @@ +#!/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}") +