Communcation with Com 3 & com4

DOS specific questions.
Post Reply
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Communcation with Com 3 & com4

Post by Gablea »

Hi all

I have a strange problem that I am not sure how to sort.

I have Com 3 and 4 in MS-DOS (they work) I have set the band rate etc. via Mode (as FreeBASIC can not seem to handle them in DOS directly)

I can open the port and send data down it but my application does not get anything back from the port.

I need to have 2 way communication on COM4 as that is the Port my chip & Pin terminal is assigned to (RS232 commutation for processing of sale data from the terminal)

In windows this works fine (So i know it is not the software) does anyone have any ideas what I need to do to allow two way communication via Mode and Open "Com4" for random

Code: Select all

	   If CardType = "VXTerminal" Then
		   Print "    Establishing communcation to VX510 terminal"

		   If CardComType = "Com" Then 
				CardMachinePort = 4
				ComSetVX510 += ",CS0,DS0"
				Open Com ComSetVX510 As #CardMachinePort
		   End If
		  	
		   If CardComType = "ComMode" Then
				CardMachinePort = 4
				Open Com ComSetVX510 As #CardMachinePort		   	
		   End If
	   End If
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Re: Communcation with Com 3 & com4

Post by kiyotewolf »

Usually you have to overwrite the COM assignments, moving COM1 to COM3, and such, reassigning them, before you can use them.



~Paul
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Communcation with Com 3 & com4

Post by Gablea »

So how do I do that?

Does anyone have any code that I can use to swap the ports

I assume I would have to close the port before I could swap it to the other port

if someone has some code for me that would be great

OR is there a way to talk DIRECTLY to irq address of the comport?

Com1 = 3F8, IRQ 4
com2 = 2F8, IRQ 3
com3 = 3E8, IRQ 11
com4 = 2E8, IRQ 12
* this is from the BIOS Screen

I have tried to open the port wit the IRQ stated but nothing

I can mode set com3 and 4 but when I try to send data to the ports it come ups and says Write error on COM3 / COM4
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Communcation with Com 3 & com4

Post by MichaelW »

One possibility for where the problem lies is with the IRQ assignments for COM3 and COM4. IRQ 8 to 15 are on a different interrupt controller than IRQ 0 to 7, and the driver may not be able to accommodate this, or at least not as it is currently configured. Will the BIOS setup allow you to change the IRQ assignments? If so, as a test you could swap the current assignments (to COM1/IRQ11, COM2/IRQ12, COM3/IRQ4, and COM4/IRQ3) and then try COM3 and COM4 again.
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Re: Communcation with Com 3 & com4

Post by kiyotewolf »

COM ports share the same IRQ address. COM 1 and 3 use the same IRQ. To swap the port addresses and keep the same IRQ, just swap the ports with the same IRQ! Below a routine swaps COM1 and COM3:"


Code:

DEF SEG = 0 'DOS BIOS settings. QB will read COM1 with COM3 values
COM1L% = PEEK(&H400): COM1H% = PEEK(&H401) 'COM1 port value
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"

'To swap COM2 and COM4, with the same IRQ, use the swap routine below:

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


This is QBasic code. Needs to be upscaled to FB code.



~Paul
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Communcation with Com 3 & com4

Post by MichaelW »

kiyotewolf wrote:COM ports share the same IRQ address. COM 1 and 3 use the same IRQ.
That was the norm at one time, but even in the “old days” I can remember having serial port adapters, and motherboards with integrated serial ports, that could be configured to use other IRQs. In recent times it depends on the port hardware and/or the system BIOS. And in any case, Gablea posted his BIOS settings.
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Re: Communcation with Com 3 & com4

Post by kiyotewolf »

Wouldn't it still be relevant, since he's using DOS?



~Paul
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Communcation with Com 3 & com4

Post by MichaelW »

kiyotewolf wrote:Wouldn't it still be relevant, since he's using DOS?
I can’t see how. The port hardware is set up to decode specific I/O addresses and to assert a specific IRQ, and the drivers have to work with the hardware.
Post Reply