|
void | setMaxProbeAttempts (int count) |
| Configure number of attempts to initiate communication with the serial port connected to a Turris Dongle.
|
|
void | setProbeTimeout (const Poco::Timespan &timeout) |
| Configure timeout to wait for response from Turris Dongle while probing it.
|
|
void | setIOJoinTimeout (const Poco::Timespan &timeout) |
| Configure join timeout when waiting for the I/O thread to finish.
|
|
void | setIOReadTimeout (const Poco::Timespan &timeout) |
| Configure timeout to use while reading from the serial port inside the I/O loop. The value can be negative but in such case, it might not be woken up properly on exit.
|
|
void | setIOErrorSleep (const Poco::Timespan &delay) |
| Set time interval to sleep for when there is an I/O error. It reduces the number of logged error messages and avoids making the CPU overloaded in such case.
|
|
void | probe (const std::string &dev) |
| Probe the given serial port (e.g. "/dev/ttyUSB0") and if it proves to be a Jablotron control station, the internal I/O thread is started. Only 1 I/O thread can run at a time and only 1 central can be served by an instance of this class. More...
|
|
void | release (const std::string &dev) |
| Release the serial port and stop the I/O thread if running. If the argument dev does not match the current serial port, nothing happens.
|
|
void | dispose () |
| Release the serial port and stop the I/O thread if running.
|
|
JablotronReport | pollReport (const Poco::Timespan &timeout) |
| Poll for reports coming from Jablotron sensors. If the timeout exceeds, an invalid report is returned. The timeout can be -1 to denote infinite waiting.
|
|
Poco::Nullable< uint32_t > | readSlot (unsigned int i, const Poco::Timespan &timeout) |
| Read address of the given slot. More...
|
|
void | registerSlot (unsigned int i, uint32_t address, const Poco::Timespan &timeout) |
| Register the given slot with the given address. More...
|
|
void | unregisterSlot (unsigned int i, const Poco::Timespan &timeout) |
| Unregister the given slot. More...
|
|
void | eraseSlots (const Poco::Timespan &timeout) |
| Unregister all slots at once. More...
|
|
void | sendTX (bool x, bool y, bool alarm, Beep beep, const Poco::Timespan &timeout) |
| Send status packet with PGX and PGY set to either 1 or 0 accodring to the given values. Alarm is disabled and beeping set to FAST . More...
|
|
void | sendEnroll (const Poco::Timespan &timeout) |
| Send enroll packet with PGX, PGY and ALARM as 0 and no beeping. More...
|
|
|
void | handleOkError (const std::string &response) const |
| Check whether the response is "OK" or "ERROR". More...
|
|
std::string | command (const std::string &request, const Poco::Timespan &timeout) |
| Issue a command and return its result unless the timeout exceeds. More...
|
|
void | startIO () |
| Start the I/O thread without any checks and clear any thread-related status.
|
|
void | stopIO (const std::string &dev) |
| Stop the I/O thread is any and if the argument dev matches the currently used serial port. The call blocks until the I/O threads finishes or the ioJoinTimeout exceeds.
|
|
void | probePort (const std::string &dev) |
| Probe the given port and test whether it is an appropriate Turris Dongle. Any obsolete messages in the serial port's buffer (that are invalid) are discarded.
|
|
bool | receivedVersion (const std::string &response) |
| Parse the response to be the version string. More...
|
|
std::string | popResponse () |
| Pop the most recent received response. All older responses are dropped because only 1 command can be issued at a time. All pending older responses are dropped as they are probably some past unhandled responses.
|
|
JablotronReport | popReport () |
| Pop the oldest report from the associated queue. If the queue is empty, it returns an invalid report.
|
|
void | readAndProcess () |
| Read the serial port and process all received messages in order. More...
|
|
void | processMessage (const std::string &message) |
| Process the given message. The call recognizes 2 kinds of messages: reports from sensors and other (unknown) messages. The reports are appended into the m_reports queue and the m_pollEvent is signalzed. All non-report messages are appended into the m_responses queue and the m_requestEvent is signalized.
|
|
void | ioLoop () |
| The entry into the I/O thread loop. It periodically calls readAndProcess() and checks whether a stop is requested. Any time an IOException is caught, the loop sleeps for ioErrorSleep and tries again. Timeouts from serial port are ignored.
|
|
void | writePort (const std::string &request) |
|
std::string | readPort (const Poco::Timespan &timeout) |
|
JablotronController provides access to the Turris Dongle that is connected via a serial port. The Turris Dongle must be probed to start an internal I/O thread that handles incoming messages.