[ECOS] tty swallows every odd character

Bob Brusa bob.brusa@gmail.com
Mon Sep 7 08:15:00 GMT 2009


Hi
using a at91sam7x-based board, I have configured UART1 as tty and with  
hw-driver. When transmitting characters to the serial_1 input, I get an  
echo on every 2nd character only. And indeed, in the final result I get  
upon <enter>, every second character ist missing. But only the first time,  
later the picture gets wilder:

My code (excerpt) is:

		j = 0;
		while (true) {
			scanf("%c",&ch);
			if ((ch == '\n') || (ch == '\r')) {
				cmd[j] = '\0';
				len = strlen(cmd);
				printf("j:%d len:%d cmd:%s\n ", j, len, cmd);
				j = 0;
			} else
				cmd[j++] = ch;
			cmd[j] = '\0';
		}

EXAMPLE:
type 01234567<enter><enter>    cmd is 1357
type 01234567<end>             cmd is 1346

The above code can be simplified to
while (true) scanf("%s",cmd);
producing the same results. I just expanded it to get an idea where the  
problem is.

Strange behaviour. Isn't it? Thanks for help.
    Robert

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list