Commit 8ffa0b2498b88e220d43e5af9aec4faa7d01ba19
1 parent
55cc5637
Exists in
master
MOD: Trigger pulse by sending BREAK via serial port
Previously, when using high baud rates, the pulse signal was not long enough to trigger the TMS device. Instead of sending a byte via serial port (for which the duration of the signal is determined implicitly by the baud rate), trigger the pulse by sending BREAK signal, for which the pulse duration can be explicitly defined. Set the pulse duration tentatively to 5 ms, adjust later if needed.
Showing
2 changed files
with
4 additions
and
3 deletions
Show diff stats
invesalius/constants.py
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.") | ... | ... |