Re: detecting characters on RS232-Interface
From: Saga (antiSpam_at_somewhere.com)
Date: 01/25/05
- Next message: Jeff Johnson [MVP: VB]: "Re: Can an ActiveX DLL raise an event to the app that calls it ?"
- Previous message: Bob Butler: "Re: TreeView Control"
- In reply to: Peter: "detecting characters on RS232-Interface"
- Next in thread: Dick Grier: "Re: detecting characters on RS232-Interface"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 Jan 2005 11:25:56 -0600
IIRC, at one time what I did was establish a receive buffer.
Everytime I received a header byte (U in your case) I would
accumulate it in the buffer. If it wasn't the header char, I
would clear the buffer. Then, I would compare the contents
of the buffer with a known header string and if equal I knew
that the next bytes were valid data. Since I also had a
termination byte, I would receive bytes until I found it, at
which time I knew I had the complete data block.
HTH
Saga
"Peter" <peter_l@myrealbox.com> wrote in message
news:1106671227.609752@stern...
> Dear All
>
> I have connected a device to my PC's comport that continuously sends
> data
> @4800bd,N,8,1.
> Most of the time these data are garbage and need not to be read by my
> VB6
> program.
> Sometimes this device also sends valid data. Right before the
> beginning of
> these valid data the device sends "UUUU" (010101..pattern) to indicate
> the
> valid data.
> I am currently using MSComm Control in my program to handle the
> comport.
> Question: How do I detect these "UUUU" to know that the next
> data(known
> length) are valid to read them in? The valid data itself do not
> contain any
> "UUUU".
> Do I need to evaluate each received byte of the garbage data and count
> the
> received Us in series until 4 times the U was received or is there a
> better
> way?
> Can I do this in realtime because the device does not support flow
> control
> so I can not stop the data flow and my program must be fast enough to
> detect
> the UUUUs?
> Thanks for any hint on this
> Regards
> Peter
>
>
- Next message: Jeff Johnson [MVP: VB]: "Re: Can an ActiveX DLL raise an event to the app that calls it ?"
- Previous message: Bob Butler: "Re: TreeView Control"
- In reply to: Peter: "detecting characters on RS232-Interface"
- Next in thread: Dick Grier: "Re: detecting characters on RS232-Interface"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|