IoT::Devices

class SerialDeviceRemoteObject

File Information

Library: IoT/Devices
Package: Generated
Header: IoT/Devices/SerialDeviceRemoteObject.h

Description

This class provides a simple interface for accessing a serial port.

There are two modes of operation for receiving data: polling (blocking) mode (default) and events (callback) mode.

In polling mode, repeatedly call poll() to detect if data is available, then call one of the read() methods to receive available data. The read() methods can also be called if no data is available, but will block until at least one character can be read.

In event mode the class will start a thread that polls and reads available data from the serial port, and fires the lineReceived event whenever something has been read. Since callback mode uses readLine() to receive entire lines (if possible), delimiter characters and timeout can be set via the "delimiters" (string) and "timeout" (double) properties.

Clients of the class can switch between polling and event mode by enabling or disabling the "events" feature:

setFeature("events", true);

Inheritance

Direct Base Classes: ISerialDevice, Poco::RemotingNG::RemoteObject

All Base Classes: IDevice, ISerialDevice, Poco::OSP::Service, Poco::RefCountedObject, Poco::RemotingNG::Identifiable, Poco::RemotingNG::RemoteObject

Member Summary

Member Functions: available, event__lineReceived, event__statusChanged, getFeature, getPropertyBool, getPropertyDouble, getPropertyInt, getPropertyInt16, getPropertyInt64, getPropertyString, getPropertyTimestamp, getRTS, hasFeature, hasProperty, poll, readByte, readLine, readString, reconfigure, remoting__enableEvents, remoting__enableRemoteEvents, remoting__hasEvents, remoting__typeId, setFeature, setPropertyBool, setPropertyDouble, setPropertyInt, setPropertyInt16, setPropertyInt64, setPropertyString, setPropertyTimestamp, setRTS, writeByte, writeString

Inherited Functions: available, duplicate, getFeature, getPropertyBool, getPropertyDouble, getPropertyInt, getPropertyInt16, getPropertyInt64, getPropertyString, getPropertyTimestamp, getRTS, hasFeature, hasProperty, isA, mutex, poll, readByte, readLine, readString, reconfigure, referenceCount, release, remoting__enableEvents, remoting__enableRemoteEvents, remoting__getURI, remoting__hasEvents, remoting__objectId, remoting__setURI, remoting__typeId, setFeature, setPropertyBool, setPropertyDouble, setPropertyInt, setPropertyInt16, setPropertyInt64, setPropertyString, setPropertyTimestamp, setRTS, type, writeByte, writeString

Types Aliases

Ptr

using Ptr = Poco::AutoPtr < SerialDeviceRemoteObject >;

Constructors

SerialDeviceRemoteObject

SerialDeviceRemoteObject(
    const Poco::RemotingNG::Identifiable::ObjectId & oid,
    Poco::SharedPtr < IoT::Devices::SerialDevice > pServiceObject
);

Destructor

~SerialDeviceRemoteObject virtual

virtual ~SerialDeviceRemoteObject();

Destroys the SerialDeviceRemoteObject.

Member Functions

available virtual inline

virtual int available() const;

Returns the number of characters available from the internal buffer.

getFeature virtual inline

virtual bool getFeature(
    const std::string & name
) const;

Returns true if the feature with the given name is enabled, or false otherwise.

getPropertyBool virtual inline

virtual bool getPropertyBool(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyDouble virtual inline

virtual double getPropertyDouble(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyInt virtual inline

virtual int getPropertyInt(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyInt16 virtual inline

virtual Poco::Int16 getPropertyInt16(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyInt64 virtual inline

virtual Poco::Int64 getPropertyInt64(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyString virtual inline

virtual std::string getPropertyString(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyTimestamp virtual inline

virtual Poco::Timestamp getPropertyTimestamp(
    const std::string & name
) const;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getRTS virtual inline

virtual bool getRTS() const;

Returns the RTS status.

hasFeature virtual inline

virtual bool hasFeature(
    const std::string & name
) const;

Returns true if the feature with the given name is known, or false otherwise.

hasProperty virtual inline

virtual bool hasProperty(
    const std::string & name
) const;

Returns true if the property with the given name exists, or false otherwise.

poll virtual inline

virtual bool poll(
    double timeout
);

Waits for data to arrive at the port.

Returns true immediately if data is already in the internal buffer, or if data arrives during the specified time interval (given in seconds), otherwise false.

readByte virtual inline

virtual Poco::UInt8 readByte();

Reads a single character from the port.

If the internal buffer is empty, blocks until data arrives at the port.

readLine virtual inline

virtual std::string readLine(
    const std::string & delimiters,
    double timeout
);

Reads a characters from the serial port.

Characters will be read until one of the characters specified in delimiters is encountered, or no character is received for the specified timeout (in seconds).

readString virtual inline

virtual std::string readString();

Reads what's currently available from the serial port or internal buffer and returns it in data.

If the internal buffer is empty, blocks until data arrives at the port.

reconfigure virtual inline

virtual void reconfigure(
    int baudRate,
    const std::string & parameters,
    const std::string & flowControl
);

Reconfigures the serial port with the given baud rate and communication parameters.

Baud rate must be one of the following: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200 or 230400.

Specify -1 for baudRate to use the currently configured speed. Note that not all platforms support all baud rates.

To specify character size, parity and stop bits, use the parameters argument. The parameters argument must be a three character string. The first character specifies the serial line character width in bits (5, 6, 7 or 8). The second char specifies the parity (N for none, E for even, O for odd) and the third character specifies the number of stop bits (1 or 2). Example: "8N1" for 8 bit characters, no parity, 1 stop bit.

To specify flow control, use the flowControl argument. Specify "none" or an empty string for no flow control. Specify "rtscts" for hardware (RTS/CTS) flow control.

remoting__enableEvents virtual

virtual std::string remoting__enableEvents(
    Poco::RemotingNG::Listener::Ptr pListener,
    bool enable = bool (true)
);

remoting__enableRemoteEvents virtual

virtual void remoting__enableRemoteEvents(
    const std::string & protocol
);

remoting__hasEvents virtual

virtual bool remoting__hasEvents() const;

remoting__typeId virtual inline

virtual const Poco::RemotingNG::Identifiable::TypeId & remoting__typeId() const;

setFeature virtual inline

virtual void setFeature(
    const std::string & name,
    bool enable
);

Enables or disables the feature with the given name.

Which features are supported is defined by the actual device implementation.

setPropertyBool virtual inline

virtual void setPropertyBool(
    const std::string & name,
    bool value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyDouble virtual inline

virtual void setPropertyDouble(
    const std::string & name,
    double value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyInt virtual inline

virtual void setPropertyInt(
    const std::string & name,
    int value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyInt16 virtual inline

virtual void setPropertyInt16(
    const std::string & name,
    Poco::Int16 value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyInt64 virtual inline

virtual void setPropertyInt64(
    const std::string & name,
    Poco::Int64 value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyString virtual inline

virtual void setPropertyString(
    const std::string & name,
    const std::string & value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyTimestamp virtual inline

virtual void setPropertyTimestamp(
    const std::string & name,
    Poco::Timestamp value
);

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setRTS virtual inline

virtual void setRTS(
    bool status
);

Manually sets or clears RTS.

writeByte virtual inline

virtual void writeByte(
    Poco::UInt8 byte
);

Writes the given byte to the port.

writeString virtual inline

virtual void writeString(
    const std::string & data
);

Writes the given data to the port. Returns the number of characters written.

event__lineReceived protected

void event__lineReceived(
    const std::string & data
);

event__statusChanged protected

void event__statusChanged(
    const IoT::Devices::DeviceStatusChange & data
);

Securely control IoT edge devices from anywhere   Connect a Device