inpout32_x64.dll issue writing/reading 128

My x64 port of InpOut32
Post Reply
CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

inpout32_x64.dll issue writing/reading 128

Post by CliffB » Thu Jan 13, 2011 2:31 pm

Hi everybody

I have successfully installed the dll on Windows 7 x64 using the supplied installation package and have tested it using both my own C# 2008 application and the provided .net test code. The port is set to ECP although I have also tested it with it set to SPP in the BIOS and it works apart from one serious issue.
When in ECP mode I have checked that the mode register is set to 000 to force SPP mode. No external hardware is attached to the port for any of the tests.

The issue is that if I write 128 to the output port it returns 8364, if we ignore the fact that the test button is marked 'byte read' (!!!!) the value is clearly not the 128 that has been written. I've confirmed that this occurs on two completely different machines The strange thing is that any other value (eg 129, 1, 0 etc) returns correctly. I have seen other issues when writing and then reading but the use of 128 as the written value is repeatable. This test has been made after a reboot and only using the .net test code supplied and without external hardware attached.

Does anyone have any idea as to why it should fail in this fashion? I have considered it being an issue with RLE mode and have disabled that prior to the test (it shouldn't matter anyway in SPP mode) but the fault persists.

Help!

Cliff

User avatar
phil
Site Admin
Posts: 5923
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by phil » Thu Jan 13, 2011 5:21 pm

Hi Cliff,

I'm not really that expert on parallel ports these days (its been far too long since I played with them back in the days of MS Dos). So I don't think I can help with this one.

You might find more information or help on the Logix4U forums (seeing as they actually wrote the driver their user community will be larger). If you suspect a bug (and the return of 8364 might be!) then there are two possibilitys, 1) if its in the driver then we will probably have to go back to logix4u (again, I only ported to x64 and unless its a mistake in the port I may not have the understanding required to fix it) and any new driver will need to be resigned for x64 - which could be a problem. 2) If its not in the driver and just a bug in the DLL that uses it, I can easily update the DLL.

I hope you find the answer to the problem (and if you find it elsewhere, please let us know), I wonder if 128 (top output pin set I presume) means something special, or if the pins are floating (not tied to zero), but in that case I would expect random reads every time.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Thu Jan 13, 2011 6:36 pm

Hi Phil

Thanks for the reply.

I've not mucked about with parallel ports for ages either. it was so much easier when you could simply address the registers directly and avoid all the ring 0 stuff. However.... I've not much idea where the issue is and short of getting right into the driver code and compiling my own flavour it will be almost impossible to debug the problem. I thought I'd just ask on the forum in case anybody else had come across the issue and had an obvious answer. The real irony is that since parallel ports are now ancient history it's almost pointless to write any code to use them in the first place. With the USB flavour being completely incompatible life will get impossible.

Anyway to the issue: the problem is consistent and it occurs even when SPP mode is selected which removes the issue of random read values since one is only reading back the output register. (IIRC even that wasn't possible in the LS374 days since the devices were output latch only... reaches for very elderly IBM XT manual...). Since most other values (129, 1 etc) work fine it could well be a DLL issue. I will do some more digging and will let you know in due course if anything turns up.

Cheers

Cliff

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Thu Jan 13, 2011 8:38 pm

Hi again Phil

Some more information: it seems to work if I use DlPortreadPortUShort and obviously mask off the msb by ANDing the result with 0xff. It still consistently fails if I use the standard Inp32_x64 command.

Maybe if you get a few moments you can have a look at the DLL to see if there is any obvious issue, although I do suspect that it's some nuance of the hardware.

Cliff

User avatar
phil
Site Admin
Posts: 5923
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by phil » Thu Jan 13, 2011 9:02 pm

Had a quick look, it appears the difference between the basic Inp32 and the DLPortIO funcitons (that I added) is that I initialise the read buffer with NULL's before using it.

So it looks like with Inp32, the buffer is unintialised, causing "random" values to be in it.
Then it only seems to read 1 byte into the 3 byte buffer, which means it will leave bytes 2 & 3 as they are (uninitialised).

That might explain the problem.
Using DlPortReadPortUchar would be the simple solution was that returns a single UCHAR (byte). Quite why Inp32() returns a short and not a byte is beyond me because it only ever reads a byte from the port - but I cant go changing that because it will break anything using the InpOut32 interface.

However looking at the code, I cant really see how DlPortReadPortUshort is doing the right thing also (its casting things badly) - it will probably work but it seems a bit messy.

Anyway, it seems that I might be able to fix this without changing the driver.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

User avatar
phil
Site Admin
Posts: 5923
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by phil » Thu Jan 13, 2011 9:32 pm

OK Made a few changes - should make it work better and fix the issues mentioned above.
If you want to try it before I make it live (just in case) let me know and I can PM you the new binary package.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Thu Jan 13, 2011 11:04 pm

Thanks very much for taking the trouble to look at the issue. It does indeed seem strange that a short is returned when only a byte quantity is involved. Traditionally such things were done to either keep a 16 bit hardware read happy (even if only 8 bits were valid) or sometimes for compiler efficiency.
I can't see why only some values would cause the problem but I'm more than happy to test it out if you want to send a new version over to me.

Noted about your suggestion of using DlPortReadPortUchar. I may try that as well in any case and report back.

Anyway I'll await your latest version!

Cliff

User avatar
phil
Site Admin
Posts: 5923
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by phil » Thu Jan 20, 2011 12:36 am

Hi Cliff, how did you get on with that new version I sent you.
Was it any better/different? Should I publish it?

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Tue Jan 25, 2011 2:56 am

Hi Phil

I guess you never got my PM then....

I'm afraid it made no difference to the problem. I'm still using the DlPortreadPortUShort function.

Cliff

User avatar
phil
Site Admin
Posts: 5923
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by phil » Tue Jan 25, 2011 9:18 pm

Oh I must have missed or perhaps it slipped by with all the spam Ive been suffering on the forums since 2011 started (fixed now I hope!)

Thanks for the update - I have, in the mean time, put a new version online that might just work (I found some more problems). v1.5.0.0 - its worth a try but if the DLPortIOShort is working then I guess its not all that important. The link is the normal one on my inpout page here.

I have also updated the .net samples a little bit (mostly the vb.net one) and updated the source archive - although I cant remember if thats the 1.4 source or the 1.5 source.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Wed Jan 26, 2011 1:37 pm

Hi Phil

I'll check it out later and let you know.

Cliff

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Fri Jan 28, 2011 11:47 am

Hi Phil

Sorry to say that it is still not working correctly. The issue is easy to replicate (here at least). Just write 0 to the port, read it back (it is zero) then write 128. It will read back 0xAC. If I clear the port and then write 1, 3, 7, 15 etc it is fine until I write a 1 to bit 7. It seems that if bit 7 is set it is going into another mode. I've checked that my port is configured correctly and also single stepped to the point where I write to the port. The values are correct in all cases. I can see the same issue if I use your example programs. It's a mystery that it works with an int read but not a byte read. I'm using byte write by the way.

Cliff

User avatar
phil
Site Admin
Posts: 5923
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by phil » Fri Jan 28, 2011 12:14 pm

I'll see if I can reproduce it. I'm not sure I even have a parallel port on my motherboard which makes things a little trick, but I think my old laptop does.

If the sample progs are failing also it shouldn't be too tricky to fix (are you referring to the .NET samples or the others)?

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

CliffB
New User
Posts: 8
Joined: Thu Jan 13, 2011 2:13 pm

Re: inpout32_x64.dll issue writing/reading 128

Post by CliffB » Sun Feb 13, 2011 9:53 pm

Hi Phil

I've been using the simple .NET example to perform the raw reference tests.

Cliff

Post Reply