serial port flush?
From: Thomas (thomas_at_tho-bai.de)
Date: 01/30/05
- Next message: Everett M. Greene: "Re: FM tuner IC?"
- Previous message: Roger: "Re: PING from Windows to a serial port"
- Next in thread: Heinz-Jürgen Oertel: "Re: serial port flush?"
- Reply: Heinz-Jürgen Oertel: "Re: serial port flush?"
- Reply: Ed Beroset: "Re: serial port flush?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 03:19:36 +0100
Hi there,
I've written a programme, to communicates with a microcontroller, but
sometimes there is no reaction when I send the initial byte. I'm working
under Suse Linux 9.2 prof. and as I know from a windows programme this
problem shouldn't be caused by the microcontroller. As it always works with
this programme under windows.
So could it be, that when there is a failure at the microcontroller, so that
the byte isn't received (i.e. it isn't in bootstrap mode), that after this
the serial port might be blocked by the previous byte? Or somthing like
that. I know, that this byte cannot really "block" the serial port, but
there must be something that blocks the transfer.
So is there a way to "flush" the serial port before starting a transfer? Or
is it something else that causes my problems.
Hier is my procedure that initializes the serial port:
int openport(char* device)
{
int fd;
struct termios options;
//Stream oeffnen
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
//ueberpruefen
if (fd == -1)
return -1;
//Alles auf Null setzen
bzero(&options, sizeof(options));
//aktuelle Einstellungen holen
tcgetattr(fd, &options);
//moeglicherweise vorhandene ungewuenschte Einstellungen zuruecksezten
options.c_cflag &= ~PARENB; //kein Parity-Bit
options.c_cflag &= ~CSTOPB; //ein Stopbit
options.c_cflag &= ~CSIZE; //Datenmaske zuruecksetzen
//weitere Controllflags setzen
options.c_cflag = B19200 | CS8 | CLOCAL | CREAD;
options.c_iflag = IGNPAR;
options.c_oflag &= ~OPOST;
options.c_lflag = 0;
options.c_cc[VMIN] = 1;
options.c_cc[VTIME] = 0;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &options);
return (fd);
}
So could anybody please help me?
Thanks in advance
Thomas
- Next message: Everett M. Greene: "Re: FM tuner IC?"
- Previous message: Roger: "Re: PING from Windows to a serial port"
- Next in thread: Heinz-Jürgen Oertel: "Re: serial port flush?"
- Reply: Heinz-Jürgen Oertel: "Re: serial port flush?"
- Reply: Ed Beroset: "Re: serial port flush?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|