Program freezes in the user thread when using the printf function

Moderators: TomKerekes, dynomotion

Post Reply
Alexanders
Posts: 33
Joined: Wed May 03, 2023 12:54 am

Program freezes in the user thread when using the printf function

Post by Alexanders » Tue Sep 12, 2023 11:07 pm

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.

User avatar
TomKerekes
Posts: 2635
Joined: Mon Dec 04, 2017 1:49 am

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

Post by TomKerekes » Tue Sep 12, 2023 11:14 pm

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
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply