• C

How to get data from serial port?

Hi,
   I am using Sun Solaris 2.6,and C compiler on Solaris.
   I got new project in which i need to acceess the serial port i.e i will be getting the data through modem (leased line modem) and my program need to read the data comming through serial port and depending upon the incomming data i need to process that data and if required put that data in the database.
   I know that unix treat device as the file and in solaris "/dev/ttya" and "/dev/ttyb" are the two files which represents two serial port and in c with the file read and write operation i can achieve the reading and writting on the serial port,but i don't know how the incomming data is stored in the file(/dev/ttya or /dev/ttyb) whether these file gets overwritten each time new data commes or all the serial port data get appended in the file and get deleted after end of the session. what really happens ?
Please advice.
tambdeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rbrCommented:
It looks like a file but it is more like a pipe. (FIFO). In unix you have the possibility to write a driver that simulates a file (the os-driver for ttyx is such a programm) The file does not exist anywhere in the fs only the driver must handle some basic fuctions. If you want to access such files you can open them like real files and read and write on it (If the driver supports reading and writing) The data comes in a stream and will not be overwritten if new data comes. The data will be but on a queue. The only problem you can have that the internal buffer of the driver will be full. Then it depends on the driver if the device will be blocked or the old data will be overwritten by the new one.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.