cancel
Showing results for 
Search instead for 
Did you mean: 

How to set LWIP debug to usart2 ?

Mathias Zviedris
Associate III
Posted on July 24, 2017 at 10:29

Hi,

i already have done the setup for the lwip stack on the STM3210C-Eval board. I can already send via TCP/UDP and also RS232 to the uC (PC-->uC) and get also a echo back (uC-->PC). The debug output of the lwip-stack is already configured via cubemx, too. But i have absolutly no idea, how to configure the lwip-stack (via lwipopts.h or something else) that i can see the debug output of the lwip on RS232. Can anybody give a hint ?

Thanks in advance,

Mathias

8 REPLIES 8
Posted on July 24, 2017 at 13:05

Create a function which outputs a string through the method of your choice (), then

#define LWIP_PLATFORM_DIAG(message) yourfunction(message)

(you can similarly define LWIP_PLATFORM_ASSERT(message))

Debug is enabled globally by

#define LWIP_DEBUG                      1

and then there are individual debugs, e.g.

 #define UDP_DEBUG                        LWIP_DBG_ON

#define LWIP_DBG_TYPES_ON    (LWIP_DBG_ON | LWIP_DBG_TRACE)

See [lwip-1.4.1]/src/include/lwip/debug.h

JW

Posted on July 26, 2017 at 11:29

Hi Jan, thank you for your fast and very good response ! I enabled the debuggin via cubemx and thought, that LWIP_DEBUG is already defined. I didnt have a look on it and that was the cause of the problem. Now i can debug . Thank you

Posted on July 26, 2017 at 14:08

I enabled the debuggin via cubemx and thought, that LWIP_DEBUG is already defined.

And what did that do then?

I am not interested in Cube/MX at all, but ST might want to hear some feedback.

JW

Posted on July 26, 2017 at 16:26

You can change the settings of WHAT the debug output should show. Now im fighting with my debug output . Do you

have another hint, how to format the lwip debug output, so that i can send it via uart ? Because the output messages are formated to be handled by printf.... i tried snprintf to save the string into an array, but there is an error with ''too few arguments''.

0690X00000607ghQAA.png
Posted on July 26, 2017 at 16:56

Couldn't in CubeMX a tickbox needed to enable the debug globally be hidden in some other place?

-----

I use

  void UartBufPrint(char * s);

  &sharpdefine UartBufPrintF(...) {char s[80]; snprintf(s, 80, __VA_ARGS__); UartBufPrint(s);}

  &sharpdefine LWIP_PLATFORM_DIAG(m) UartBufPrintF m

JW

Posted on July 26, 2017 at 17:14

I havent found a radiobutton yet. I give your hint a try and implement it in that way. Hopefully i understand till tomorow, what your code snippet means 🙂 . Thank you !

So i implemented it quick and dirty and the debug is now working. Great 🙂 ! Is it normal, that in ''idle state'' (if no packages are sended by pc or uC) that the debug output shows some weired data ?

0690X00000607grQAA.png
Posted on July 26, 2017 at 17:35

So i implemented it quick and dirty and the debug is now working.

Congrats! Quick and dirty, that's how it supposed to be! 😉

Is it normal,[...]

Sorry don't know, it's been quite a couple of months I've looked at this last time...

JW

Posted on July 27, 2017 at 07:36

No need to write sorry. Everything is fine 🙂