LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i get Pci Parallel Port I/O range ?

Hi

 

I am currently writing a program which as to support Writing and Reading to a Pci Parallel port.

Is there a way of getting the I/O range (Address) for writing to the port using the outp ?

Help share your knowlegde
0 Kudos
Message 1 of 29
(11,716 Views)

on a normal Windows configuration, the fact that your parallel port is on the PCI bus does not change anything: the port should still be exposed as any other parallel port under the name "LPTX:" (where X is the port number). there are standard function calls in the windows SDK for accessing a parallel port (opening, reading bytes, sending bytes): look for CreateFile() as well as SetCommConfig() (which, unlike its name suggest, is also capable to speak to a parallel port and lot of other stuffs you don't even have an idea what it is made for).

 

(why does everyone absolutely want to use 'outp' ? 30 years of thoughtful operating system design advances to provide HAL, device drivers, plug-n-play, etc. all this thrashed because people absolutely want to stick with an instruction dating from the 8086 days...)

 

 

 

0 Kudos
Message 2 of 29
(11,704 Views)

Hi Shako,

 

There are 'usual' assignments for port io ranges, the base addresses are:

0x378 - LPT1; 0x278 - LPT2; 0x3BC - LPT3

 

However, these are not absolute. For portability of your finished application, you should look the address up from memory (which is assigned by the BIOS), using the ReadFromPhysicalMemory() function.

 

For example, to look up LTP1, use:

lptNum=1;

ReadFromPhysicalMemory (1032+lptnum*2, &lptIOAdr, 2);

 

This works for lptNum's between 1 and 4, I have not tested it for ports above LPT4 .

 

All this and much more can be found in an excellent document on low level parallel port comms, found at:

http://www.beyondlogic.org/spp/parallel.pdf

 

cheers,

Diz

 

 

 

0 Kudos
Message 3 of 29
(11,648 Views)

er, sorry, that example code should have read:

 

 

lptNum=1;

ReadFromPhysicalMemory (1030+lptnum*2, &lptIOAdr, 2);

 

Diz.

0 Kudos
Message 4 of 29
(11,646 Views)

I have tried both of these methods and still doesnt work.

I have been on other forums and they told me the same things.

 

I have also tried the VISA driver but i get a time out when i try to read from the port.

I think that is because of i have to write one byte at a time but im not sure about that.

 

The base addresses only work for onboard parallel ports and i have already implemented this in my application.

I am not quite clear on how to use CreateFile() in this case.

Could you please show me if you know how ?

 Is there any other ways to write and read to the parallel port ?

Help share your knowlegde
0 Kudos
Message 5 of 29
(11,635 Views)

I am 99.9% sure I have used the BIOS lookup to access a parallel port which was on an extension card.

It was back in the days when PCs had ISA and/or PCI slots, I cant remember which was used.

Anyway, a few questions:

 

Have you verified that this port is set up correctly (windows drivers, etc)?

Have you tried using the (first) I/O range reported in windows Device Manager?

Out of curiosity, how many ports do you have installed?

 

 

0 Kudos
Message 6 of 29
(11,590 Views)

Hi Diz@work

 

I have used the drivers that came with the pci card.

I have been using this functions to retrieve the memory address (Range),

 

 

int PortNo;//This will be the number of the lpt port.
unsigned int wAddr;
int iport;//is used by outp();

wAddr=0x0408+(--PortNo*2);
iport=0;
ReadFromPhysicalMemory (wAddr, &iport, 2);

 

 

 

But this only seems to work with On Board Parallel ports.

I have attached my port layout.

Com1 and 3 is stanard and not used.

Help share your knowlegde
0 Kudos
Message 7 of 29
(11,587 Views)

What is the I/O range for your port? (right click on MosChip ... , properties, resources) It's not a very nice way of doing things but you may be able to enter this directly into your code.

 

It shouldnt matter, but is there a reason why you have set your port to LPT3?

0 Kudos
Message 8 of 29
(11,571 Views)

I currently do have a maunal insert of this io range in my program and it does work.

The LPT was set to 3 automatically.

 

The problem am have is getting this range automatically,

So the use does not have to in put this Range.

 

Help share your knowlegde
0 Kudos
Message 9 of 29
(11,562 Views)

dummy_decoy wrote:

on a normal Windows configuration, the fact that your parallel port is on the PCI bus does not change anything: the port should still be exposed as any other parallel port under the name "LPTX:" (where X is the port number). there are standard function calls in the windows SDK for accessing a parallel port (opening, reading bytes, sending bytes): look for CreateFile() as well as SetCommConfig() (which, unlike its name suggest, is also capable to speak to a parallel port and lot of other stuffs you don't even have an idea what it is made for).

 

(why does everyone absolutely want to use 'outp' ? 30 years of thoughtful operating system design advances to provide HAL, device drivers, plug-n-play, etc. all this thrashed because people absolutely want to stick with an instruction dating from the 8086 days...)

 

 

 


Probably because 30+ years of operating system design has produced an awful lot of Rube Goldberg machines, sometimes toggling a bit is just toggling a bit.

 

If you can clue me in on uisng CreateFile() and SetCommConfig() to open a usb to lpt port adaptor (add printer device ID: USB001) so I could use WriteFile() to set the 8 output bits and ReadFile() to get the state of the 5 status bits I'd solve a lot of problems in minutes instead of days.

 

Of course this just changes the problem from figuring out the dynamic mapping of IO addresses to figuring out the dynamic mapping of com port devices.

 

--wally.

 

0 Kudos
Message 10 of 29
(11,476 Views)