LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Pci Parallel Port address to write or read too ?

Hi I am currently editing a program written for windows 98.

This was the code for get the address of the parallel port :

 

int GetPrinterAddr (int PortNo)
{              
 int iport;
 unsigned int wAddr;
  
 wAddr=0x0408+(--PortNo*2);
 iport=0;
  ReadFromPhysicalMemory (wAddr, &iport,2);
 return(iport);
}

 

This code reads a segment of memory in the bios and gets the address of LPT 1,2 and so on.

 

Can anyone help , I need to find a different way gets the address from a Pci slot in Parallel port ?

 

Its Urgent .

Help share your knowlegde
0 Kudos
Message 1 of 15
(10,062 Views)

Hi Shako,

 

I'm not quite sure about the details of the problem you are having.  Are you trying to modify this code to find the address of parallel ports on a PCI card?  Please provide a bit more detail and I'd be happy to help!

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 2 of 15
(10,036 Views)

The code i gave is the code i am currently using and it does not work when a pci parallel card is inserted.

What the program does , it takes a binary image file which my other program creates and writes it to EEPROM's through a parallel port.

I would like to create new code to find avaliable parallel ports if its on board or a Pci Addon.

 

Help share your knowlegde
0 Kudos
Message 3 of 15
(10,022 Views)

Hi Shako,

 

I would recommend using the VISA driver to do this port recognition for you (free download here).  The VISA API will allow you to open a reference to your port using this code:

 

viOpen (defaultRM, "ASRL1::INSTR", VI_NULL, VI_NULL, &instr);

 

 where "ASRL1::INSTR" is the device resource name.  You can find the resource name for your ports in Measurement& Automation Explorer, located in Start»All Programs»National Instrument»Measurement& Automation.  Once it is open, expand devices in the left pane, the expand serial and parallel.  in the window to the right, you should see all parallel ports (including the PCI ones) along with their resource name.

 

Once you have the reference from the viOpen function, you can write with this function:

 

viWrite (instr, (ViBuf)stringinput, (ViUInt32)strlen(stringinput), &writeCount);

 

More information on these functions can be found in the NI-VISA help.  In the meantime, let me know if you have any questions about NI VISA and I'll be happy to help!

 

 

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 4 of 15
(10,008 Views)

Thanks for your help. I will most definitely try that out.

I currently changed the program to let the user input the Address and it works.

Only down fall is that not all pci Parallel Ports Give you the address.

 

If I have any question I will most certainly ask.

Thanks again.  

Help share your knowlegde
0 Kudos
Message 5 of 15
(9,991 Views)

Hi is there a way of getting the Port Resource name via code to add to a list from which the user can select, example ("ASRL1::INSTR" )

Cause the names vary on different pc's.

Help share your knowlegde
0 Kudos
Message 6 of 15
(9,986 Views)

Hi Shako,

 

There are a number of prewritten VISA examples included with the VISA driver. These are located in C:\Documents and Settings\All Users\Documents\National Instruments\NI-VISA\Examples\C\General.  The example FindRsrc.prj shows how to get a list of all instruments attached to the computer.  Let me know if you have any other questions!

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 7 of 15
(9,954 Views)

Hi Shako,

why you not reading the parallel port-address from windows registry ?

 

WIN98SE: 

    HKLM\System\CurrentControlSet\Services\Class\Ports\               (enumerate all ports on your PC)

and 

    HKLM\Enum   (PortName, LogConfig, etc... of ports)

 

 

for sample on my PC with W98SE:

    HKLM\System\CurrentControlSet\Services\Class\Ports\0002          (LPT1 on board)

        InfSection = "LptPort"

        MatchingDeviceId = "*PNP0400"

    HKLM\System\CurrentControlSet\Services\Class\Ports\0005          (LPT2 on PCI card)

        InfSection = "LptPort"

        MatchingDeviceId = "NMMFENUM\PCI9710_LPT"

 

Address of ports are: 

    HKLM\Enum\ACPI\0\LogConfig =

    HKLM\Enum\NMMFENUM\PCI9710_LPT\68F000&PORT_0002\LogConfig =

 

 In LogConfig are (device driver resource list) information of port-address.

 

I'm Hope that this may be way for you ?  (My softw. working like this nice 🙂

Regards

 

 

0 Kudos
Message 8 of 15
(9,862 Views)

Hi Shako,

sorry - small bug in my msg - this is correct:

 Now is morning here 😞

 

Address of ports are: 

    HKLM\Enum\ACPI\*PNP0400\0\LogConfig =

    HKLM\Enum\NMMFENUM\PCI9710_LPT\68F000&PORT_0002\LogConfig =

 

0 Kudos
Message 9 of 15
(9,860 Views)
Hi paper

I have researched many ways of solving this problem and all the places i checked say that on Windows XP looking in the registry wont work.
I did try it and it didn't work cause there is no registry that i could find regarding the pci parallel port addresses.
The solution that Al B suggested seems like the most solid solution.
Message Edited by Shako on 03-12-2009 09:39 AM
Help share your knowlegde
0 Kudos
Message 10 of 15
(9,856 Views)