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