Finally, the problem was the USB-Serial Converter which I was using (CH340). I changed it to FT232RL and I has able to send all the data. Thanks for your hints.
Best Regards
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi everyone, I am using Visual Studio 2013 (C#) in order to test serial port. I have an array of bytes and I am trying to send it via Serial Port using two USBSerialConverter. The data that I receive is between 14 to 18 bytes of lenght (it change everytime i execute the code), not 30 as the size of array.
byte[] tx_Data = new byte[30];
...
string bitString = BitConverter.ToString(tx_Data);
Console.WriteLine(bitString);
serialPort1.Open();
Console.WriteLine(tx_Data.Length);
serialPort1.Write(tx_Data, 0, tx_Data.Length);
serialPort1.Close();
The Console.WriteLine from this code is:
4F-42-2D-30-35-30-34-2D-32-34-33-36-2C-0C-01-13-17-33-09-0F-0F-0A-1E-58-00-00-00-00-C8-26
30
but I receive something like.
4F 42 2D 30 35 30 34 2D 32 34 33 36 2C 0C 01 13
What I could be doing wrong?
thanks for your help.
Finally, the problem was the USB-Serial Converter which I was using (CH340). I changed it to FT232RL and I has able to send all the data. Thanks for your hints.
Best Regards
Thanks for your advice,
by default the baud rate was 9600, then I changed it to 19200 and it works very well. What could be wrong when I use 9600 baud?
Now the same code works well sending all the data with 9600 baud, but it works with virtual COM ports. Before I was testing with two ch340 USB-Serial Coverter. Maybe these modules are the problem, I will try with FT232RL.
Best Regards