We help IT Professionals succeed at work.

MSComm control input property

pizarro
pizarro asked
on
720 Views
Last Modified: 2008-03-03
I want to use the MSComm active X control to get some data from a serial device.  I know that the device is sending me data because I have another device that lets me look at the data comming through the serial port directly, therefore, the availability of data is not an issue.
I have defined the input buffer to be of 1000 bytes. I also defined the inputlen property to be 0 so that I can read the entire contents of the buffer at once.
Here is the problem: when I define the input to be text, the input property only retrieves a few characters from the buffer eventhough I know the buffer has 1000 characters by looking at the inputbuffercount property.  The number of characters retrieved vary from 1 to 9; no more, no matter what I define the inputlen property to be.
If I define the input to be binary, the input property only retrieves half the buffer, no more, no matter what the buffer size is.
How can I retrieve the whole buffer?
P.S. By the way, my settings are 9600,n,8,1
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
The answer is very complete; however, the problem that I am facing is that whenever I invoke one of the methods you explained, I don't get the contents of the whole buffer.
For example, when I use polling, I do it so that the control reads 20 characters, but when I use the input method to retrieve the contents, I only get from 1 to 9 characters.  i.e. although the inbuffercount property says there are 20 characters in the receive buffer, I only get a few when I use the input method.
This happens when I am expecting the receive buffer to have text characters.
When I define the control so that I'm expecting binary characters, I only get half the size of the buffer.  Why is this?
It's interesting that InputBuffer has 20 characters, yet input is only showing from 1 to 9 characters.  Could you be getting some null characters or CHR$(0)'s that are terminating the VB string early?  

What exactly are you expecting from the Comm Device.

With BinaryMode, have you tried setting the input buffer to twice your need and gotten the full string?  Could your comm device have a different size byte that VB? Could you be looking at UniCode characters?  (Most likely not...)

Chris!

Author

Commented:
Forget the comment above. This works like a charm.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.