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
2
votes
1 answer

Why does this serial communication code hang when talking to a USB-to-serial adapter?

I am writing an application that is supposed to control a projector from the desktop of a Mac Mini. I am writing the application in Objective-C using Xcode and termios.h to talk to the serial port. I am connecting from a USB-to-Serial adapter and I…
Stevezie
  • 111
  • 2
  • 11
2
votes
2 answers

writting 0D 0A insted of 0A when I tried to write into uart

The following code configures UART port. const char *UART2_path="/dev/ttymxc2"; int UART2; void UART2_open(const char *UART2_path) { int flags = O_RDWR | O_NOCTTY ; …
Rajesh D
  • 63
  • 3
2
votes
1 answer

"Inappropriate ioctl for device" from termios with pipes

I was working on a project yesterday and I came across an issue that I haven't encountered before. I'm current using argparse to ask for an input filename, and I'm adding support for piping a file via stdin to my program. I've got it all set up and…
Tabulate
  • 611
  • 6
  • 19
2
votes
3 answers

How to differentiate between Escape and Up/Down/Left/Right with termios?

GitHub This is the best I can come up with to handle ncurses-style key presses (I'm actually writing an alternative to ncurses for various reasons). An example app built with this code advises the user to "Quit by pressing Escape". In truth, it…
mcandre
  • 22,868
  • 20
  • 88
  • 147
2
votes
1 answer

Non canonical terminal mode buffer stdout in c program

I am working a school project (building a very basic shell). The idea is to be able to do line edition like in bash. For this, I change the terminal mode to non canonical and I stop echo. I made a very simple code to expose my issue (please note, I…
Bstorm
  • 247
  • 1
  • 10
2
votes
1 answer

How to open a tty device in noncanonical mode on Linux using .NET Core

I'm using .NET Core on an embedded Linux platform with good success so far. I just ran into a problem with trying to open a tty device in raw (noncanonical mode) though. If I was using regular C or C++ I would call cfmakeraw() after opening the…
snaddenm
  • 105
  • 7
2
votes
1 answer

Why does open()ing a Linux tty hang after killing a process which configured it?

I want to set a serial port in Linux to "raw" mode at 115200 baud. If I run the following program #include #include #include #include #include #include #include int…
AlexGP
  • 43
  • 1
  • 8
2
votes
1 answer

Ubuntu Serial Communication: reads failing and then coming in all at once

I'm writing a program that runs on a MIO-3260 single board computer running Ubuntu server 14.04 and communicates with a AMC DPRANIE C100A400 drive. The program sends a string of hex codes to the drive and is supposed to receive a response for every…
2
votes
2 answers

Serial read in C returning no data

I am using termios in C to write a simple program to write to a serial port and read the returned data. The communication with the device on the serial line terminates with a carriage return. The program is simple and currently looks like: #include…
cirrusio
  • 580
  • 5
  • 28
2
votes
1 answer

Should I reset termios settings on SIGINT/SIGTERM?

I was playing around with termios and I figured out quickly that if I change the terminal settings and exit, my changes will persist and screw up my environment. So I setup my program to save the initial settings with tcgetattr and reset them before…
Greg Schmit
  • 4,275
  • 2
  • 21
  • 36
2
votes
1 answer

How are terminal parameters restored by the shell on job control?

How is terminal state saved/restored when process is put in background and then in foreground again? I'm reading https://www.gnu.org/software/libc/manual/html_node/Foreground-and-Background.html which gave me idea that tcgetattr/tcsetattr are…
sc0ty
  • 193
  • 1
  • 7
2
votes
1 answer

Serial port read is not complete

The functions below are used consequently to read data from serial port under Linux. I can read the complete data when I debug, but when I launch the program, read_buffer seems not to be complete. I receive the small part of the data correctly but…
sanchop22
  • 2,729
  • 12
  • 43
  • 66
2
votes
1 answer

Implementing a KeyPress Event in C with Multiple Threads

My goal: A thread will wait (busy loop not sleep) until a specific key (lets say 0) is pressed. Each thread has a different key that will trigger that thread to get out of waiting and progress through the commands that follow the wait. I have tried…
user3913218
  • 77
  • 1
  • 2
  • 6
2
votes
1 answer

CUSE - return proper IOCTL for termios.tcgetattr()

I try to use libfuse (cuse) to create character device and play on it like with regular tty, all is fine till I use tcgetattr. Unfortunately, termios.tcgetattr() always raise I/O error. cusetest.c #define FUSE_USE_VERSION 29 #define…
MrHetii
  • 1,315
  • 10
  • 12
2
votes
1 answer

Using tcdrain along with termios2

I want to use tcdrain with termios2. The problem is the method is defined in termios.h, but not in asm/termbits.h. It is not possible to use termios.h with asm/termbits.h together as there would have compilation errors as some of the structs are…
Kong Chun Ho
  • 268
  • 4
  • 14