[En-Nut-Discussion] CR + LF or LF + CR
Andre Riesberg
andre at riesberg-net.de
Sun Sep 6 07:51:37 CEST 2009
Ulrich Prinz wrote:
>Sorry to fast...
>But by the way: I stumbled accross that on another project: Windows has
>a big problem with string recognition with exchaned CR/LF. We searched
>for hours to find that on a test enviroment in a production line...
>
>Ok, here are fixes for the different platforms. Tell me what you tested
>and what worked, so I test the others.
>
>static void DebugPut(CONST NUTDEVICE * dev, char ch)
>{
> if (ch == '\n') {
> while ((inr(dev->dev_base + US_CSR_OFF) & US_TXRDY) == 0);
> outr(dev->dev_base + US_THR_OFF, '\r');
> }
> while ((inr(dev->dev_base + US_CSR_OFF) & US_TXRDY) == 0);
> outr(dev->dev_base + US_THR_OFF, ch);
>}
>
>The wait for the THR getting empty has to follow after sending the CR
>out. Sorry again.
>
>Ok, here the fix for AVR: arch/avr/dev/debug1.c
>Find / replace DebugPut(char ch)
>
>static void DebugPut(char ch)
>{
> if(ch == '\n') {
> while((UCSR1A & BV(UDRE)) == 0);
> UDR1 = '\r';
> }
> while((UCSR1A & BV(UDRE)) == 0);
> UDR1 = ch;
>}
>
>And for AVR debugging via UART 0: arch/avr/dev/debug0.c
>Find / replace DebugPut(..)
>
>/*!
> * \brief Send a single character to debug device 0.
> *
> * A carriage return character will be automatically appended
> * to any linefeed.
> */
>static void DebugPut(char ch)
>{
> if(ch == '\n') {
> while((USR & BV(UDRE)) == 0);
> UDR = '\r';
> }
> while((USR & BV(UDRE)) == 0);
> UDR = ch;
>}
>
>And now for the LPC2xxx: arch/arm/dev/debug_lpc2xxx.c
>
>/*!
> * \brief Send a single character to debug device 0.
> *
> * A carriage return character will be automatically appended
> * to any linefeed.
> */
>void DebugPut0(char ch)
>{
> if(ch == '\n') {
> while ((U0LSR & U0LSR_THRE) == 0);
> U0THR = '\r';
> }
> while ((U0LSR & U0LSR_THRE) == 0);
> U0THR = ch;
>}
>
>/*!
> * \brief Send a single character to debug device 1.
> *
> * A carriage return character will be automatically appended
> * to any linefeed.
> */
>void DebugPut1(char ch)
>{
> if(ch == '\n') {
> while ((U1LSR & U1LSR_THRE) == 0);
> U1THR = '\r';
> }
> while ((U1LSR & U1LSR_THRE) == 0);
> U1THR = ch;
>}
>
>Andre Riesberg schrieb:
>
>
>>Hi all,
>>
>>I use the debug output via serial interface. In the output every LF will
>>be replaced by LF CR.
>>This surprised me a little bit, many other system (I know) use CR LF.
>>
>>I know this is really an unimportant detail but my favorite terminal
>>program can suppress CR LF but not LF CR on the screen.
>>
>>Greetings
>>Andre
>>
>>PS: I forward this mail to the developer of HTerm. Maybe in the next
>>version he can also suppress LF CR :-)
>>
>>_______________________________________________
>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>
>
Hi Ulrich,
thanks for your answer! Too bad to spend hours for a detail....
In the moment I have no ARM board avail, but the source looks correct.
In the AVR debug1.c and debug0.c I exchange to line of code:
Original:
/*!
* \brief Send a single character to debug device 0.
*
* A carriage return character will be automatically appended
* to any linefeed.
*/
static void DebugPut(char ch)
{
while((USR & BV(UDRE)) == 0);
UDR = ch;
if(ch == '\n')
DebugPut('\r');
}
Modified:
/*!
* \brief Send a single character to debug device 0.
*
* A carriage return character will be automatically appended
* to any linefeed.
*/
static void DebugPut(char ch)
{
if(ch == '\n')
DebugPut('\r');
while((USR & BV(UDRE)) == 0);
UDR = ch;
}
Bye the way... I am beginner with Nut/OS (less then 1 week). What is the
correct way to make this changes permanently? I had also found an issue
in "cfg/arch/porttran.h" that prevents my 1-wire interface to work
correctly. So long this modification is not in the common code base,
nobody can use my interface.
Greetings
Andre
More information about the En-Nut-Discussion
mailing list