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
0 answers

Termios configuration

In a MAC OS X (10.10) program, I have a hard time setting up termios correctly for RS-485 serial communication (I use a starcom USB → RS-485 featuring the FTDI chip) I need to set up the following: 1 Start bit (0 bit) 8 Databits 1 Odd parity bit…
Adeline
  • 465
  • 5
  • 16
1
vote
0 answers

Linux termios.h: incoming bytes can only be read after \n

I'm trying to write a C program in linux that interacts with serialports. The program got 2 threads, one main wich writes and a listening thread. My problem is in the listening thread. I want the read function to read the raw data right after a…
Tac0
  • 21
  • 1
  • 7
1
vote
1 answer

Trouble in setting DTR RTS pins of serial port using ioctl() Call in linux

Hi i am writing a small code to control the DTR and RTS lines of USB to Serial port Converter chip FT232 on Linux (Mint Linux 13 Maya,x86). I have successfully wrote code to read and write data to the FT232 chip using termios. Now i want to control…
rohkumarj
  • 27
  • 1
  • 4
1
vote
1 answer

Serial I/O in C with termios: unreliable output capitalization

I have a very small C program which sends and receives newline-terminated ASCII strings to and from a serial device. It's plugged into my computer with a USB adapter, on /dev/ttyUSB0. Most of the time it sends the commands just find, but…
Eric Dand
  • 1,106
  • 13
  • 37
1
vote
2 answers

Linux termios parameter interpretation

I have been trying to set up a serial port on an Olimex A13 machine with the Linux (Debian Wheezy) operating system. To set up the parameters to set up the UART I am using the termios structure. In my case I am simply setting a parameter = value…
mikenycz
  • 81
  • 1
  • 1
  • 5
1
vote
2 answers

Serial Programming: Sender and Receiver

So I am using two Xbee ZB (S2B) in a project to transmit data from one to another. It is a 8 data bit, no parity, 1 stop bit system (8N1). I have two questions. 1. Since I am interfacing with an RS232 (DB9 connector) interface to USB adapter on my…
M B
  • 41
  • 5
1
vote
0 answers

Using SOCAT for serial communication to USB on Linux

I'd like a little clarification on what socat does to the serial communication, because for some reason I can only get the communication to my Arduino to work when using socat. This is the command I use to set up socat: socat -d -v -x…
user2744971
  • 123
  • 1
  • 2
  • 8
1
vote
0 answers

Serial port configuration not working after forking

I have written a program that can execute in foreground or background. The program uses a serial port to communicate. If I start it in foreground (i.e. it does not fork) everything runs fine. If I start it as daemon from the command line everything…
felix
  • 61
  • 7
1
vote
1 answer

run a program with tcsetattr raw mode in background

I need to run a program as is in the background. The catch is that the program does a tcsetattr() call and sets the raw mode as following : struct termios tio; if (tcgetattr(fileno(stdin), &tio) == -1) { perror("tcgetattr"); …
Smash
  • 839
  • 1
  • 9
  • 10
1
vote
2 answers

C & Linux: Waiting for when a file has been written to

I'm currently working on a project that will read data from a micro-controller via serial communications. As of right now, the program (on my computer), opens a /dev/tty* file and is able to read/write to it. The micro-controller will send a packet…
Benjamin
  • 1,223
  • 1
  • 13
  • 22
1
vote
1 answer

C termios and printf issue

I'm using Lubuntu with LXterminal. I have (somewhat) unashamedly copied the basis for this code from a stack overflow answer that gives details on c non-blocking keyboard input. This is the first part: #include #include #include…
Blue Ice
  • 7,888
  • 6
  • 32
  • 52
1
vote
1 answer

terminal prompt is distorted and unreadable

I am new to the linux programming. I followed example on the web to read/write to console e.g., "/dev/ttyS0". Each time I run the code, it exits without prompting user to write the input. It also distorts the terminal prompt (newline) and I am…
iamauser
  • 11,119
  • 5
  • 34
  • 52
1
vote
0 answers

termios messing up stdout in terminal after exiting although old attributes are reset

I'm using termios in a serial logging application, the application reads the serial port and saves data in a file. It also accepts inputs from standard input and sends it to the serial port. The problem is that once the application exits (by…
big_mu5
  • 103
  • 1
  • 9
1
vote
0 answers

storage size not constant when using offsetof and including termios.h with android ndk

I encounter a strange error when compiling this #include #include struct Test { int a; int b; }; void test() { static int test_array[(offsetof(struct Test,a)) > 0 ? 2 : 1]; } with arm-linux-androideabi-gcc…
Nathan
  • 7,099
  • 14
  • 61
  • 125
1
vote
0 answers

C - Reading Cooked input from stream

I know that there are many questions that are about "reading input" but to clarify I am trying to read cooked input. For some reason fgets is not cooked (Not sure if thats by default or I need to turn it on using termios) So any help? ncurses is not…
user1659134
  • 93
  • 2
  • 7