YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SerialDeviceDriver.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2007 Alexandre Bernardino
4 * SPDX-FileCopyrightText: 2007 Carlos Beltran-Gonzalez
5 * SPDX-FileCopyrightText: 2007 Francesco Giovannini
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef SerialDeviceDriverh
10#define SerialDeviceDriverh
11
14#include <yarp/os/Bottle.h>
15
16#include <stdio.h>
17
18#include <ace/DEV_Connector.h>
19#include <ace/TTY_IO.h>
20// In one the ACE headers there is a definition of "main" for WIN32
21# ifdef main
22# undef main
23# endif
24
25
26using namespace yarp::os;
27
29{
30public:
31 char CommChannel[100]; // Contains the name of the com port "COM1", "COM2" (windows) or "/etc/stty0", "/dev/stty1" (linux), etc...
32 ACE_TTY_IO::Serial_Params SerialParams;
68};
69
78{
79private:
81 void operator=(const SerialDeviceDriver&);
82
83 ACE_TTY_IO _serial_dev;
84 ACE_DEV_Connector _serialConnector;
85 bool verbose; // If enabled (1), the data sent/received by the serial device is print on screen
86 char line_terminator_char1;
87 char line_terminator_char2;
88
89public:
91
92 virtual ~SerialDeviceDriver();
93
94 bool open(yarp::os::Searchable& config) override;
95
101 bool open(SerialDeviceDriverSettings& config);
102
103 bool close() override;
104
110 bool send(const Bottle& msg) override;
111 bool send(const char *msg, size_t size) override;
112 //bool putMessage(Bottle& msg, bool waitreply, double replytimeout, Bottle& reply, char *replydelimiter, int replysize );
118 bool receive(Bottle& msg) override;
124 int receiveChar(char& chr) override;
125
132 int receiveBytes(unsigned char* bytes, const int size) override;
133
140 int receiveLine(char* line, const int MaxLineLength) override;
141
147 bool setDTR(bool value) override;
148
153 int flush() override;
154};
155
156#endif
ACE_TTY_IO::Serial_Params SerialParams
serialport: A basic Serial Communications Link (RS232, USB).
bool send(const Bottle &msg) override
Sends a string of chars to the serial communications channel.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
int receiveBytes(unsigned char *bytes, const int size) override
Gets an array of bytes (unsigned char) with size <= 'size' parameter.
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 receive(Bottle &msg) override
Gets the existing chars in the receive queue.
int flush() override
Flushes the internal buffer.
bool setDTR(bool value) override
Enable/Disable DTR protocol.
int receiveChar(char &chr) override
Gets one single char from the receive queue.
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 base class for nested structures that can be searched.
Definition Searchable.h:31
An interface to the operating system, including Port based communication.