Serial(or BufferedSerial) class not working after reconnect the builtin st-link

First, my nucleo 746zg is connected to pc and is powered by smps(JP3 setting).

I monitor it via tera term.

I tested 3 conditions.

  1. After the first power and first connection, I press the disconnect button on tera term and reconnect the board, the board is running continuously.

  2. After the first power and first connection, I turn off the smps and turn on, the board reset and works.

  3. After the first power and first connection, I unplug the usb cable and plug it back in, the board reconnected to the terminal but print nothing.

3rd case is my problem.

Can anyone have an Idea to handle it?

Using my logic analyzer, I scope CN5 which is uart pin before f103(stlink).

It shows the data it has to be.

Hello,

from my point of view that is correct and normal behavior and it have nothing with any code in your board.
On Board ST-Link is powered via its USB cable. So how you connect it to a PC, then you will ST-link VCP device in System device manager is shown and then you can connect to it. Now you can reset the board or On/Off external power source (that will reset only the MCU not the ST-link) but ST-Link is still powered by the host side, that mean the connection is still established.
However, your third case is different, because when you unplug USB cable of ST-link, then it is not powered and established connection with PC was lost, the VCP was closed on the host side. When you plug it again, then the connection must be established again (you must VCP open again).

BR, Jan

Hi Jan.

Thank you for the reply.

Now I understand what I have to do.

However, in the Windows environment, OS makes VCP in the same name(in my case COM24).

Is there any way you recommend?

I am not sure what you are asking for.
That is also correct, when you first time conect a device to your PC, the system will store identification (VID/PID) from USB interface chip and assigns a free number of COM port, and that COM port will be used always, when you connect this chip/hardware (with this VID/PID). Of course, or until not change settings manually.

BR, Jan

Hi Jan.

What I wonder was the sentence “VCP open again”.

As I understand, unplug and plug back is not open again right?

Could you tell me the way how I can do?

No google answers me about that…

Ok, in the basic you need to do exactly same like with the cable. When you unplug and replug the cable you also must Disconnect and Connect your application.
If used App is not made well it may be necessary to completely close and re-open also used App. And in the worst case, when app after closing still block COM port (COM is still open and can not be opened again), you need to kill it in system’s task manager or restart PC.

BR, Jan

Thank you, Jan.

I tested it today.

Even I re-plug then reinstall the device(it is necessary to reboot my computer), my serial monitor does not show the data.

I need to do something else.

I solved the problem.

My on board st-link F/W version was too low.

After I upgrade the F/W, it reset itself when it is re-plugged.