UsbSerial/integration/validate_serial_tx.py

20 wiersze
347 B
Python
Czysty Zwykły widok Historia

2019-02-23 22:45:56 +00:00
import serial
import sys
import os
2019-03-02 20:45:03 +00:00
port = sys.argv[1]
size = sys.argv[2]
speed = sys.argv[3]
2019-02-23 22:45:56 +00:00
2019-02-23 22:49:26 +00:00
comm = serial.Serial(port, int(speed))
2019-02-23 22:45:56 +00:00
2019-03-02 20:45:03 +00:00
data_tx = os.urandom(int(size))
2019-02-23 22:49:26 +00:00
comm.write(data_tx)
2019-03-02 20:45:03 +00:00
data_rx = comm.read(int(size))
2019-02-23 22:49:26 +00:00
if data_tx == data_rx:
print("Success: Data was transmitted correctly")
else:
2019-03-02 20:45:03 +00:00
print("Error: Data was not transmitted")