Click to See Complete Forum and Search --> : Reading From COM1
Mark Sreeves
Nov 28th, 1999, 04:19 PM
Is it possible to read from a serial port like reading a file?
If so, How?
I would normally use
strTemp = space(LOF(Filenum))
get filenum,,strtemp
to read in one 'gulp' but LOF doesn't seem to work on com1.
------------------
Mark Sreeves
Analyst Programmer
Mark.Sreeves@Softlab.co.uk
A BMW Group Company
john_murphy
Nov 30th, 1999, 08:23 PM
what you need is the mscomm component add one in your form and add the following code
dim data_in as any
MSComm1.CommPort = 1 ' We will be using Com1 as the default com port.
MSComm2.PortOpen = True ' Open the port for use.
data_in = MSComm2.Input
john_murphy
Nov 30th, 1999, 08:24 PM
sorry they should all have been Mscomm1 (if that is the object added)
Any more help please do not hesitate to contact me
john_m_murphy@hotmail.com
Co Galway
Ireland
Mark Sreeves
Nov 30th, 1999, 08:32 PM
Thanks for your reply but that's what I'm using at the moment. I wanted a 'lower level'
method!
------------------
Mark Sreeves
Analyst Programmer
Mark.Sreeves@Softlab.co.uk
A BMW Group Company
razzaj
Dec 1st, 1999, 03:43 AM
i kind of hesitated before posting this reply but then i noticed u were a proam analyst ... so there ... i dont really know how to do it on vb ... but i can tell how to do it on c++ ( i am not sure it worlks on vc++)
include the header dos.h (among the classical ones)
and to print to a port use this code :
outport (portnumber,byte)
to read :
inport (portnumber)
in ur case portnumber would be the decimal number of com1 which i think is 1016(for 3F8 in Hex) com2 is i think 760 for 2F8
i might have mixed com1 with com2 but the cxonversion is correct(i used a calculator :) )
i hope this helps ... i would apreciate any feedback because i am currently working on a project in c++ that use these functions ...
- regards -
- razzaj -
Bob Baddeley
Dec 1st, 1999, 05:37 AM
To outut to a port or input from a port using the stuff in the above post, you need to find a program called inpout.zip or inpout16.zip or inpout32.zip at http://www.lvr.com/parport.htm
This works for the parallel port, but should also work for the serial if you have the right port address. The specifics of how to do it are in the zip and on the page. Good luck,
bob
Mark Sreeves
Dec 1st, 1999, 06:06 PM
Thanks for your suggestions Bob and razzaj.
I haven't had time to look into them yet though!
------------------
Mark Sreeves
Analyst Programmer
Mark.Sreeves@Softlab.co.uk
A BMW Group Company
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.