Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

read binary data stream through com port, create file

Posted on 2006-07-23
6
Medium Priority
?
512 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 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

660 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