YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SerialPort_nwc_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_NWC_H
7#define YARP_DEV_SERIALPORT_NWC_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 "ISerialMsgs.h"
21
23
24using namespace yarp::os;
25using namespace yarp::sig;
26using namespace yarp::dev;
27
39{
40private:
41 ISerialMsgs m_rpc;
42 yarp::os::Port m_rpcPort;
43 yarp::os::Port m_sendPort;
44 yarp::os::Port m_receivePort;
45
46 bool closeMain()
47 {
48 m_rpcPort.close();
49 m_sendPort.close();
50 m_receivePort.close();
51 return true;
52 }
53
54public:
60 ~SerialPort_nwc_yarp() override;
61
62 // ISerialDevice methods
63 bool send(const Bottle& msg) override;
64 bool send(const char *msg, size_t size) override;
65 bool receive(Bottle& msg) override;
66 int receiveChar(char& c) override;
67 int flush () override;
68 int receiveLine(char* line, const int MaxLineLength) override;
69 int receiveBytes(unsigned char* bytes, const int size) override;
70 bool setDTR(bool enable) override;
71 bool close() override;
72 bool open(Searchable& prop) override;
73
74};
75
76#endif // YARP_DEV_SERVERSERIAL_H
This class is the parameters parser for class SerialPort_nwc_yarp.
serialPort_nwc_yarp: a client for a serialPort_nws_yarp device
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.
SerialPort_nwc_yarp(SerialPort_nwc_yarp &&)=delete
SerialPort_nwc_yarp & operator=(SerialPort_nwc_yarp &&)=delete
SerialPort_nwc_yarp(const SerialPort_nwc_yarp &)=delete
SerialPort_nwc_yarp & operator=(const SerialPort_nwc_yarp &)=delete
bool close() override
Close the DeviceDriver.
int receiveChar(char &c) override
Gets one single char from the receive queue.
int flush() override
Flushes the internal buffer.
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.
bool open(Searchable &prop) override
Open the DeviceDriver.
bool setDTR(bool enable) override
Enable/Disable DTR protocol.
SerialPort_nwc_yarp()=default
Interface implemented by all device drivers.
A generic interface to serial port devices.
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.
A mini-server for network communication.
Definition Port.h:46
void close() override
Stop port activity.
Definition Port.cpp:363
A base class for nested structures that can be searched.
Definition Searchable.h:31
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.