Commit 8ffa0b2498b88e220d43e5af9aec4faa7d01ba19

Authored by Olli-Pekka Kahilakoski
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.
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 = 5
... ...
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.")
... ...