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 | 834 | # Serial port |
| 835 | 835 | BAUD_RATES = [300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200] |
| 836 | 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 | 22 | import time |
| 23 | 23 | |
| 24 | 24 | import wx |
| 25 | + | |
| 26 | +from invesalius import constants | |
| 25 | 27 | from invesalius.pubsub import pub as Publisher |
| 26 | 28 | |
| 27 | 29 | |
| 28 | 30 | class SerialPortConnection(threading.Thread): |
| 29 | - BINARY_PULSE = b'\x01' | |
| 30 | - | |
| 31 | 31 | def __init__(self, com_port, baud_rate, serial_port_queue, event, sleep_nav): |
| 32 | 32 | """ |
| 33 | 33 | Thread created to communicate using the serial port to interact with software during neuronavigation. |
| ... | ... | @@ -65,7 +65,7 @@ class SerialPortConnection(threading.Thread): |
| 65 | 65 | |
| 66 | 66 | def SendPulse(self): |
| 67 | 67 | try: |
| 68 | - self.connection.write(self.BINARY_PULSE) | |
| 68 | + self.connection.send_break(constants.PULSE_DURATION_IN_MILLISECONDS / 1000) | |
| 69 | 69 | Publisher.sendMessage('Serial port pulse triggered') |
| 70 | 70 | except: |
| 71 | 71 | print("Error: Serial port could not be written into.") | ... | ... |