termios and raw data - bug?

Eric Norum eric.norum at usask.ca
Mon Sep 17 16:26:18 UTC 2001


peter.o.mueller at gmx.de wrote:
> 
> Hi all,
> 
> searching why I'm not able to get binary data over the serial line (bit 8
> set) I found the following "feature" of the 16550 character read function. If a
> character is available the character will be returned, if there is no char
> available -1 will be returned. So if data with bit 8 set comes in the
> character was lost because the upper layer assumes it is -1 and just picks up the
> next incoming char.
> 
> The following change in ns16550.c solves the problem: The char was set to
> the lower byte of the return value, without expanding it sign correct.
> 
>   unsigned short       tmp=0;
> ..
>   ucLineStatus = (*getReg)(pNS16550, NS16550_LINE_STATUS);
>   if(ucLineStatus & SP_LSR_RDY) {
>     cChar = (*getReg)(pNS16550, NS16550_RECEIVE_BUFFER);
>     tmp |= (unsigned char)cChar;
>     return (int)tmp;
>   } else {
>     return -1;
>   }

That seems a little complicated.  Would not
	return (unsigned char)((*getReg)(pNS16550, NS16550_RECEIVE_BUFFER));
work properly?

-- 
Eric Norum                                 eric.norum at usask.ca
Department of Electrical Engineering       Phone: (306) 966-5394
University of Saskatchewan                 FAX:   (306) 966-5407
Saskatoon, Canada.



More information about the users mailing list