Skip to content

Commit

Permalink
removed prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
ripred committed Jan 20, 2024
1 parent 870a88f commit dee5530
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions arduino_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def open_serial_port(port, baud):
"""
@brief Open the specified serial port.
Attempts to open the specified serial port with a timeout of 1 second.
Attempts to open the specified serial port with a timeout of 30 milliseconds.
@param port: The serial port to open.
@param baud: The baud rate.
Expand Down Expand Up @@ -357,13 +357,12 @@ def run():
macros = load_macros()
setup_logger()

prompted = False
while True:
if not prompted:
print("Waiting for a command from the Arduino...")
prompted = True

arduino_command = cmd_serial.readline().decode('utf-8').strip()
try:
arduino_command = cmd_serial.readline().decode('utf-8').strip()
except Exception as e:
logger.error(f"An unexpected error occurred: {e}")
continue

if not arduino_command:
continue
Expand Down Expand Up @@ -414,7 +413,6 @@ def run():

# Check if the command is a Serial Monitor output line
elif cmd_id == '#':
# print out the received message
result = command

else:
Expand All @@ -429,11 +427,9 @@ def run():
lines.pop() # Remove the last line

for line in lines:
print(line + '\n', end="")
print(line)
cmd_serial.write(line.encode('utf-8') + b'\n')

prompted = False


if __name__ == '__main__':
run()

0 comments on commit dee5530

Please sign in to comment.