![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 1
| Code: #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 */
/*
* '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 | O_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);
}
However, when we try to compile this code, we get an error that O_NDELAY is an undeclared variable. We think it has something to do with termios.h, but we have not been able to fix this. We also tried using FileOutputStream.h (Source: fileoutputstream.c File Reference) but we got a file not found error. Can someone point us in the right direction here? Thanks. |
| aSpareName is offline | |
| | #2 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,941
| This might help: Quote:
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS | |
| MK27 is online now | |
| | #3 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| Well you could mention which actual OS/Compiler you're using. The code you posted won't work everywhere.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
![]() |
| Tags |
| communication, file transfer, serial port |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file won't close despite calling the function TiffClose(image) | caggles | C Programming | 1 | 05-27-2009 12:46 PM |
| FTP program | jakemott | Linux Programming | 14 | 10-06-2008 01:58 PM |
| help with text input | Alphawaves | C Programming | 8 | 04-08-2007 04:54 PM |
| Reading and writing to a serial port | SwarfEye | C Programming | 2 | 08-18-2006 12:28 AM |
| send zip file via socket | WaterNut | C Programming | 11 | 05-24-2005 11:49 AM |