Does a C/C++ PC (not arduino) serial port library exist on Linux?

I am having a hard time trying to talk with my Arduino on a Debian system. I am a linux noob. It seems that these unix/linux systems are holding on to their serial terminals tight. Every option in the termios struct is about using serial ports with a terminal (like VT100 or something). I seriously doubt there's such usage nowadays. Trying to use a serial port for unbuffered and un-processed data is just so hard. I just learned today that by turning off flow control, I was finally able to send bytes from Debian PC to Arduino. The Arduino -> Debian worked out of the box.

I wonder if there exists a c/c++ library for linux to run Arduino fashion Serial ports, such as Serial.begin, available, read, write. I am just hacking up code I found online and hoping it will hold together.

Here is what I found, from a member on the beagle board forum (probably also on pi forum):

I really can't understand why a FILE pointer is used and why one needs to open the serial port with open and then use the file descriptor to fopen again and only fread and fwrite with the FILE pointer instead of read and write with the file descriptor. I was using the file descriptor and it worked fine. Looks like the code disables buffering on FILE object so isn't that becoming just read and write?

I think you open the device (like "/dev/usbtty") as if it were a file. Then you can read from the 'file' and write to the 'file'.

Here is a tutorial: Serial HOWTO

Thanks John! I should have read on the hardware flow control in the tutorial.

You asked about C++ lib, but if you want to easily, quickly, seamlessly, problemfree, etc., etc to communicate with an Arduino from a host computer, one of the best way is to use Python and pySerial lib (http://pyserial.sourceforge.net/). You will find lot of examples if you google for it, as an elaborated one I can offer my arduino-hosted lib: GitHub - pfalcon/arduino-hosted: Arduino Hosted Python module, allows to rapid-prototype simple Arduino microcontroller applications on desktop computer. Unlike many other Python wrappers, this provides syntax as close as possible to Arduino.

Thanks, I know about python library but I don't use python. I use c/c++. It is much more powerful and faster. I have had enough trouble using Processing because it is slow and won't do static methods. I should be better off learning Java but then c is always my choice of language. If there are very good python scripts I can call them with system command. I envy people with good bash shell programming skills. They can do a lot with it. But I don't think I will learn bash that much, because of that. Too old to learn a language. What I will try is to cal python code from c so if I can understand a bit of python I can make use some good python scripts.

See this one
http://qt-project.org/wiki/QtSerialPort

I don't know if this is bad practice but if in a hurry I sometimes use system("stty ..."); instead of filling in the termios struct, eg:

#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int main(){
	int sp=open("/dev/ttyACM0",O_RDWR);
	system("stty -F /dev/ttyACM0 sane raw -echo 115200");
	sleep(2);
	
	unsigned char c;
	for(c=0;c<255;c++) write(sp,&c,1);
	while(read(sp,&c,1)) printf("got %d\n",c);
}

Great! Thanks. I'll give both a try.