1

I am using STM Virtual Com Port (VCP) to send data from my firmware to my PC application using C# .NET

I have created a Windows PC application that reads the data using VCP

From my firmware, I am sending 512 bytes every second, but my PC application is not receiving the data every second. It needs to wait 8 second, for the buffer to be full before I receive a data callback

That means, it needs to wait 4096 bytes before, I receive the callback...

But I have configured, my port to timeout every 1 ms, but it is not working...

My code is below:

port1 = new SerialPort("COM171", 9600);
port1.WriteBufferSize = 1024;
port1.ReadBufferSize = 1024;
port1.WriteTimeout = 1;
port1.ReadTimeout = 1;    
port1.Handshake = Handshake.RequestToSend;
port1.ReceivedBytesThreshold = 1024;
port1.DtrEnable = true;
port1.RtsEnable = true;
port1.ReceivedBytesThreshold = 1;
port1.Open();

Any idea how to fix this? I want to reduce the latency timer to 1ms or the receive buffer to be smaller = 512 bytes for every data callback?

Tim
  • 3,755
  • 3
  • 36
  • 57

1 Answers1

1

I make a mistake in firmware, I dint send the zero length packet, so the data connection between my firmware and PC is open, no data will be received in PC until the data connection is terminated

You can check the link below for more information:

When do USB Hosts require a zero-length IN packet at the end of a Control Read Transfer?

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FVCP%20with%20STM32&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=6980

Community
  • 1
  • 1
Tim
  • 3,755
  • 3
  • 36
  • 57