Cheetah Software  1.0
rt_serial.cpp File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <asm/termios.h>
#include <termios.h>
#include <math.h>
#include <pthread.h>
#include <stropts.h>
#include <endian.h>
#include <stdint.h>
#include <rt/rt_serial.h>
+ Include dependency graph for rt_serial.cpp:

Go to the source code of this file.

Macros

#define termios   asmtermios
 

Functions

int set_interface_attribs_custom_baud (int fd, int speed, int parity, int port)
 Configure serial port. More...
 

Macro Definition Documentation

#define termios   asmtermios

Definition at line 12 of file rt_serial.cpp.

Function Documentation

int set_interface_attribs_custom_baud ( int  fd,
int  speed,
int  parity,
int  port 
)

Configure serial port.

Parameters
fdSerial port FD
speedBaud rate
parityParity
portPort number

Definition at line 40 of file rt_serial.cpp.

40  {
41  (void)parity;
42  (void)port;
43 
44  printf("\t[RT SERIAL] Configuring serial device...\n");
45  struct termios2 tty;
46 
47  ioctl(fd, TCGETS2, &tty);
48  tty.c_cflag &= ~CBAUD;
49  tty.c_cflag |= BOTHER;
50  tty.c_ispeed = speed;
51  tty.c_ospeed = speed;
52 
53  tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
54  // disable IGNBRK for mismatched speed tests; otherwise receive break
55  // as \000 chars
56  tty.c_iflag &= ~IGNBRK; // disable break processing
57  tty.c_lflag = 0; // no signaling chars, no echo,
58  // no canonical processing
59  tty.c_oflag = 0; // no remapping, no delays
60  tty.c_cc[VMIN] = 0; // read doesn't block
61  tty.c_cc[VTIME] = 1; // 0.5 seconds read timeout
62 
63  tty.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl
64 
65  tty.c_cflag |= (CLOCAL | CREAD); // ignore modem controls,
66  // enable reading
67  // tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
68  tty.c_cflag |= PARENB;
69  tty.c_cflag &= ~CSTOPB;
70  tty.c_cflag &= ~CRTSCTS;
71  // cfmakeraw(&tty);
72 
73  ioctl(fd, TCSETS2, &tty);
74  return 0;
75 }

+ Here is the caller graph for this function: