QBasic communication through COM1 port? (reader question)

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Pete
Site Admin
Posts: 882
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

QBasic communication through COM1 port? (reader question)

Post by Pete » Thu Nov 13, 2008 4:48 pm

Question from QB Express reader Eric:

Hi Pete,

I am going to try to use Qbasic to talk to a piece of equipment through the COM1 port via RS232. I did this may years ago but I have forgot how to do this. I will need to both read and write information. Can you tell me the correct command, format and if I need to do any variable setups.

Thanks,
Eric

User avatar
burger2227
Veteran
Posts: 2378
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Thu Nov 13, 2008 5:22 pm

There are a couple of ways to deal with COM ports in QB. You can use the OPEN COM1 statement and use LOC(1) to find if data was received, INPUT$(1, bytes) to read the data, and PRINT #1 to transmit data.

You could also use INP and OUT to deal directly with the COM port address registers. I have a tutorial called Q-Basics.Zip at:

http://www.qbasicstation.com/index.php? ... &filecat=3

Scroll down to find it and download. Check Chapter 11 for port programming. If you use NT or XP you may need PortTalk (free on web).
Read the PortTalk install procedure and useage to allow a port address acess!

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Dav
Coder
Posts: 14
Joined: Thu Jul 15, 2004 9:23 am
Contact:

Porttalk

Post by Dav » Fri Nov 14, 2008 9:33 pm

Hey, that Qbasic/PortTalk package looks interesting. Thanks for the link.
Visit Dav's Qbasic Site at: www.qbasicnews.com/dav

User avatar
burger2227
Veteran
Posts: 2378
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

NOTE!

Post by burger2227 » Mon Nov 17, 2008 6:31 pm

One note of caution about PortTalk.

If you do not designate a port address, it may cause your mouse to quit working! Without a port address, it opens all ports for access, shutting off the mouse perhaps.

Welcome Dav,

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Post Reply