USBSerial - C# .Net no data received

26 Jun 2015

I am having problems receiving any data from the USBSerial mbed drivers on a windows PC using the .Net SerialPort drivers. I have setup a simple loopback test on mbed which periodically sends a string and loopsback any data received and under all of the below tests the .Net drivers do not receive any data.

I have tested this code on the frdm-k20,k22f and kl25z all with the same results. Updated the USBDevice libraries for mbed.

Running windows. The com port is detected no problems on the PC and I can successfully connecting with terminal windows, sniffer, c# program.

The mbed program simply runs in loopback and sends a periodic text string. I have tested with 3 terminal applications. 1 and 2 send and receive the data no problems. 3 send, but does not receive any data (same result as with the c# program).

I have tested many other available c# serial port applications withe same same results (no data received). Some of the programs are professionally developed.

I have tested freescale drivers on the boards and all of the above work with no problems.

Everything is pointing to there being an issue with mbed drivers working with windows .Net C# drivers at this point. Not sure where to go from here. Any suggestions? Can anyone confirm that they receive data using .Net drivers and using mbed?

Here is a C# program and mbed project which test this setup. https://www.dropbox.com/s/6zocyec10yztlu0/test_com.zip?dl=0

26 Jun 2015

As a followup, I exported the project to KDS where I could do some real debugging. I found that when connecting with a program running the .net serialport drivers mbed does connect and successfully receives data. But, when mbed tries to send data, it does not send the data and the send is aborted in the USBSerial._putc() function based upon the "terminal_connected" variable not being set to 1.

I commented out the terminal_connected chck in the putc() function and now the .net programs are recieving the data no problem. /media/uploads/fvnktion/2015-06-26_11_44_31-debug_-_frdm_test_usbserial_usbdevice_usbserial_usbserial.cpp_-_kinetis_design_s.jpg

See attached image of the single stepped code returned based upon the "terminal_connect" variable being read as 0. When indeed to terminal is connected.

The problem seems to be in the way that mbed is connecting to the .Net PC drivers and is not setting the "terminal_connected" variable for whatever reason.

Is there a way to properly report a bug or put in a service request?

26 Jun 2015

I discovered while trying to get serial RPC for .Net working that you need to set DtrEnable and RtsEnable to true for communications to be successful. Try doing this after you have opened the comms port.

26 Jun 2015

Hi Robin,

You are correct the DTR/RTS enabled does indeed make things work. Very counterintuitive where we are working with a serial port "emulator".

I believe this should still be considered a bug so that others don't lose hair coming to the same conclusion?