Skip to content

Commit 5706c93

Browse files
committed
FIX: Ensure commands sent to serial port by routines end in \n
1 parent 84c6932 commit 5706c93

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

data_gateway/cli.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ def _get_serial_port(serial_port, configuration, use_dummy_serial_port):
371371

372372
def _load_routine(routine_path, interactive, serial_port):
373373
"""Load a sensor commands routine from the path if exists, otherwise return no routine. If in interactive mode, the
374-
routine file is ignored.
374+
routine file is ignored. Note that "\n" has to be added to the end of each command sent to the serial port for it to
375+
be executed - this is done automatically in this method.
375376
376377
:param str routine_path:
377378
:param bool interactive:
@@ -383,7 +384,10 @@ def _load_routine(routine_path, interactive, serial_port):
383384
logger.warning("Sensor command routine files are ignored in interactive mode.")
384385
else:
385386
with open(routine_path) as f:
386-
routine = Routine(**json.load(f), action=lambda command: serial_port.write(command.encode("utf_8")))
387+
routine = Routine(
388+
**json.load(f),
389+
action=lambda command: serial_port.write((command + "\n").encode("utf_8")),
390+
)
387391

388392
logger.info("Loaded routine file from %r.", routine_path)
389393
return routine

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ force_grid_wrap=0
2323
combine_as_imports=True
2424

2525
[pydocstyle]
26-
ignore = D100, D101, D104, D105, D107, D203, D205, D213, D400, D415
26+
ignore = D100, D101, D104, D105, D107, D203, D205, D213, D301, D400, D415

0 commit comments

Comments
 (0)