Read data from serial port
c, embedded, serial-port
Solution
A lot of useful information about dealing with serial ports both on PCs and on the device end of the wire can be found at Jan Axelson's site for the book Serial Port Complete.
Actual interaction with the port will be highly platform-specific. On *nix of most flavors you open a device named something like `/dev/ttya` and use `read()`, `write()`, and `ioctl()` to read, write, and configure the port.
On Windows, you open a file named `COM1` (or `\\.\COM1` on some flavors) with the `CreateFile()` function, and then get it configured and happy with functions like `SetCommState()` and the `DCB` structure. The details are similar in broad outline to the things you need to do on *nix, but organized completely differently. You can find the whole discussion of configuring and using COM ports at MSDN.
On the embedded device, you will either be directly accessing the hardware registers of the UART or interacting with an RTOS. Either way, there is essentially no way to make the code on the device end broadly portable.
Problem
How do i read data from serial port using C ? and then again transfer the data to modem ? I am using RS 232 cable for serial communication ...