Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpSerial.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Serial communication.
32
*/
33
34
#ifndef VP_SERIAL_H
35
#define VP_SERIAL_H
36
37
#if !defined(_WIN32)
38
39
#include <stdint.h>
40
#include <string>
41
42
#include <visp3/core/vpConfig.h>
43
44
BEGIN_VISP_NAMESPACE
70
class
VISP_EXPORT
vpSerial
71
{
72
public
:
76
typedef
enum
77
{
78
fivebits
= 5,
79
sixbits
= 6,
80
sevenbits
= 7,
81
eightbits
= 8
82
} bytesize_t;
83
87
typedef
enum
88
{
89
parity_none
= 0,
90
parity_odd
= 1,
91
parity_even
= 2
92
} parity_t;
93
97
typedef
enum
98
{
99
stopbits_one
= 1,
100
stopbits_two
= 2,
101
} stopbits_t;
102
106
typedef
enum
107
{
108
flowcontrol_none
= 0,
109
flowcontrol_software
,
110
flowcontrol_hardware
111
} flowcontrol_t;
112
113
vpSerial
(
const
std::string &port =
""
,
unsigned
long
baudrate = 9600, bytesize_t bytesize = eightbits,
114
parity_t parity = parity_none, stopbits_t stopbits = stopbits_one,
115
flowcontrol_t flowcontrol = flowcontrol_none);
116
virtual
~vpSerial
();
117
118
int
available();
119
void
close();
120
125
unsigned
long
getBaudrate
() {
return
m_baudrate; }
126
131
bytesize_t
getBytesize
() {
return
m_bytesize; }
132
137
flowcontrol_t
getFlowcontrol
() {
return
m_flowcontrol; }
138
143
parity_t
getParity
() {
return
m_parity; }
144
149
std::string
getPort
() {
return
m_port; }
150
155
stopbits_t
getStopbits
() {
return
m_stopbits; }
156
157
void
open();
158
bool
read(
char
*c,
long
timeout_s);
159
std::string readline(
const
std::string &eol);
160
void
setBaudrate(
const
unsigned
long
baudrate);
161
void
setBytesize(
const
bytesize_t &bytesize);
162
void
setFlowcontrol(
const
flowcontrol_t &flowcontrol);
163
void
setParity(
const
parity_t &parity);
164
void
setPort(
const
std::string &port);
165
void
setStopbits(
const
stopbits_t &stopbits);
166
void
write(
const
std::string &s);
167
168
private
:
169
void
configure();
170
171
std::string m_port;
172
int
m_fd;
173
174
bool
m_is_open;
175
bool
m_xonxoff;
176
bool
m_rtscts;
177
178
unsigned
long
m_baudrate;
179
180
parity_t m_parity;
181
bytesize_t m_bytesize;
182
stopbits_t m_stopbits;
183
flowcontrol_t m_flowcontrol;
184
};
185
END_VISP_NAMESPACE
186
#endif
187
#endif
vpSerial
Definition
vpSerial.h:71
vpSerial::getStopbits
stopbits_t getStopbits()
Definition
vpSerial.h:155
vpSerial::flowcontrol_t
flowcontrol_t
Definition
vpSerial.h:107
vpSerial::flowcontrol_software
@ flowcontrol_software
Software flow control.
Definition
vpSerial.h:109
vpSerial::flowcontrol_none
@ flowcontrol_none
No flow control.
Definition
vpSerial.h:108
vpSerial::flowcontrol_hardware
@ flowcontrol_hardware
Hardware flow control.
Definition
vpSerial.h:110
vpSerial::getBytesize
bytesize_t getBytesize()
Definition
vpSerial.h:131
vpSerial::parity_t
parity_t
Definition
vpSerial.h:88
vpSerial::parity_odd
@ parity_odd
Check for odd parity.
Definition
vpSerial.h:90
vpSerial::parity_none
@ parity_none
No parity check.
Definition
vpSerial.h:89
vpSerial::parity_even
@ parity_even
Check for even parity.
Definition
vpSerial.h:91
vpSerial::getBaudrate
unsigned long getBaudrate()
Definition
vpSerial.h:125
vpSerial::stopbits_t
stopbits_t
Definition
vpSerial.h:98
vpSerial::stopbits_two
@ stopbits_two
2 stop bits are used
Definition
vpSerial.h:100
vpSerial::stopbits_one
@ stopbits_one
1 stop bit is used
Definition
vpSerial.h:99
vpSerial::getPort
std::string getPort()
Definition
vpSerial.h:149
vpSerial::vpSerial
vpSerial(const std::string &port="", unsigned long baudrate=9600, bytesize_t bytesize=eightbits, parity_t parity=parity_none, stopbits_t stopbits=stopbits_one, flowcontrol_t flowcontrol=flowcontrol_none)
Definition
vpSerial.cpp:104
vpSerial::getFlowcontrol
flowcontrol_t getFlowcontrol()
Definition
vpSerial.h:137
vpSerial::bytesize_t
bytesize_t
Definition
vpSerial.h:77
vpSerial::eightbits
@ eightbits
Data is encoded with 8 bits.
Definition
vpSerial.h:81
vpSerial::fivebits
@ fivebits
Data is encoded with 5 bits.
Definition
vpSerial.h:78
vpSerial::sevenbits
@ sevenbits
Data is encoded with 7 bits.
Definition
vpSerial.h:80
vpSerial::sixbits
@ sixbits
Data is encoded with 6 bits.
Definition
vpSerial.h:79
vpSerial::getParity
parity_t getParity()
Definition
vpSerial.h:143
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
core
include
visp3
core
vpSerial.h
Generated by
1.17.0