Solved

MSComm and binary data

Posted on 1998-07-21
10
587 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
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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

809 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