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

Disable DSUSP in Python

An OSX user submitted a bug that CTRL+Y causes a python terminal application to be suspended, via dsusp causing SIGTSTP to be sent when the Python program tried to read on stdin. The code below to solves the problem: (context) import sys import…
Thomas
  • 6,515
  • 1
  • 31
  • 47
4
votes
0 answers

ioctl complains a tty device is not a tty device

I am writing a program to open, setup, and write to a tty for rs485. I have played a bit with the tty device, and now I can't seem to open it anymore. Here is the relevant code: int rs485_enable(const char *dev_name, const speed_t speed) { int…
Gauthier
  • 40,309
  • 11
  • 63
  • 97
3
votes
1 answer

Porting POSIX C code to windows

I just finished a small project written in C, where I read a data stream from a serial port and parse the incoming data. The software is written for POSIX systems (using termios) and follows the standard steps to working with serial i/o Opening the…
bing
  • 443
  • 6
  • 11
3
votes
0 answers

Pynput prints entered keys when Keyboard Listener finishes

This has been keeping me up quite a bit. When using the Python pynput module with keyboard.Listener, whatever is typed whilst the keyboard is listening is printed out in Terminal after the keyboard Listener has stopped. I've tried…
3
votes
1 answer

How to use Termios to send bytes over a socat data transfer loop

I am trying to write a simple program that sends bytes over a serial connection. I created a data transfer loop using socat as follows: $ socat -d -d pty pty This creates a data transfer loop between /dev/pts/2 and /dev/pts/0. When I try to use…
3
votes
0 answers

python: Terminal input, echo all except newline, and handle backspace?

I'm trying to write a function in Python-3.x which will prompt the user to enter characters from the keyboard. I want all characters to be echoed normally except for the final newline, which terminates the input. The following function does this…
HippoMan
  • 2,119
  • 2
  • 25
  • 48
3
votes
2 answers

Failed to configure device ttyUSB0 (Arduino) on Ubuntu, C++

I can open serial port, but I can't correctly configure this port for write (/dev/ttyUSB0). Piece of code C++: int Platform::initConnection( const char* devicePath, int baudRate ) { int fd = 0; int ret = 0; struct termios…
Marat Gareev
  • 387
  • 1
  • 4
  • 16
3
votes
0 answers

Ubuntu C++ termios.h example program

I searched a lot and tried many different ways, but I cannot send data to gtkterm via virtual serial bridge (for testing!). My idea is to communicate with an Atmega uC later on, but first I wanted to test the serial communication by setting up a…
T_Born
  • 31
  • 1
  • 2
3
votes
2 answers

struct termios setting for serial communication with arduino

on a unix based software, which must send a number between 0 and 179 to arduino and arduino will apply that number as an angle to a servo motor, but i do not know what parameters i have to change in the terminos struct to permit the serial…
Dadda Barba
  • 145
  • 2
  • 9
3
votes
4 answers

Manually Call a C++ Object's Initializer in C

I am working on a small application that was written in C++ and would like to use on my platform. Unfortunately, our cross-compile toolchain only (reliably) provides a C compiler. I looked at the application, and it is fairly simple and only uses…
Woodrow Barlow
  • 8,477
  • 3
  • 48
  • 86
3
votes
1 answer

Raspberry Pi UART program in C using termios receives garbage (Rx and Tx are connected directly)

I have a simple program written in C which uses termios to send a basic string to the Raspberry Pi UART and attempts to read and output the response. The Rx and Tx pins on the Raspberry Pi are connected with a jumper so whatever is sent should be…
kourosh
  • 41
  • 1
  • 2
  • 3
3
votes
0 answers

tcsetattr() fails

&"warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device\n" bool rs485::rs485ConfigPort() { termios portSettings; memset(&portSettings, 0, sizeof(portSettings)); portSettings.c_cflag |=…
Sam
  • 813
  • 2
  • 16
  • 30
3
votes
3 answers

Linux Terminal Problem with Non-Canonical Terminal I/O app

I have a small app written in C designed to run on Linux. Part of the app accepts user-input from the keyboard, and it uses non-canonical terminal mode so that it can respond to each keystroke. The section of code that accepts input is a simple…
Charles Salvia
3
votes
3 answers

How to get around no backspace when ICANON in non-canonical

I am using termios as suggested in a previous question I asked but now am asking if there is a way get backspace to work whilst using termios in non-canonical mode. I am using termios to have not have an echo If I use &=ECHO and &=ICANON this is the…
UNECS
  • 533
  • 1
  • 9
  • 20
2
votes
1 answer

How to unplug a USB device under Ubuntu and C/C++ without rebooting

I'm using a C program with termios to exchange information and commands between my pc with Ubuntu and a USB motor controller. It works great and i'm able to successfully send messages over the serial port; however, sometimes it happens that if i…
Marcus Barnet
  • 2,083
  • 6
  • 28
  • 36
1 2
3
20 21