COM PORTS 3 & 4
COM PORTS 3 & 4
I need to access COM Ports ! through 4 in a program that allows me to use the OPEN COM statement. At one time there was some code posted here that showed how to force ports 3 & 4 to temprarily be 1 & 2 and then reverse back so that all 4 could have separate inputs/outputs. Any ideas? Also sorry, I forgot to put a subject header!
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
This can only be done on older computers like a 98. Newer PC's block port access unless you use Port Talk.
Below a routine swaps COM1 and COM3:
'To swap COM2 and COM4, with the same IRQ, use the swap routine below:
To swap them back just change the values back the same way.
Below a routine swaps COM1 and COM3:
Code: Select all
DEF SEG = 0 'DOS BIOS settings. QB will read COM1 with COM3 values
COM1L% = PEEK(&H400): COM1H% = PEEK(&H401) 'COM1 port values
COM3L% = PEEK(&H404): COM3H% = PEEK(&H405) 'COM3 port values
POKE &H400, COM3L%: POKE &H401, COM3H% 'change COM1 to COM3 settings
POKE &H404, COM1L%: POKE &H405, COM1H% 'change COM3 to COM1 settings
DEF SEG 'reset to default memory segment"
Code: Select all
DEF SEG = 0 'DOS BIOS settings. QB will read COM2 with COM4 values
COM2L% = PEEK(&H402): COM2H% = PEEK(&H403) 'COM2 port values
COM4L% = PEEK(&H406): COM4H% = PEEK(&H407) 'COM4 port values
POKE &H402, COM4L%: POKE &H403, COM4H% 'change COM2 to COM4 settings
POKE &H406, COM2L%: POKE &H407, COM2H% 'change COM4 to COM2 settings
DEF SEG 'reset to default memory segment"
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
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