25 yCDebug(SERVERSERIAL,
"std::string to send : %s", msg.
toString().c_str());
27 if(serial !=
nullptr) {
38 yCDebug(SERVERSERIAL,
"std::string to send : %s", msg);
40 if(serial !=
nullptr) {
41 serial->
send(msg, size);
50 if(serial !=
nullptr) {
60 if(serial !=
nullptr) {
69 if(serial !=
nullptr) {
70 return serial->
flush();
78 if (serial !=
nullptr) {
79 return serial->
setDTR(enable);
87 if(serial !=
nullptr) {
96 if (serial !=
nullptr) {
113 verb = (prop.
check(
"verbose",
Value(0),
"Specifies if the device is in verbose mode (0/1).").asInt32())>0;
115 yCInfo(SERVERSERIAL,
"running with verbose output");
119 if (prop.
check(
"subdevice",name,
"name of specific control device to wrap")) {
124 p.setMonitor(prop.getMonitor(),
131 poly.
open(subdevice);
137 yCError(SERVERSERIAL,
"\"--subdevice <name>\" not set for serial");
145 std::string rootName =
147 "prefix for port names").asString();
149 command_buffer.
attach(toDevice);
150 reply_buffer.
attach(fromDevice);
154 toDevice.
open(rootName+
"/in");
155 fromDevice.
open(rootName+
"/out");
162 if(serial !=
nullptr) {
167 yCError(SERVERSERIAL,
"subdevice <%s> doesn't look like a serial port (no appropriate interfaces were acquired)",
174 yCInfo(SERVERSERIAL,
"Server Serial starting");
182 reply_buffer.
write();
187 yCInfo(SERVERSERIAL,
"Server Serial stopping");
198 yCError(SERVERSERIAL,
"Could not get serial device");
210 yCError(SERVERSERIAL,
"Problems while trying to send data");
ImplementCallbackHelper2()
Constructor.
yarp::dev::ISerialDevice * ser
void onRead(Bottle &b) override
Callback function.
serial: Export a serial sensor.
void run() override
The thread main loop deals with writing on ports here.
bool close() override
Close the device driver by deallocating all resources and closing ports.
bool setDTR(bool enable) override
Enable/Disable DTR protocol.
virtual bool open()
Default open() method.
int receiveBytes(unsigned char *bytes, const int size) override
Gets an array of bytes (unsigned char) with size <= 'size' parameter.
bool receive(Bottle &msg) override
Gets the existing chars in the receive queue.
int receiveChar(char &c) override
Gets one single char from the receive queue.
int receiveLine(char *line, const int MaxLineLength) override
Gets one line (a sequence of chars with a ending '\n' or '\r') from the receive queue.
bool send(const Bottle &msg) override
Sends a string of chars to the serial communications channel.
int flush() override
Flushes the internal buffer.
bool view(T *&x)
Get an interface to the device driver.
A generic interface to serial port devices.
virtual int receiveLine(char *line, const int MaxLineLength)=0
Gets one line (a sequence of chars with a ending '\n' or '\r') from the receive queue.
virtual bool setDTR(bool enable)=0
Enable/Disable DTR protocol.
virtual int flush()=0
Flushes the internal buffer.
virtual bool send(const yarp::os::Bottle &msg)=0
Sends a string of chars to the serial communications channel.
virtual int receiveChar(char &chr)=0
Gets one single char from the receive queue.
virtual bool receive(yarp::os::Bottle &msg)=0
Gets the existing chars in the receive queue.
virtual int receiveBytes(unsigned char *bytes, const int size)=0
Gets an array of bytes (unsigned char) with size <= 'size' parameter.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A simple collection of objects that can be described and transmitted in a portable way.
Bottle tail() const
Get all but the first element of a bottle.
void clear()
Empties the bottle of any objects it contains.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
void attach(Port &port)
Attach this buffer to a particular port.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
void write(bool forceStrict=false)
Try to write the last buffer returned by PortWriterBuffer::get.
T & get()
A synonym of PortWriterBuffer::prepare.
void attach(Port &port)
Set the Port to which objects will be written.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
static void delaySystem(double seconds)
bool isStopping()
Returns true if the thread is stopping (Thread::stop has been called).
bool start()
Start the new thread running.
A single value (typically within a Bottle).
virtual bool isString() const
Checks if value is a string.
std::string toString() const override
Return a standard text representation of the content of the object.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)