Questions tagged [termios]

Termios is Unix API for terminal I/O.

The anatomy of a program performing serial I/O with the help of termios is as follows:

  • Open serial device with standard Unix system call open(2)

  • Configure communication parameters and other interface properties (line discipline, etc.) with the help of specific termios functions and data structures.

  • Use standard Unix system calls read(2) and write(2) for reading from, and writing to the serial interface. Related system calls like readv(2) and writev(2) can be used, too. Multiple I/O techniques, like blocking, non-blocking, asynchronous I/O (select(2) or poll(2)) or signal-drive I/O (SIGIO signal) are also possible.

  • Close device with the standard Unix system call close(2) when done.

309 questions
1
vote
1 answer

How do I open a ttyMFD device on the Intel-Edison [C++]?

I have a /dev/ttyUSB device and a /dev/ttyMFD device that I need to stream to logfiles. For the USB device I could use termios and configure it through that. This was pretty straight forward and there was a bit of documentation for this as well. I…
Tropical_Peach
  • 1,143
  • 3
  • 16
  • 29
1
vote
1 answer

Hardware flow control with termios (CRTSCTS) for UART Device

right now I'm communicating with a device over UART in C++ on a Udoo Neo. For this I'm using termios to set up the connection and write data to the device. For this purpose I want to use hardware flow control and have set the flag (CRTSCTS) with…
Dingodoodl
  • 21
  • 1
  • 4
1
vote
1 answer

forkpty works for some terminal apps, not for others

I'm trying to write a pty I/O transparent filter for a shell. The following example mostly works. Most programs run as expected with the wrapper. This example does not do any filtering, it's purpose is just to provide a framework. EDIT: With my…
bogen
  • 21
  • 5
1
vote
1 answer

Read multi-character keyboard strokes

I have a script to read and handle keyboard strokes within python. This works perfectly fine for me for standard keys which send one byte to stdin. I cannot find a reasonable way to read keystrokes that produce a multi-byte ansi escape code. What…
amicitas
  • 13,053
  • 5
  • 38
  • 50
1
vote
2 answers

Linux set higher baud rate and associated settings

Input hardware: BeagleBone Black, with some GNU/Linux distro running on it. What I want to achieve: I want to set some UART peripheral to 921600 baud value, and be able to set the other serial-associated settings (e.g. start/stop bits, parity, data…
mariusmmg2
  • 713
  • 18
  • 37
1
vote
1 answer

Some times serial port read giving converted values [ Junk values]

configuring the serial port is given below // open serial port /* O_RDWR means that the port is opened for both reading and writing * O_NOCTTY means that no terminal will control the process opening the serial port */ fd = open(MODEMDEVICE,…
tharunkumar
  • 2,801
  • 1
  • 16
  • 19
1
vote
1 answer

Cannot configure TERMIOS in SOCAT, xioinitialize: Assertion

I am using SOCAT 1.7.2.4 from Yocto with PowerPC as target (Big Endian) on a Linux machine. Not able to start SOCAT as I am getting the below assertion xioinitialize.c:45: xioinitialize: Assertion `3 << opt_crdly.arg3 == 00030000' failed. I…
Neo
  • 141
  • 5
  • 16
1
vote
0 answers

Arrow navigation input in C

I am creating a shell interface for a program, at first I used getline combined with strtok to split user entry, but it's not a great choice because if a quoted string is passed it will be splitted in several argument, or if spaces are present in a…
1
vote
1 answer

my linux C program cannot receive data from Arduino through USB Serial

My Linux C application cannot receive bytes from Arduino Hi all, I intend to use Arduino Mega 2560 as a programmer for AT89S52 (a family of 8051 microprocessor). The Arduino board connects to PC via USB Serial cable. At first I need to write a…
Huy Dang
  • 11
  • 4
1
vote
1 answer

Injecting unicode characters via termios.TIOCSTI

I have a piece of python code that injects entries from the bash history into the command prompt. Everything worked perfectly until I switched to Python 3. Now German Umlaute appear wrong. eg. python3 console_test.py mööp results in: $ m� Here's…
Vindolin
  • 827
  • 8
  • 12
1
vote
1 answer

read changes stdout from unbuffered to line buffered in canonical mode

When I use this piece of code in canonical mode: #include #include #include static struct termios newt; static struct termios oldt; static void kb_fini(void) { tcsetattr(STDIN_FILENO, TCSANOW, &oldt); } void…
David Ranieri
  • 39,972
  • 7
  • 52
  • 94
1
vote
1 answer

Capture ESCAPE key using termios under OSX

I am trying to capture ESC key (ASCII 27) on a OSX terminal or xterm using kbhit to distinguish a real Escape from Arrow keys: #include #include #include static struct termios newt; static struct termios…
David Ranieri
  • 39,972
  • 7
  • 52
  • 94
1
vote
0 answers

C++ How to implement timeout in serial canonical communications

I´m using ubuntu as host, and C++ as language. I´m communicating to a serial device that uses line by line commands. For that purpose I opted for a canonical mode of operation and my termios flags are: fd = open(portName.c_str(), O_RDWR | O_NOCTTY |…
Mendes
  • 17,489
  • 35
  • 150
  • 263
1
vote
1 answer

confused about termios.h constants

test.c... #include #include int main() { printf("%x\n",B600); } On my system this prints "8". gcc -M test.c shows /usr/include/stdc-predef.h /usr/include/termios.h \ /usr/include/features.h…
freak
  • 13
  • 4
1
vote
0 answers

How to make the termios read() return after the VTIME value?

I do have open a native serial port on linux using termios. The port is opened in blocking mode and with the settings VMIN = 10 and VTIME = 5. I thought this should mean the blocking read function is returning after half a second if the timeout…
p0fi
  • 1,056
  • 12
  • 28