nidas v1.2.3
SerialPortIODevice.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2011, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26#ifndef NIDAS_CORE_SERIALPORTIODEVICE_H
27#define NIDAS_CORE_SERIALPORTIODEVICE_H
28
29#include "UnixIODevice.h"
30#include <nidas/util/Termios.h>
32
33#include <sys/types.h>
34#include <sys/stat.h>
35#include <fcntl.h>
36#include <sys/ioctl.h>
37
38#ifdef DEBUG
39#include <iostream>
40#endif
41
42namespace nidas { namespace core {
43
48
49public:
50
61
66 SerialPortIODevice(const std::string& name):
68 {
69 _termios.setRaw(true);
72 }
73
78
84 void open(int flags);
85
92 {
94 }
95
97
120 int getUsecsPerByte() const;
121
170 void setRTS485(int val);
171
177 size_t write(const void *buf, size_t len);
178
179protected:
180
182
184
185 unsigned int _usecsperbyte;
186
187};
188
189}} // namespace nidas namespace core
190
191#endif
virtual const std::string & getName() const
Definition IODevice.h:57
A serial port.
Definition SerialPortIODevice.h:47
void applyTermios()
Apply the current Termios to an opened port.
Definition SerialPortIODevice.h:91
int getUsecsPerByte() const
Calculate the transmission time of each byte from this serial port.
Definition SerialPortIODevice.cc:70
size_t write(const void *buf, size_t len)
Write to the device.
Definition SerialPortIODevice.cc:110
nidas::util::Termios _termios
Definition SerialPortIODevice.h:181
void open(int flags)
open the device.
Definition SerialPortIODevice.cc:45
void setRTS485(int val)
Is this a RS485 half-duplex device, and if so, can the transmitter on the data system be enabled/disa...
Definition SerialPortIODevice.cc:88
SerialPortIODevice(const std::string &name)
Constructor, passing the name of the device.
Definition SerialPortIODevice.h:66
nidas::util::Termios & termios()
Definition SerialPortIODevice.h:96
int _rts485
Definition SerialPortIODevice.h:183
unsigned int _usecsperbyte
Definition SerialPortIODevice.h:185
~SerialPortIODevice()
Destructor.
Definition SerialPortIODevice.h:77
SerialPortIODevice()
Constructor.
Definition SerialPortIODevice.h:54
A basic Unix I/O device, such as a named pipe, or a watched file.
Definition UnixIODevice.h:49
int _fd
Definition UnixIODevice.h:161
A class providing get/set methods into a termios structure.
Definition Termios.h:48
void apply(int fd, const std::string &devname)
Set the termios options on a serial port.
Definition Termios.cc:104
void setRawTimeout(unsigned char val)
Definition Termios.cc:349
void setRaw(bool val)
Sets termios options for raw or non-raw(cooked) mode.
Definition Termios.cc:307
void setRawLength(unsigned char val)
Definition Termios.cc:342
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948