COM port control - Need help!

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
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

COM port control - Need help!

Post by Patz QuickBASIC Creations »

Hello! It's been a while since I've been on...
Anyway, I need help using the COM ports. I am testing using QBasic, but I usually use PDS. I need help on sending values from a COM port to another computer. It's a basic program, but I can't figure out how to send out to a COM port. Any and all help would be appreciated. Thanks.

PATZ
Patz QuickBasic Creations


P.S. - The program sends ASC values from a COM port and another computer recieves them and shows the character on the screen. MY IDEA!!! PATENTED!!!
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

Hi there,

You can open the com port much like you open a file using the OPEN statement. The help file in the PDS or any QB should detail it quite nicely for you :-). just see about the OPEN statement.

Hope this helps.
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

woah... fast reply...
Anyway, I'm in the middle of a move, and my computer with PDS is currently packed. That's why I'm using QBasic right now. (I don't usually mess with libraries - I have Future 3 for PDS) Is it possible to do this in QBasic? I would like to get it running as soon as possible.

Also, is there amy sort of program that can tell what your COM port codes are?
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

Yup QBasic should do it just as good as PDS.

As for the com port codes? what do you mean, the physical address? Or the kind of code you can send?

If you go to your BIOS settings, com ports should be in there somewhere.

Typically com1 is $03f8 but you should only need to open "COM1:" not the address itself. :-)
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

The example in QBasic reads:
OUT port%, data%
- port% A number in the range 0 65535 that identifies the port
- data% A numeric expression to send to the port

Example:
x% = INP(&H3FC) <These confuse me
OUT &H3FC, (x% XOR 1)

So... I know what to do for the data% and what for the recieving side (COM trapping), but I can't send. Maybe PDS would work better for this.
And, to me, the OPEN COM statement makes no sense...

P.S. MystikShadows, ASCII-WORLD rocks! I just sent a contribution. I hope it becomes one of the great sites. Good Luck!
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

Excellent :-).....I see a few in there, what's the file name so I can sort it out and put it in it's rightful ASCII world section? :-)
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Moochthemonkey
Newbie
Posts: 5
Joined: Wed Apr 20, 2005 6:54 pm

Post by Moochthemonkey »

x% = INP(&H3FC) <These confuse me
Simply what is happening here is INP records the data at the address(&H3FC) and stores it in x%...

Besides, reading from the COM is a lot harder than it sounds...I originally tried to get this working with a PDA I had but got nothing working..
8)
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Usually the COM ports are accessed as files, with OPEN, PRINT # and INPUT #. Why are you doing it the hard way?
Comm ports are the same in QB and in PDS

This should help http://faq.qbasicnews.com/?blast=SerialComms
Sum Yung Guy

Post by Sum Yung Guy »

If you go to the tutorials section of petesqbsite, you should find Helppc, a MS-DOS App which has all the base addresses in your computer
Guest

Post by Guest »

Antoni wrote:Usually the COM ports are accessed as files, with OPEN, PRINT # and INPUT #. Why are you doing it the hard way?
Comm ports are the same in QB and in PDS

This should help http://faq.qbasicnews.com/?blast=SerialComms
Yes, I remember when you gave that to me a while ago. What's basically throwing me off is the damn protocol.
Guest

Post by Guest »

And that was me by the way, I don't know why it showed me as a guest. ^
Post Reply