Solved

MSComm and binary data

Posted on 1998-07-21
10
599 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

820 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