03-02-2009 03:24 AM
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 .
03-02-2009 05:01 PM
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!
03-03-2009 01:08 AM
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.
03-03-2009 10:54 AM
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!
03-04-2009 04:20 AM
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.
03-04-2009 05:58 AM
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.
03-05-2009 11:29 AM
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!
03-12-2009 01:09 AM
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
03-12-2009 01:16 AM
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 =
03-12-2009 02:30 AM - edited 03-12-2009 02:39 AM