Commit e1b52082f042948e62e67d3c8934f1bddbb02dd3
Committed by
GitHub
Exists in
master
Merge pull request #389 from okahilak/trigger-pulse-by-sending-break-via-serial-port
MOD: Trigger pulse by sending BREAK via serial port
Showing
2 changed files
with
4 additions
and
3 deletions
Show diff stats
invesalius/constants.py
@@ -834,3 +834,4 @@ WILDCARD_MARKER_FILES = _("Marker scanner coord files (*.mkss)|*.mkss") | @@ -834,3 +834,4 @@ WILDCARD_MARKER_FILES = _("Marker scanner coord files (*.mkss)|*.mkss") | ||
834 | # Serial port | 834 | # Serial port |
835 | BAUD_RATES = [300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200] | 835 | BAUD_RATES = [300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200] |
836 | BAUD_RATE_DEFAULT_SELECTION = 4 | 836 | BAUD_RATE_DEFAULT_SELECTION = 4 |
837 | +PULSE_DURATION_IN_MILLISECONDS = 0.2 |
invesalius/data/serial_port_connection.py
@@ -22,12 +22,12 @@ import threading | @@ -22,12 +22,12 @@ import threading | ||
22 | import time | 22 | import time |
23 | 23 | ||
24 | import wx | 24 | import wx |
25 | + | ||
26 | +from invesalius import constants | ||
25 | from invesalius.pubsub import pub as Publisher | 27 | from invesalius.pubsub import pub as Publisher |
26 | 28 | ||
27 | 29 | ||
28 | class SerialPortConnection(threading.Thread): | 30 | class SerialPortConnection(threading.Thread): |
29 | - BINARY_PULSE = b'\x01' | ||
30 | - | ||
31 | def __init__(self, com_port, baud_rate, serial_port_queue, event, sleep_nav): | 31 | def __init__(self, com_port, baud_rate, serial_port_queue, event, sleep_nav): |
32 | """ | 32 | """ |
33 | Thread created to communicate using the serial port to interact with software during neuronavigation. | 33 | Thread created to communicate using the serial port to interact with software during neuronavigation. |
@@ -65,7 +65,7 @@ class SerialPortConnection(threading.Thread): | @@ -65,7 +65,7 @@ class SerialPortConnection(threading.Thread): | ||
65 | 65 | ||
66 | def SendPulse(self): | 66 | def SendPulse(self): |
67 | try: | 67 | try: |
68 | - self.connection.write(self.BINARY_PULSE) | 68 | + self.connection.send_break(constants.PULSE_DURATION_IN_MILLISECONDS / 1000) |
69 | Publisher.sendMessage('Serial port pulse triggered') | 69 | Publisher.sendMessage('Serial port pulse triggered') |
70 | except: | 70 | except: |
71 | print("Error: Serial port could not be written into.") | 71 | print("Error: Serial port could not be written into.") |