Subj : Re: win32 - High speed serial streaming code??? To : comp.programming From : robertwessel2@yahoo.com Date : Thu Sep 01 2005 12:05 am DarkD wrote: > I need to capture data from a serial device that has 115200bps output. Its > continously outputs 3byte packets 1250 times per second. > > I have tried using the win standard way to do serial port access (CreateFile > ReadFile etc.) and cannot obtain anywhere near 3750 bytes per second. The > system is completely dropping some data. > > The 3rd byte in every packet is 0xFF and the packets can have no break in > time between the 3rd byte of one and the first of the next. I am not sure if > 0xFF is affecting anything. Alot of the packets are: 0x00 0x00 0xFF, so im > not sure if this is cuasing the problem either. > > I have tried use setupcomm to give massive buffers (30KB etc.) and can't get > close to 3750 bytes per second > . > With ReadFile how many bytes should I be reading? If I put 3 I can get about > 100 packets per second. If I put 1000bytes I get about 200 packets per > second... > > I am using visual c++ > > I know it is not a CPU performance thing because this is a 3GHz P4 and the > CPU usuage is zero all the time. > > Is there some other way to low level access the uart chip so I can stream in > this data fully? I cannot understand why modern computer cannot continously > stream and save data at 115200bps. > > I have also tried event based triggering and the performance is just as bad. Something else is wrong. On that fast a machine doing even one byte reads should be able to keep up with that with no problem whatsoever. Are you perhaps doing something like writing the data to disk in tiny chunks and flushing disk repeatedly, or...? Make sure you don't have any flow control turned on - CTS, DSR or Xon/Xoff, make sure you set binary in the DCB. Make sure you have the right baud rate set. As to the data you're getting does it look anything like what you're expecting? Missing bytes? Garbage bytes? Missing packets? Try an experiment. Fire up Hyperterminal and see if he can receive data at that rate. If not, there may be something wrong with the serial port. I've seen some external USB based ports that do badly at high speeds. .