CR + LF or LF + CR

View: New views
12 Messages — Rating Filter:   Alert me  

CR + LF or LF + CR

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Can you specify which platform you're using? There are quite some debug
modules...

Thanks and kind regards
Ulrich

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

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, found it:

Can you test this fix by exchanging the appropriate function in
nut/arch/arm/dev/debug_at91.c: Starting Line 289 with the following code:

/*!
  * \brief Send a single character to debug device 0.
  *
  * A newline character will be automatically prepended
  * by a carriage return.
  */
static void DebugPut(CONST NUTDEVICE * dev, char ch)
{
     while ((inr(dev->dev_base + US_CSR_OFF) & US_TXRDY) == 0);
     if (ch == '\n') {
        while ((inr(dev->dev_base + US_CSR_OFF) & US_TXRDY) == 0);
         outr(dev->dev_base + US_THR_OFF, '\r');
     }
     outr(dev->dev_base + US_THR_OFF, ch);
}

Hope that this will fix it for ARM. If it works, give me a response so I
can check it into the latest trunk.

Best regards,
Ulrich

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

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: CR + LF or LF + CR

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ulrich Prinz wrote:

>Hi!
>
>Can you specify which platform you're using? There are quite some debug
>modules...
>
>Thanks and kind regards
>Ulrich
>
>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 Ulich,

I use the AVR debug modules.
 
I make a simple search for '\r' in all *.c files from nut os and took a
short look inside. Here are the file I found:

arch\arm\dev\debug_at91.c
arch\arm\dev\debug_lpc2xxx.
arch\avr\dev\debug0.c
arch\avr\dev\debug1.c
arch\h8300h\dev\scih8dbg.c
arch\h8300h\dev\uart_s3c4510b_dbg.c
boot\bootmon\dialog.c

Greetings
Andre



_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: CR + LF or LF + CR

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[SNIP]

>>
>>  
>>
> 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.

I didn't want to do a recursive call as I could not forsee if there is a
way to get a dead loop. So I did it the hard way :)

If you're a beginner, the best way is to do it like you did. Post the
problem here and some of the NutO/S guys will catch up. You can add
DIFFs to your posts or someone will ask you for your modifications and
integrate them. After a while there are options, that you can get write
access to the repository.

So don't hasitate to write any bugreports and / or solutions. You're not
alone :)

Best regards,
Ulrich
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Andre Riesberg schrieb:
>>
> Hi Ulich,
>
> I use the AVR debug modules.

Ok, if you got fine with the AVR module, I will take care about the rest :)

>  
> I make a simple search for '\r' in all *.c files from nut os and took a
> short look inside. Here are the file I found:
>
> arch\arm\dev\debug_at91.c
> arch\arm\dev\debug_lpc2xxx.
> arch\avr\dev\debug0.c
> arch\avr\dev\debug1.c
> arch\h8300h\dev\scih8dbg.c
> arch\h8300h\dev\uart_s3c4510b_dbg.c
> boot\bootmon\dialog.c
>
Ok, fine, but there is AVR32 missing... So may be, you're not on the
latest trunk version?

Best regards,
Ulrich
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Corrected for following Systems in the trunk:
- AVR
- ARM
- H8300
- LPC2xxx
- Bootmon

Best regards
Ulrich

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

Re: CR + LF or LF + CR

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ulrich Prinz wrote:

>Hi!
>
>Andre Riesberg schrieb:
>  
>
>>Hi Ulich,
>>
>>I use the AVR debug modules.
>>    
>>
>
>Ok, if you got fine with the AVR module, I will take care about the rest :)
>  
>
>>
>>I make a simple search for '\r' in all *.c files from nut os and took a
>>short look inside. Here are the file I found:
>>
>>arch\arm\dev\debug_at91.c
>>arch\arm\dev\debug_lpc2xxx.
>>arch\avr\dev\debug0.c
>>arch\avr\dev\debug1.c
>>arch\h8300h\dev\scih8dbg.c
>>arch\h8300h\dev\uart_s3c4510b_dbg.c
>>boot\bootmon\dialog.c
>>
>>    
>>
>Ok, fine, but there is AVR32 missing... So may be, you're not on the
>latest trunk version?
>
>Best regards,
>Ulrich
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Hi Ulrich,

very nice!
I will finish my 1-Wire bus master interface first. This will take 2 or
3 days (testing with diffent cpu clock rates).
Next I fix all these LF CR issues.
Then I can send you a pack of all changed files (incl. a change log!).
It would be very helpful when you check in these files!

Greetings
André













_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: CR + LF or LF + CR

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, you missed my last post on that one:

It's already checked in and fixed for all platforms. But I mentioned
your name in the log, cause you found it.

So thank you very much, and happy coding :)

Best regards, Ulrich

Andre Riesberg schrieb:

>>
> Hi Ulrich,
>
> very nice!
> I will finish my 1-Wire bus master interface first. This will take 2 or
> 3 days (testing with diffent cpu clock rates).
> Next I fix all these LF CR issues.
> Then I can send you a pack of all changed files (incl. a change log!).
> It would be very helpful when you check in these files!
>
> Greetings
> André
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: CR + LF or LF + CR

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ulrich Prinz wrote:

>Sorry, you missed my last post on that one:
>
>It's already checked in and fixed for all platforms. But I mentioned
>your name in the log, cause you found it.
>
>So thank you very much, and happy coding :)
>
>Best regards, Ulrich
>
>Andre Riesberg schrieb:
>  
>
>>Hi Ulrich,
>>
>>very nice!
>>I will finish my 1-Wire bus master interface first. This will take 2 or
>>3 days (testing with diffent cpu clock rates).
>>Next I fix all these LF CR issues.
>>Then I can send you a pack of all changed files (incl. a change log!).
>>It would be very helpful when you check in these files!
>>
>>Greetings
>>André
>>
>>_______________________________________________
>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>    
>>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Perfect! I had not read the mail accurate enought....

Greetings
André


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion