Solved

MSComm and binary data

Posted on 1998-07-21
10
622 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
[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
  • 5
  • 3
  • 2
10 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1466316
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
ID: 1466317
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
ID: 1466318
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 9

Expert Comment

by:Dalin
ID: 1466319
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
ID: 1466320
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
 

Author Comment

by:rick_ahl
ID: 1466321
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
ID: 1466322
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
ID: 1466323
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
ID: 1466324
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
ID: 1466325
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

Industry Leaders: 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’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 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