Class SerialTrigger#
Defined in File serial_trigger.hpp
Inheritance Relationships#
Base Type#
public QObject
Class Documentation#
-
class SerialTrigger : public QObject
Receives trigger events from an RS-232 / USB-serial port.
SerialTrigger opens the configured serial port and listens for incoming bytes. A trigger fires when the received byte satisfies the match rule defined in
SerialTriggerConfig::matchMode:AnyByte — any received byte fires.
NonZero — fires only for non-zero bytes.
Exact — fires only if the byte equals
matchValue(hex string, e.g."0xFF").
The trigger label is set to the config name; the value is the decimal representation of the received byte.
See also
SerialTriggerConfig, TriggerManager
- Thread safety
All methods must be called from the main thread. QSerialPort uses Qt’s event loop for async I/O, so no additional thread is needed.
Public Functions
-
explicit SerialTrigger(SerialTriggerConfig &config, QObject *parent = nullptr)
-
~SerialTrigger() override
-
bool open()
Opens the serial port with the current config.
- Returns:
trueon success; logs the reason on failure.
-
void close()
Closes the serial port. Safe to call when already closed.
-
bool is_open() const
- Returns:
truewhile the port is open.
-
int fire_count() const
- Returns:
The number of trigger events fired since the last reset.
-
void reset_count()
Signals
-
void triggered(mosaic::TriggerEvent event)
Emitted on the main thread each time a matching byte is received.
-
void count_changed(int count)
Emitted whenever fire_count() changes.
-
void error_occurred(QString message)
Emitted when QSerialPort reports a non-NoError state.
Public Static Functions
-
static QStringList available_ports()
- Returns:
A list of all available serial port names on this system.