I am new here. I am using the C to do simple communciations to a serial port (like opening,reading, writing to the serial port.....). I use the Dev C++ compiler for this. But the first thing I encountered is that my code doesnt compile without some headers..
1. <termios.h>
2. <bios.h> (even though its not used in the below example)
Do you guys have any idea where to get them. I searched the whole net but wasnt smart enough to find a place I can downlaod these headers.
Or are there any better header files that can be used in place of these. I am totally lost at this point. Would greatly appreciate any help.
The code is below
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#incldue <conio.h>
/*
* 'open_port()' - Open serial port 1.
*
* Returns the file descriptor on success or -1 on error.
*/
int
open_port(void)
{
int fd; /* File descriptor for the port */
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | _NDELAY);
if (fd == -1)
{
/*
* Could not open the port.
*/
perror("open_port: Unable to open /dev/ttyS0 - ");
}
else
fcntl(fd, F_SETFL, 0);
return (fd);
}
int main ()
{ open_port();
getch();
return 0;
}
This post has been edited by jayman9: 14 September 2006 - 07:53 AM

New Topic/Question
Reply




MultiQuote



|