Finished preliminray version of the python serial monitor. Updated arduino scripts to wor at 115200 baud rate.
This commit is contained in:
parent
59a9758a63
commit
9af30ef829
5 changed files with 61 additions and 2 deletions
6
.vim/coc-settings.json
Normal file
6
.vim/coc-settings.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"python.linting.pylintEnabled": true,
|
||||||
|
"python.linting.mypyEnabled": false,
|
||||||
|
"python.linting.enabled": true,
|
||||||
|
"python.formatting.provider": "black"
|
||||||
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ void setup() {
|
||||||
// Setting an invalid value.
|
// Setting an invalid value.
|
||||||
lastOp = -1;
|
lastOp = -1;
|
||||||
|
|
||||||
Serial.begin(9600);
|
Serial.begin(115200);
|
||||||
|
|
||||||
writeEEPROM(0x1234, 0x55, true);
|
writeEEPROM(0x1234, 0x55, true);
|
||||||
writeEEPROM(0x4321, 0x7E, true);
|
writeEEPROM(0x4321, 0x7E, true);
|
||||||
|
|
|
||||||
9
arduino_programs/arduino_tester.ino
Normal file
9
arduino_programs/arduino_tester.ino
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
// This program is supposed to be used with an Arduino Mega.
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#define WRITE_CLOCK 19
|
#define WRITE_CLOCK 19
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(115200);
|
||||||
attachInterrupt(digitalPinToInterrupt(ADDRESS_CLOCK), onAddressClock, RISING);
|
attachInterrupt(digitalPinToInterrupt(ADDRESS_CLOCK), onAddressClock, RISING);
|
||||||
attachInterrupt(digitalPinToInterrupt(WRITE_CLOCK), onWriteClock, FALLING);
|
attachInterrupt(digitalPinToInterrupt(WRITE_CLOCK), onWriteClock, FALLING);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
44
serial_monitor/serial_monitor.py
Normal file
44
serial_monitor/serial_monitor.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
import glob
|
||||||
|
import argparse
|
||||||
|
import serial
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--port")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Get all the valid serial ports available.
|
||||||
|
available_ports = glob.glob("/dev/cu.*")
|
||||||
|
|
||||||
|
# Only do this if the user did not specify a port.
|
||||||
|
if args.port is None:
|
||||||
|
# Make the user select a port to start a listening session.
|
||||||
|
print("Available ports:")
|
||||||
|
for i, port in enumerate(available_ports):
|
||||||
|
print(f"{i} - {port}")
|
||||||
|
|
||||||
|
selected_port_index = None
|
||||||
|
while selected_port_index is None and args.port is None:
|
||||||
|
try:
|
||||||
|
selected_port_index = input(
|
||||||
|
"\nType port number to start listening section: "
|
||||||
|
)
|
||||||
|
selected_port_index = int(selected_port_index)
|
||||||
|
if selected_port_index < 0 or selected_port_index >= len(available_ports):
|
||||||
|
print("The port number you provided does not exist.")
|
||||||
|
selected_port_index = None
|
||||||
|
except:
|
||||||
|
print("The typed input is not valid, please enter a valid number.")
|
||||||
|
selected_port_index = None
|
||||||
|
|
||||||
|
port = args.port if args.port is not None else available_ports[selected_port_index]
|
||||||
|
# TODO: Allow selecting baud raute, 115200 by default for now.
|
||||||
|
with serial.Serial(port, 115200) as ser:
|
||||||
|
while True:
|
||||||
|
byte = ser.read()
|
||||||
|
print(byte.decode("utf-8"), end="")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue