Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 639
  • Last Modified:

MSComm and binary data

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
rick_ahl
Asked:
rick_ahl
  • 5
  • 3
  • 2
1 Solution
 
DalinCommented:
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
 
rick_ahlAuthor Commented:
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
 
rick_ahlAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DalinCommented:
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
 
alamoCommented:
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
 
rick_ahlAuthor Commented:
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
 
alamoCommented:
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
 
rick_ahlAuthor Commented:
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
 
DalinCommented:
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
 
rick_ahlAuthor Commented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now