
recieve data from com1 vb
Quote:
>I have a scale that is connected to com1. The only thing the scale
>company has told me is that it is ascii characters and that %P is the
>command to call the scale. I need to write the first 8 characters
>from what the scale send to c:\testing\weight.txt
>I know you are supposed to use MSCOMM and I have seen basic code but
>it doesn't seem to work, and I do not know where that %P goes. PLEASE
>HELP!!....
>Ricky,
Depending on the scale being used, the "%P" may very well all that's required to
get the scale to respond - no CRLF needed.
Look up the MSCOMM control in Help and determine how to read data from it and
send data to it. As previously mentioned, you also need to know the serial line
parameters (speed, parity, stop bits) - the vendor should have provided that
info and a manual (usually with sample program snippets). First call the vendor
and get the rest of the documentation, then go online and see if their web site
has code samples.
.
Send the characters "%P" to the scale and read the response back from it.
MSCOMM can be used in either polled mode (you ask it for data when you expect
data to be there) or in event mode (it alerts the program that there's data to
be read). Polled mode is probably simpler for a beginner, and you would only
expect data from the scale when you have sent a request to it.
If you were in Atlanta (instead of Columbus, MS), I could come by with some test
gear (laptop with RS-232 'sniffer' software, a hardware speed monitor, and a
breakout box) and probably have all the info you needed in a couple of hours.
It would cost you $50/hr, but that might be cheap considering the level of
frustration I read in your post ;-)
For more info on using the MSCOMM control, you may want to look at someone
else's code. Go to
http://www.htservices.com/Tools/VisualBasic/SerialCommunications.htm and scan
the page for "Poor Man's Serial Instant Messenger". Download the file and you
will have a very basic VB6 communications program that uses the MSCOMM control
to send and recieve data. You should be able to adapt this to send the request
to the scale and read the response back from it. You would get the response
into a string, then open the file and print the string to the file. If you need
further help after exploring the program code, post or send email.
VB3 source code: http://thelabwiz.home.mindspring.com/vbsource.html
VB6 source code: http://thelabwiz.home.mindspring.com/vb6source.html
Fix the obvious to reply by email.