Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Redirect COM3 to either COM1 or COM2 ??

966 views
Skip to first unread message

Chris Rankin

unread,
Aug 30, 1997, 3:00:00 AM8/30/97
to

Hi,

We have a program which receives data over an RS-232 serial line. This
program is designed to listen at either COM1 or COM2, but the notebook
that we are using (we need a portable system) must use COM3. We have
contacted the program's original author, but we need a temporary
solution very quickly.

My original thought was that we could switch the names of the
COM-devices in the DOS list-of-lists so that any attempt to open COM2
would get COM3 instead. Unfortunately this doesn't work: we have since
learned that the program hooks IRQ3 and IRQ4 and bypasses DOS
completely.

I have studied Ralph Brown's INT list and seen that COM3 and COM1 share
the same IRQ. Is there a way that I could reprogram the ports so that
output from COM3 is sent to COM1 instead?

I am familiar with capturing interrupts and ASM in general, but have
never descended to the port-level before. I hear that you can really
damage your hardware with stuff like this, and so I am reluctant to
start until I have a clue what I am doing :-) !

One final thing: the notebook we have runs Windows 95, but booting into
MS-DOS mode is acceptable. Can anyone advise us, please?

Cheers,
Chris.

Chris Softley

unread,
Sep 2, 1997, 3:00:00 AM9/2/97
to

Chris Rankin wrote:

> Hi,
>
> We have a program which receives data over an RS-232 serial line. This
>
> program is designed to listen at either COM1 or COM2, but the notebook
>
> that we are using (we need a portable system) must use COM3. We have
> contacted the program's original author, but we need a temporary
> solution very quickly.
>
> My original thought was that we could switch the names of the
> COM-devices in the DOS list-of-lists so that any attempt to open COM2
> would get COM3 instead.

That was my first thought, too :)

> Unfortunately this doesn't work: we have since
> learned that the program hooks IRQ3 and IRQ4 and bypasses DOS
> completely.
>

> I have studied Ralph Brown's INT list and seen that COM3 and COM1
> share
> the same IRQ. Is there a way that I could reprogram the ports so that
> output from COM3 is sent to COM1 instead?
>
> I am familiar with capturing interrupts and ASM in general, but have
> never descended to the port-level before. I hear that you can really
> damage your hardware with stuff like this, and so I am reluctant to
> start until I have a clue what I am doing :-) !
>
> One final thing: the notebook we have runs Windows 95, but booting
> into
> MS-DOS mode is acceptable. Can anyone advise us, please?
>
> Cheers,
> Chris.

Hmm. Imn protectd mode you can 'virtualize' ports - Any attempt
to access a specific port address without the required level of
privelige (which a user program wouldn't have, esp. in a dos box under
win. 95) can be made to cause a general protection fault. The operating
system then handles this exception and
*could * redirect the port access to another port. Try posting to some
of the windows programming ng's - someone there may know how to use
Windows 95 virtual IO system to do this.

Failing that I am currently (coincidentally) working on something
very similar to this. I need to monitor what a particular device driver
is sending to the printer port, so I am writing a protected mode program
which will intercept these port accesses. If I get it working any time
soon I'll let you know. I'd mail you the source but at the moment there
isn't much to look at - just the entry and exit from protected mode.

Good luck,
Chris

Tom Lavedas

unread,
Sep 2, 1997, 3:00:00 AM9/2/97
to Chris Rankin

Chris Rankin wrote:
>
> Hi,
>
> We have a program which receives data over an RS-232 serial line. This
> program is designed to listen at either COM1 or COM2, but the notebook
> that we are using (we need a portable system) must use COM3. We have
> contacted the program's original author, but we need a temporary
> solution very quickly.
>
> My original thought was that we could switch the names of the
> COM-devices in the DOS list-of-lists so that any attempt to open COM2

> would get COM3 instead. Unfortunately this doesn't work: we have since


> learned that the program hooks IRQ3 and IRQ4 and bypasses DOS
> completely.
>
> I have studied Ralph Brown's INT list and seen that COM3 and COM1 share
> the same IRQ. Is there a way that I could reprogram the ports so that
> output from COM3 is sent to COM1 instead?
>
> I am familiar with capturing interrupts and ASM in general, but have
> never descended to the port-level before. I hear that you can really
> damage your hardware with stuff like this, and so I am reluctant to
> start until I have a clue what I am doing :-) !
>
> One final thing: the notebook we have runs Windows 95, but booting into
> MS-DOS mode is acceptable. Can anyone advise us, please?

I wrote a com port swapping batch file a while back and updated it a few
days ago. I know it will work in straight DOS mode, though it will not
work in a DOS window. It may work in general, if it is run from the
AUTOEXEC.BAT during the boot process. I have used this technique
(loading in AUTOEXEC.BAT) with a commercial IEEE 488 TSR program to
create a file handle that is accessable through an LPT port address from
within a Windows program (a speadsheet). I don't have a Win 95 system
handy to test it, but you're welcome to give the batch procedure a try.

:: SWAPCOM.BAT - A routine to swap COM port addresses
:: Tom Lavedas <tlav...@deltaelectronics.com>
:: http://www.deltaelectronics.com/tglbatch
::
@echo off
%8 if [%2==[ for %%v in (echo goto:End) do %%v Syntax: %0 P1 P2 (Ports
1, 2, 3 or 4)
> {S} for %%v in (21 31 41 32 42 43) do if %1%2==%%v %0 %2 %1
if %1%2==12 %0 M0:400L8 100 M100L2 0:402 M102L2 0:400 Q goto:Swap %1
%2
if %1%2==13 %0 M0:400L8 100 M100L2 0:404 M104L2 0:400 Q goto:Swap %1
%2
if %1%2==14 %0 M0:400L8 100 M100L2 0:406 M106L2 0:400 Q goto:Swap %1
%2
if %1%2==23 %0 M0:400L8 100 M102L2 0:404 M104L2 0:402 Q goto:Swap %1
%2
if %1%2==24 %0 M0:400L8 100 M102L2 0:406 M106L2 0:402 Q goto:Swap %1
%2
if %1%2==34 %0 M0:400L8 100 M104L2 0:406 M106L2 0:404 Q goto:Swap %1
%2
for %%v in (echo goto:End) do %%v Swap ERROR - Nothing done.
:Swap
>>{S} echo %1 %2
if not [%5]==[] for %%v in (shift shift goto:Swap) do %%v
< {S} debug > NUL
echo Swap Complete - COM%3 exchanged with COM%4
:End
del {S}

Please don't make me explain how it works. Suffice it to say that it
uses the DEBUG program to 'Peek' and 'Poke' around in the DOS data space
to make the swap. The group of IF statements are a kind of lookup table
for a little script used to run DEBUG. Beside those hints, my web site
general notes give insight into some of the other techniques used.

It can be limited to swap only even or only odd ports by removing
references to port pairs other than 13, 24, 31 or 42. Other pairings
would then result in an error message.

BTW, this procedure toggles the port swap. Performing the same swap an
even number of times restores the original configuration.

Tom Lavedas
-----------
Delta Electronics, Inc.
http://www.deltaelectronics.com/tglbatch/

PS: Wicked anti-spam address (backward AND no-spam). It's a wonder you
get any mail. My approach has been to stay out of places where I don't
want mail from and delete unwanted mail unopened. I only get two or
three unsolicited mail items a week.

Fred Pang

unread,
Sep 3, 1997, 3:00:00 AM9/3/97
to

You could try setting your COM3 Port address (3E8h) at memory address
0:400h (BIOS data for COM1 Port address). Then try run the application
with COM1.
If your application looks at the BIOS segment to pick up the COM port
address, it should run, as COM1 and COM3 has the same IRQ.
If it runs, you have a good application because most programmer,
including me, would not bother checking the BIOS data.

Good Luck
Fred HK Pang

>Hi,

>Cheers,
>Chris.

advill...@gmail.com

unread,
Jul 16, 2016, 7:44:33 PM7/16/16
to


Hi Fred.... I have a similar problem... i try to swap the COM1 with the COM2, because i need that COM1 been disable for a electronics ffdecoder card get this port for funtion special, but i can setup the ffdecoder card and the motherboard... i try all... i see a command called MODE COM1 but i dont know how cant swap this... for now im still very sad... please help me!!!

John R. Sowden

unread,
Jul 17, 2016, 7:28:26 AM7/17/16
to
On 07/16/2016 04:44 PM, advill...@gmail.com wrote:
>
>
> Hi Fred.... I have a similar problem... i try to swap the COM1 with the COM2, because i need that COM1 been disable for a electronics ffdecoder card get this port for funtion special, but i can setup the ffdecoder card and the motherboard... i try all... i see a command called MODE COM1 but i dont know how cant swap this... for now im still very sad... please help me!!!
>
I had a similar issue years ago. Go into DOS with a hex editor and
switch the interrupt table entries for the ports you wish to swap. I
even did it in CP/M to switch between 2 printers inside dbase II.

sbro...@gmail.com

unread,
Aug 11, 2016, 9:25:09 PM8/11/16
to
Den søndag den 17. juli 2016 kl. 01.44.33 UTC+2 skrev advill...@gmail.com:
> Hi Fred.... I have a similar problem... i try to swap the COM1 with the COM2, because i need that COM1 been disable for a electronics ffdecoder card get this port for funtion special, but i can setup the ffdecoder card and the motherboard... i try all... i see a command called MODE COM1 but i dont know how cant swap this... for now im still very sad... please help me!!!

Hi advil...
In the following I assume you are running pure DOS.
The MODE COMx - command is used to initiate the com-port with speed, stopbits etc. but the command can not handle a com-port switch, which you wanted.

To switch printer port LPT1 to LPT2 and back is easy to handle as others have said, but I don't know exactly what you want to do: Read from COM2 and send it to COM1 ? Read form COM1 and send to COM2 ? But I understand your COM1-port is occupied by a ffdecoder card. Please explain your wish.
Br
Svend
Message has been deleted

michalne...@gmail.com

unread,
Aug 24, 2018, 2:25:33 PM8/24/18
to
Hi,

There is a version of DOSBox for Windows 95. I know that it's usually completely pointless to run DOSBox on a machine that already has DOS on it, but if you open the DOSBox config file and change the line:

serial1=dummy

to

serial1=directserial realport=COM3

for COM1 to COM3, or

serial2=dummy

to

serial2=directserial realport=COM3

for COM2 to COM3 and then just run the software in DOSBox instead of DOS itself. You sacrifice some speed, but any attempts to write to/read from COM1/COM2 (depending on the configuration) will end up writing to/reading from COM3.

Good luck,
Michal
0 new messages