Posted by: foxtrot_xray
Serial/STDOUT? - 01/08/2003 17:36
Hey guys,
Now that I got the VFD powered and displaying, I'm tryin' to do something..
I'm actually opening "/dev/ttyS1" as a file_descriptor. I can write to it using the write() command, but when I do a read(), it ALWAYS reads from stdin! Even though I'm sending it the fd for the previously openend serial port.. Here's the snippits to my code, in case you see something I don't..
I open it special so I can set the baud rate in AC *OR* DC mode. And it works pretty well. I have to reset it because sometimes when the player boots up, the garbage ASCII locks the display up to where I HAVE to hard reset the display. When it'd reset, it sends back a character (which will, eventually, drop me out of the while loop.)
The read() command freezes until I hit a key on the keyboard, to which it then echos back at me what *I* typed in, regardless of the fact the write() command sent the characters out to the display thru /dev/ttyS1..
Strange..
Now that I got the VFD powered and displaying, I'm tryin' to do something..
I'm actually opening "/dev/ttyS1" as a file_descriptor. I can write to it using the write() command, but when I do a read(), it ALWAYS reads from stdin! Even though I'm sending it the fd for the previously openend serial port.. Here's the snippits to my code, in case you see something I don't..
vfd_fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY);
if (vfd_fd != -1)
{
/* Configure port.. */
tcgetattr(vfd_fd, &port_opt);
cfsetispeed(&port_opt, B19200);
cfsetospeed(&port_opt, B19200);
port_opt.c_oflag |= (CLOCAL | CREAD);
tcsetattr(vfd_fd, TCSANOW, &port_opt);
/* Send reset command.. */
vfd_reset();
}
/* Reset port params... */
tcgetattr(vfd_fd, &port_opt);
cfsetispeed(&port_opt, B19200);
cfsetospeed(&port_opt, B19200);
//port_opt.c_oflag |= (CLOCAL | CREAD);
tcsetattr(vfd_fd, TCSAFLUSH, &port_opt);
/* Loop, to reset display.. */
while (reset_ok)
{
write(vfd_fd, "\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000\x000", 20);
usleep(100);
write(vfd_fd, "\x01B\x052", 2);
usleep(50000);
/* Read the responce? */
//fcntl(vfd_fd, F_SETFL, FNDELAY);
read(vfd_fd, vfd_ret, 1);
perror("VFD_REST: Error: ");
fcntl(vfd_fd, F_SETFL, 0);
printf("VFD_REST: '%s'\n", vfd_ret);
}
I open it special so I can set the baud rate in AC *OR* DC mode. And it works pretty well. I have to reset it because sometimes when the player boots up, the garbage ASCII locks the display up to where I HAVE to hard reset the display. When it'd reset, it sends back a character (which will, eventually, drop me out of the while loop.)
The read() command freezes until I hit a key on the keyboard, to which it then echos back at me what *I* typed in, regardless of the fact the write() command sent the characters out to the display thru /dev/ttyS1..
Strange..