Hi,<br>
Could any one tell me how to read a Serial Port? Any DOS based program(or location)to do the above will be more than enough.<br>
Regards and Thanks<br>
Charley
If you have VB or Access, you can do it.<br>
<br>
In VB or Access, go to the References menu item (in VB, choose Components, Access it's ActiveX components). Find the MSComm control. Check the box by the reference or component.<br>
<br>
Now you'll see a phone icon on the toolbox. Drag it to a form. In Properties (right click in Access and select properties, in VB hit F4). Set up the comm parameters, ie, 9600,n,8,1 or whatever the device on the other end is set to. You should, at least until you've tinkered with this, or know precisely what you're device is sending, set the RecieveThreshold value to 1, which means it will generate an event each time a character is recieved. <br>
<br>
Now, double click on the control to bring up the OnComm event. If you set the rThreshold to 1, you can expect at least one character here using the following syntax:<br>
dim x<br>
if me!mscomm1.commevent = 2 then '2=recieved data<br>
x = me!mscomm1.input<br>
end if<br>
However, and this is where it can get tricky, the buffer may have filled with several characters before the buffer was read. You can set the Input Length (not input buffer size) to 1, and now you know you'll be dealing with 1 and only 1 charachter. You can Dim a Global variable, and append each character to it just after it's read into the 'x' varaiable (in this example). Anyway, there you have it. There's much, much more that can be done, but that's the basics.<br>
<br>
--Jim Horton
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.