LTPS C++ API
Cuart.h
1 
5 
6 #ifndef __CUART_H__
7 #define __CUART_H__
8 
9 #include <unistd.h>
10 #include <string.h>
11 #include <stdint.h>
12 
13 #include <termios.h>
14 #include <linux/serial.h>
15 #include <sys/ioctl.h>
16 
17 #define SER_RS422_ENABLED (SER_RS485_ENABLED << 5)
18 
19 enum CuartMode_t {
20  CuartMode232,
21  CuartMode422,
22  CuartMode485,
23 };
24 
26 class Cuart {
27 
28 private:
29 
30 protected:
31 
32 public:
33 
35 
38  static void termios_def( struct termios &_termios);
39 
44  inline static int termios_get( int _fd, struct termios &_termios) {
45  return( tcgetattr( _fd, &_termios)); }
46  inline static int termios_set( int _fd, struct termios &_termios) {
47  return( tcsetattr( _fd, TCSANOW, &_termios)); }
49 
50 
52  // http://retis.sssup.it/~scordino/code/serial-rs485.txt
53 
55  static void mode_def( struct serial_rs485 &_c, CuartMode_t _m);
56 
61  inline static int mode_set( int _fd, struct serial_rs485 &_c) {
62  return( ioctl( _fd, TIOCSRS485, &_c)); }
63  inline static int mode_get( int _fd, struct serial_rs485 &_c) {
64  return( ioctl( _fd, TIOCGRS485, &_c)); }
66 
67 }; // class /
68 
69 #endif
static void mode_def(struct serial_rs485 &_c, CuartMode_t _m)
Helps to define struct serial_rs485 fields for mode ...
static int termios_get(int _fd, struct termios &_termios)
Definition: Cuart.h:44
static void termios_def(struct termios &_termios)
static int mode_set(int _fd, struct serial_rs485 &_c)
Definition: Cuart.h:61
UART base setup functions.
Definition: Cuart.h:26