Date: Sun, 3 Sep 2006 23:26:04 +0600 From: =?koi8-r?b?88XSx8XKIPPPwsvP?= <bug2bug@bug2bug.tk> To: freebsd-questions@freebsd.org Subject: A question about programming RS-232 Message-ID: <200609032326.05071.bug2bug@bug2bug.tk>
next in thread | raw e-mail | index | archive | help
Hello. I have a question I can't deal myself. And nobody can help me in resolving my problem. Problem: I have a hand-made device, I want to control from FreeBSD 6.1 (I am porting this application from Windows equivalent). But I don't know, in what device /dev/ I should write to get reults. I tryed to write bytes into /dev/ttyd0, /dev/cuad0, but got nothing. :( Code: #include <stdio.h> #include <termios.h> #include <unistd.h> #include <fcntl.h> int main(void) { int t = 0, num = 10, fd, i, iOut; char *ch; struct termios my_termios; ch = (char *)malloc(6); memset(ch, 250, 6); fd = open("/dev/ttyd0", O_RDWR | O_NONBLOCK); printf("Opened com port\n"); if(fd < 0) return 0; // tcflush(fd, TCIFLUSH); my_termios.c_cflag = CS8 | CLOCAL; if(cfsetspeed(&my_termios, B9600) < 0) return 0; if(tcsetattr(fd, TCSANOW, &my_termios) < 0) return 0; iOut = write(fd, ch, 6); if(iOut < 0) return 0; printf("Number of bytes = %d\n", iOut); printf("Writed %s!\n", ch); close(fd); printf("Closed!\n"); return 0; } P.S. Please, help me. P.P.S. Sorry for such stupid and annoying questions P.P.P.S. Sorry for my bad English as I'm from Russia and I'm only 16 ;)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609032326.05071.bug2bug>