Date: Wed, 15 Jun 2005 04:07:53 -0700 (PDT) From: snort Snort <snort_sam@yahoo.com> To: freebsd-current@freebsd.org Subject: ttys0 code freezes 5.4 release-p1 badly Message-ID: <20050615110753.11528.qmail@web54408.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
Hi,
The following ttys0 code freezes 5.4 release-p1 badly:
#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/ttyd0", 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);
}
int
write_port(int fd)
{
int n = write(fd, "ATZ\r", 4);
if (n < 0) {
fputs("write() of 4 bytes failed!\n", stderr);
return 0;
}
return n;
}
void
read_port(int fd)
{
fcntl(fd, F_SETFL, FNDELAY);
//fcntl(fd, F_SETFL, 0);
}
void
close_port(int fd)
{
close(fd);
}
int main()
{
int fd = open_port();
if (write_port(fd) < 0)
return 1;
read_port(fd);
close_port(fd);
}
Dose anyone know what is problem and how to fix it?
Thanks
Sam
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050615110753.11528.qmail>
