Page 1 of 1

Program freezes in the user thread when using the printf function

Posted: Tue Sep 12, 2023 11:07 pm
by Alexanders

Code: Select all

:
#include "KMotionDef.h"

void main()
{
   for(;;)
      {
      	printf("\nfgkjg;rgr;r'kgeroqwwn  " );   //The content of the text is not important
      	Delay_sec (0.1);
      	if (!ReadBit(47)) SetBit(47); else ClearBit(47);  // Led for control  	
      }
}
Kmotion 5.1.0
After some time after disconnecting communication with Kmotion, the execution of this thread stops.
Sometimes the connection is not restored after connection. Flashing user memory becomes impossible until this thread is stopped.
As long as this thread is not forcibly stopped, it is impossible to flash user memory.

Re: Program freezes in the user thread when using the printf function

Posted: Tue Sep 12, 2023 11:14 pm
by TomKerekes
Hi Alexanders,

printf should only be used for diagnostics. KFLOP has a buffer for 256 printed lines. If no PC is connected after 256 lines have filled the buffer then printf will block. So if no PC is connected don't do any prinfs.

HTH