YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SerialPort_nws_yarp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_SERIALPORT_NWS_YARP_H
7#define YARP_DEV_SERIALPORT_NWS_YARP_H
8
9#include <cstdio>
10#include <cstdlib>
11
13#include <yarp/dev/PolyDriver.h>
15#include <yarp/os/Time.h>
16#include <yarp/os/Network.h>
17#include <yarp/os/Thread.h>
18#include <yarp/os/Vocab.h>
19#include <yarp/os/Bottle.h>
20#include <yarp/os/RpcServer.h>
22#include "ISerialMsgs.h"
23
25
26using namespace yarp::os;
27using namespace yarp::sig;
28using namespace yarp::dev;
29
31
49
51{
52private:
53 std::mutex m_mutex;
54 yarp::dev::ISerialDevice* m_iser = nullptr;
55
56public:
57 bool setDTR(bool enable) override;
58 int flush() override;
59
60public:
62 std::mutex* getMutex() { return &m_mutex; }
63};
64
80 public yarp::os::Thread,
84{
85private:
86 yarp::dev::ISerialDevice* m_iserial{ nullptr };
87 yarp::os::Port toDevice;
88 yarp::os::Port fromDevice;
89 yarp::os::Port m_rpcPort;
90 ISerialMsgsd m_rpc;
91
94 ImplementCallbackHelper2* callback_impl{ nullptr };
95
96 // yarp::dev::IWrapper
97 bool attach(yarp::dev::PolyDriver* deviceToAttach) override;
98 bool detach() override;
99
100private:
101 bool receive(Bottle& msg);
102 int receiveChar(char& c);
103 bool closeMain();
104
105public:
111 virtual ~SerialPort_nws_yarp() override;
112
113 bool open(yarp::os::Searchable& config) override;
114 bool close() override;
116 void run() override;
117};
118
119#endif // YARP_DEV_SERIALPORT_NWS_YARP_H
void setInterfaces(yarp::dev::ISerialDevice *iser)
int flush() override
std::mutex * getMutex()
bool setDTR(bool enable) override
Callback implementation after buffered input.
yarp::dev::ISerialDevice * m_iser
virtual ~ImplementCallbackHelper2() override
void onRead(Bottle &b) override
Callback method.
This class is the parameters parser for class SerialPort_nws_yarp.
serialPort_nws_yarp: Export a serial sensor.
virtual ~SerialPort_nws_yarp() override
void run() override
Main body of the new thread.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
SerialPort_nws_yarp(SerialPort_nws_yarp &&)=delete
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
SerialPort_nws_yarp(const SerialPort_nws_yarp &)=delete
SerialPort_nws_yarp()=default
SerialPort_nws_yarp & operator=(const SerialPort_nws_yarp &)=delete
SerialPort_nws_yarp & operator=(SerialPort_nws_yarp &&)=delete
Interface implemented by all device drivers.
A generic interface to serial port devices.
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a thread of execution.
Definition Thread.h:21
A callback for typed data from a port.
For streams capable of holding different kinds of content, check what they actually have.
Definition jointData.cpp:13
An interface to the operating system, including Port based communication.