INPOUT32/X64 Works with SOME PCI cards

My x64 port of InpOut32
Moundtop
New User
Posts: 4
Joined: Fri Apr 16, 2010 1:35 am

INPOUT32/X64 Works with SOME PCI cards

Post by Moundtop »

In my MATLAB thread on this forum I noted that I have found that both inpout32 and inpoutx64 work quite well with SOME PCI printer port cards (contrary to reports on this forum and at logix4U).
Here's the story in a nutshell. MOST of the PCI, PCMCIA, ExpressCard and Cardslot add-on peripherals that implement printer ports (i.e., LPT1, etc.) use a USB chipset that emulated the printer port via a complex serial driver that cannot be used to implement real-time digital I/O. These are the cards that are not useful with inpout32 and inpoutx64. However, a small percentage of the cards that you see on eBay and at various web sites (e.g., the SYBA SD-EXP50021 Expresscard with parallel port and 2 serial ports) support TRUE PARALLEL PORT interfaces that can be used successfully with inpout32 and inpoutx64. I have used various PCI add-on cards and Expresscard add-ons successfully under 32-bit Windows 2000, XP and Vista and most recently on 64-bit Windows 7. Look for a card that implements the interface using either the MOSCHIP MCS9901 chip (1 parallel port, 2 com ports) or the MCS9805 (1 parallel port). Sometimes these chips are listed as NETMOS instead of MOSCHIP...
Good luck with your interfacing exploits...and many thanks to Phil and Logix4U for making the inpout322 and inpoutx64 device drivers available to the world!!!
jroxtheworld
New User
Posts: 3
Joined: Tue Feb 08, 2011 8:14 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by jroxtheworld »

Hey Moundtop!

I was wondering what version of inpout32 you used for your tests. Since I didn't manage to get it to work with a MCS9805 pci parallel port card. I would be glad for some code as well. The pci card has a port address of 0x1110.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by phil »

Likewise, it might be useful to specify what version of InpOut32 and what OS you are using?
(I dont know the answer to your question, but I imagine at least v1.3.0.0 of my port if it was working on Windows 7!)

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
jroxtheworld
New User
Posts: 3
Joined: Tue Feb 08, 2011 8:14 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by jroxtheworld »

I'm running on a Windows 7 (32bit). The problem is that I'm using a JAVA JNI Port (Jnpout32pkg_v10.zip) which can be found here (http://www.hytherion.com/beattidp/comput/pport.htm) and I'm not sure what version has been used in this port.

If anyone has successfully used the InpOut32 or maybe even your port to 64bit with Java, it would be great if the person could share the code.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by phil »

OK that is looking rather old - so its almost certain it wont be using my port. The orriginal InpOut32 should work on 32bit Windows 7 but there are potentially all sorts of UAC admin issues. The driver must be installed with Admin rights - I accomplish this using an elevated installer EXE but that wont work with the old inpout32 DLL (or driver).

Could you try running your java app as administrator (or an account in the local administrators group) to see if it makes any difference?

I don't know of anyone else using this through Java so I cant really suggest much more. Sorry about that!
It might be a good idea to try my port and test code (.net ideally) to see if you can actually use the PCI card - because right now, with this JAVA bit also, there are perhaps more unknowns in the mix which could be making life more difficult. The test app should be sufficient to see if you can write to the address of the parallel port (and if you can monitor the outputs on the port to be sure - even better).

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
jroxtheworld
New User
Posts: 3
Joined: Tue Feb 08, 2011 8:14 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by jroxtheworld »

Thanks for the hint there ...actually I was able to run my Java code (webstart) as an administrator and it worked!!!! So it's actually possible with inpout32.dll!
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by phil »

Well done. Don't expect the orriginal InpOut32.dll to work on an x64 machine though :(
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
wyoung
New User
Posts: 1
Joined: Wed Jul 20, 2011 1:21 am

Re: INPOUT32/X64 Works with SOME PCI cards

Post by wyoung »

I'd like to share with you my experience with a PCI parallel port. On my application I've had no issues with onboard ports. I basically am just using Inp32() and Out32().

With the PCI version, the address the port took up was E000-E007 instead of the normal 0378-037F. And when I tried passing the E00X address to Out32 it would give me an arithmatic error. I am using VB.NET 2005. The problem is E000 needs an unsigned short, not a short. And that is the parameter for the port address. I was able to get it to work by downloading the source, changing the parameter to an unsigned short and re-compiling inpout32.dll. I dont know why it was giving me an error passing an unsigned short to a short since they occupy the same amount of space but it was.

Overall, it might be nice if for future versions you change port address from a short to unsigned short to allow for those higher addressed PCI cards. Just wanted to provide some feedback for you and anyone else having similar issues. Great DLL, its pretty ridiculous Microsoft neglected to put any parallel port support in .NET, but I suppose it is a dinosaur now days.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by phil »

Thanks for the info.

Are the DLPortIO functions I added not working in this area - or do they suffer the same problem I wonder.

As you are probably aware, I didn't write the code, I just ported the driver to x64 and added a few extra calls (that I never properly tested!). I'm glad you managed to get it working, but one worry I would have changing the interface, it could break any application already using it. So I think it would be better to introduce new functions with the correct DLL interface.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
WimWWimw
New User
Posts: 4
Joined: Mon Dec 19, 2011 4:54 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by WimWWimw »

but one worry I would have changing the interface, it could break any application already using it. So I think it would be better to introduce new functions with the correct DLL interface.
True. Only copying Out32 to Out32_2 with the same body but an unsigned address parameter

Code: Select all

void	_stdcall Out32_2(ushort PortAddress, short data);
would help a lot. However, I presume the driver has to have the same function overloaded to?
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by phil »

No the driver does not have any of these function overloads. The drive is controlled by IOCTL's I think - the code is all there for anyone to see/change and the dll can be changed/fixed as much as anyone wants (as you have already done!) without having to re-sign the driver (that is where it gets sticky - even I cant do that!).

To be honest, while I'm happy to keep hosting the files and to some extent this forum, I have no use for Inpout32 these days so I'm not exactly keen to keep making changes to something that is a) not mine in the first place, b) open source, c) not something I actually use any-more.

Ideally Logix4U would have gotten their heads round x64 by now and this port could be retired or at least updated and hosted by them, but I guess that they are in a similar position and don't want to support legacy stuff like this (I can only presume that by their general lack of comment/communication on their web site).

Having said that, I will every now and then go on an update splurge with these things. I suppose its handy to have somewhere these things are all consolidated (and where people can actually talk about them and get a response, even if its not from the authors lol).

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
WimWWimw
New User
Posts: 4
Joined: Mon Dec 19, 2011 4:54 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by WimWWimw »

Weel, I decided to try the hard way and make the fix myself, even though as an objectPascal regular, for me it's a long time no C...

The way I see it, the exported function could easily be doubled with an unsigned pendant:

Code: Select all

void	_stdcall Out32(short PortAddress, short data);
void	_stdcall Out32u(unsigned short PortAddress, short data);
The original out32 relays either to _outp, which already takes an unsigned short for the address, or is transfered by LOWORD to Buffer, which in tur also is of (unsigned short *). Therefore, the modification may be linited to

Code: Select all

void _stdcall Out32(short PortAddress, short data)
{
	Out32u(PortAddress, data);
}

void _stdcall Out32u(unsigned short PortAddress, short data)
{
  // the original implementation
}
The new Out32u needs be exported, of course. I even think that it wouldn't break existing code if one would just change out32() to the unsigned form, but I'd rather avoid guessing that.
Given that the adddress cannot possibly be negative, and seeing the iplementation, I think the signed form is but a historic mistake.

I cannot test it right now, and I don't know whether this is my only problem, but possibly later this week I can tell more.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by phil »

Thanks Wim,

I'm not sure I understand why you have a problem with the signed short, at the end of the day its just 2 bytes. I guess it does depend on the code in the DLL and its been years since I looked, but your right, there should not be a bug difference.

The only obvious problem I can think of is if somewhere it gets stored in a larger (or smaller) structure i.e. cast to an 32bit INT (or maybe a 64bit one :) ). That would cause havoc - maybe that's the problem!

Anyway let me know what your find.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
WimWWimw
New User
Posts: 4
Joined: Mon Dec 19, 2011 4:54 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by WimWWimw »

Well, I am not a C-man, so perhaps I am reading the code wrong. But it seems to me that both calls are by value. That would mean that with addresses upto 7EEE there's no problem, for they can be represented both by signed and unsigned two-byte integers. Higher address values, such as my CD00, are interpreted by the functions expecting a signed short as negative numbers. So my CD00 (56320) is taken for a -9216. When this value in turn is assigned to any unsigned variable, the code ought to raise a range check/integer underflow-error. Or does C just shift the 16 bits ? In programming languages I am familiar with I'd need a pointer operation for that.
WimWWimw
New User
Posts: 4
Joined: Mon Dec 19, 2011 4:54 pm

Re: INPOUT32/X64 Works with SOME PCI cards

Post by WimWWimw »

:D Well, that seems to work! The motor is running now. Apparently I don't understand the role of the sys driver files. I have a 32bit application running on XP64 (AMD). According to dbgView it's loading the x64 driver. But it doesn't work until both files have been copied tot system32\drivers.

I think other people here will be helped if you'd take over my suggestion into the official inpout-dll?
Post Reply