Solved

MSComm and binary data

Posted on 1998-07-21
10
561 Views
Last Modified: 2010-05-03
I have been trying unsucessfully to write a program that brings in binary data over the serial port and saves it to a file with no changes. Can someone show me an example of this? I can get text but control chars just dont come  through. If the MSComm controll is set to binary input all I get is garbage.
0
Comment
Question by:rick_ahl
  • 5
  • 3
  • 2
10 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
Comment Utility
rick-ahl,
The "garbage" is what you want... It is in binary format.
You need to process the binary data  to convert back to Text (ASCII) before it make sense.  To do that you need to to know how the data is send to the port.
For example, some use two bytes for each character, so you need to process two bytes at a time.

Let me know if I can be futher help.

Regards
Dalin



0
 

Author Comment

by:rick_ahl
Comment Utility
Dalin,

I guess I should have phrased my Question a bit better. I understand the "garbage" I am recieving is the data I want but I havent been able to figure a way to convert it properly. At this point I am using a null modem cable as a test bed on my local machine. Comm1 sends(using hyperterminal) and Comm2 recieves using the VB app I am working on. Settings are 9600,8,n,1. As I said I can recieve in text mode but I lose my control characters. I need those characters though in order for the app to be useful. What code do I need in order to facilitate recieving these control characters. I will bump this question to 200 points if you can give me some sample code that I can use.
0
 

Author Comment

by:rick_ahl
Comment Utility
Dalin,

I guess I should have phrased my Question a bit better. I understand the "garbage" I am recieving is the data I want but I havent been able to figure a way to convert it properly. At this point I am using a null modem cable as a test bed on my local machine. Comm1 sends(using hyperterminal) and Comm2 recieves using the VB app I am working on. Settings are 9600,8,n,1. As I said I can recieve in text mode but I lose my control characters. I need those characters though in order for the app to be useful. What code do I need in order to facilitate recieving these control characters. I will bump this question to 200 points if you can give me some sample code that I can use.
0
 
LVL 9

Expert Comment

by:Dalin
Comment Utility
rick_ahl,
What type of control characters are you using? like CR/LF?
Do you mean you send those chars with other normal text and you do not receive them?

I do have sample code of various kind, but would like to know better on what you try to do so I can give more proper code.
Regards
DAlin
0
 
LVL 6

Expert Comment

by:alamo
Comment Utility
Is it possible the control characters you are losing are ctrl-s and xtrl-q? These are the software handshaking codes, and if you have the control's Handshaking property set to comXonXoff or comRTSXonXoff you will never see them. Change Handshaking to comNone or comRTS.

Another property that affects control characters is NullDiscard - make sure this is false.

Hope this helps...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:rick_ahl
Comment Utility
Dalin,

To be more specific I am tranfering postscript output from an old pagination system that only support serial output to a pc running Win95. the CR/LF are the majority of the control characters I will run into but I could run into others(Control+D) possibly. My biggest concern is just that what comes over the wire serialy I need to replicate idntically in a file. If I dont it could wind up in corrupted output which would render the page output useless.

In Normal text mode with MSComm the CR/LF are converted to a different character. I dont have sample output handy here with me at work to find out what character its converting to.

Does that help?
0
 
LVL 6

Expert Comment

by:alamo
Comment Utility
I forgot about EOFEnable, by the way, that must be false also.

I think the problem is not in VB, it's in Hyperterminal. Hyperterminal is modifying the file before it sends it. I have done binary comm with the MSComm control and it works fine with no special action. Are you using 'Send File' rather than 'Send text file'?

But.. Postscript output should be text-only, anyway, so I am xonfused (although it will probably have newline (LF) as the only line terminator).
0
 

Author Comment

by:rick_ahl
Comment Utility
Alamo,

You were right, Hyperterminal was striping the characters. Look for my next message titles "for Alamo" to recieve an equal amount of points for your contribution to this problem. Thanks!
0
 
LVL 9

Expert Comment

by:Dalin
Comment Utility
rick_ahl,
Sorry, I was unable to follow up in time becuase I had a crash in one of the robot.  I am glad that alamo was able to point out the problem.
If I can be further help, please let me know.
Good luck in your project.
Dalin
0
 

Author Comment

by:rick_ahl
Comment Utility
Dalin,

Dont underestimate your assistance. It took both of you, thats why I gave you an A for your answer. Thanks again!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now