dobbinjp
asked on
read binary data stream through com port, create file
I am new to working with binary data in vb.net and need to write code that will open a com port (com5) and read binary data from a sensor device. The binary data stream has characters "cs" and "end" that signify the start and end of the stream, respectively. A new data stream will begin every 5 minutes. I want to save the binary data inbetween the "cs" and the "end" characters to a file on the computer, let's say in "c:\sensor\binary" with a ".000" extension. I need to remove the "cs" and "end" from the resulting binary file.
I have seen several posts about serial/com ports, but nothing about reading the data in the stream (esp. data between certain characters) to a file and I wasn't sure about a replace function for binary data, either. I think I just need a kick in the right direction about how to approach the problem. Any help is appreciated.
I have seen several posts about serial/com ports, but nothing about reading the data in the stream (esp. data between certain characters) to a file and I wasn't sure about a replace function for binary data, either. I think I just need a kick in the right direction about how to approach the problem. Any help is appreciated.
ASKER
I figured I was leaving something out, here are the answers:
1. the data will not be a constant length between "cs" and "end" It is a pretty large stream (about 100kb worth of data every 5 minutes)
2. yes, "cs" and "end" are not found anywhere else in the data so it should be a unique binary pattern
3. the data does not look like 1's and 0's when I open it in Notepad, rather it looks like hieroglyphics (úLhq£T5TUD ýÛþ¿E+ gÿÊÿ©ÿ ? –ÿ žÿñÿ ÿéÿ ÿØÿ 6), so I assume the answer is really a stream of ascii characters with the encoded data...I am a DB guy so not very used to working with binary data.
4. the expected data rate is 9600 8-none-1
5. I am using .NET framework 2.0, Visual Studio 2005
Thanks again!
1. the data will not be a constant length between "cs" and "end" It is a pretty large stream (about 100kb worth of data every 5 minutes)
2. yes, "cs" and "end" are not found anywhere else in the data so it should be a unique binary pattern
3. the data does not look like 1's and 0's when I open it in Notepad, rather it looks like hieroglyphics (úLhq£T5TUD ýÛþ¿E+ gÿÊÿ©ÿ ? –ÿ žÿñÿ ÿéÿ ÿØÿ 6), so I assume the answer is really a stream of ascii characters with the encoded data...I am a DB guy so not very used to working with binary data.
4. the expected data rate is 9600 8-none-1
5. I am using .NET framework 2.0, Visual Studio 2005
Thanks again!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
few questions:
has the data a constant length between the "cs" and "end"?
How do you recognize the "cs" and "end" info. Is this a unique binary pattern, not existing in the data?
Is the data a real binary pattern, as opposed to a stream of ASCII characters containing encoded data?
What is the expected data rate in bytes per second?
What vb.net version are you using?
The answer to these questions is important to understand the concept and to suggest the best solution.
Jack.net