Days of research and programming have led me to try all variants of inpout32.dll and inpoutx64.dll: binaries, source code, 32-bit, 64-bit, address wrappers. None work: no change is seen to the output bits of the port.
However, I know it is possible, because using another commercially available program that does parallel port output, I can detect a trigger (state change) on all eight output bits (D0-D7) by passing a value between 0 and 255, exactly what I want to do in my own application.
I have followed all the advice from at least these pages:
I am using Windows 7, 64-bit; and my SIIG Cyberpro port is mapped as LPT3 at address 0xCCD8, with four status bits at address 0xCCD4. I have another ECP printer port mapped as LPT1 at 0x0378, but that does not work either.
I know better than to try direct _inp(), _outp() calls on Win7.
Can anyone help?
If I need to download and modify the driver code, I can do that if I have to, but I think it should not be that difficult.
My final version of code uses 32-bit compilation, interfacing to inpout32.dll:
using System;
using System.Runtime.InteropServices;
namespace ParallelPort
{
public class PortAccess
{
//inpout.dll
[DllImport("inpout32.dll")]
private static extern void Out32(ushort PortAddress, short Data);
[DllImport("inpout32.dll")]
private static extern short Inp32(ushort PortAddress);
private ushort _PortAddress = 0;
public ushort PortAddress { get { return _PortAddress; } }
public PortAccess(ushort portAddress)
{
_PortAddress = portAddress;
short result = 0;
try
{
result = Inp32(portAddress);
}
catch (DllNotFoundException e)
{
throw new ArgumentException("Unable to find InpOut32.dll");
}
catch (BadImageFormatException)
{
result = 0;
}
if (0 == result)
throw new ArgumentException("Unable to open parallel port driver");
}
//Public Methods
public void Write(ushort Data)
{
Out32(_PortAddress, (short)Data);
}
public byte Read()
{
return (byte)Inp32(_PortAddress);
}
}
}
FYI:
When I added
[DllImport("inpout32.dll")]
private static extern void DlPortWritePortUshort(ushort PortAddress, ushort Data);
and called that function rather than Out32(ushort addr, ushort value) the code worked.
I don't know why the exact interface matters, but it does; and perhaps that is indeed because of sign extension on the 16-bit port address, as suggested [somewhere TBD].