mesko mesaric

mesko mesaric

  • NA
  • 1
  • 7.9k

Serial USB problem

Dec 20 2010 4:46 AM

Hi all !


Newbie needs some help with serial port.


In my C# application I read data that are send from AVR chip to USB port.

I've defined my message structure like this (byte by byte in hex):
1. C3 -> start of message
2. xx -> address field
3. xx -> address field
4. xx -> data field
5. 3C -> end of message.


This is general structure of my messages, I mean the most important are START and END sequences to help me to process what is between them.
Messages are 30 bytes max. 


I use :

string indata;
indata = port.ReadExisting();


Problem is that from time to time I receive only half of my message and sometimes "empty string".

Received messages on PC are:

1. 3c 15 88 3 45 c3   OK
2. 3c 15 88 3 45 c3   OK
3. 3c 15 88 3 45 c3    OK
4. 88 3 45 c3 NOT OK
5. 3c 15 88 3 45 c3     OK
6. 3 NOT OK
7. 3c 15 88 3 45 c3     OK
8. 3 45 c3  NOT OK
9. (nothing) NOT OK
10.3c 15 88 3 45 c3     OK
.
.
.


How many bytes can USB port receive at ones? You know what I mean.
Maybe I overloaded this buffer?

Port parameters are OK, (baudrate,....)


Any idea?




Thank You and regards !