Solved

read binary data stream through com port, create file

Posted on 2006-07-23
6
507 Views
Last Modified: 2008-03-06
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.
0
Comment
Question by:dobbinjp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 9

Expert Comment

by:jrscherer
ID: 17165170
Hi
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



0
 

Author Comment

by:dobbinjp
ID: 17168146
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 (úLh q£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!
0
 
LVL 9

Accepted Solution

by:
jrscherer earned 500 total points
ID: 17181892
Hi dobbinjp

I was looking into my own programs, but I found that I had always ASCII streams with CRLF as line terminator.

First I thought that the new my.Computer.Ports  in 2005 could do the job. But it is really string oriented and does not supply a byte stream or anything which could be converted into it.

You can get a byte stream using the WIN32 API
A good starting point is the sample:  101 VB.NET Samples\Framework - Using the COM Port
This is a 2003 sample set, but it still is working on 2005.

You can find it here http://www.microsoft.com/downloads/details.aspx?familyid=08e3d5f8-033d-420b-a3b1-3074505c03f3&displaylang=en

You will need to do some modifications in Rs232.vb to get a stream instead a string, but it seems to be doable.
Jack.net
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question