[英]Does inpout32.dll/inpoutx64.dll handle I/O to/from all parallel ports?
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. 经过几天的研究和编程,我尝试了inpout32.dll和inpoutx64.dll的所有变体:二进制文件,源代码,32位,64位,地址包装器。 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. 但是,我知道这是可能的,因为使用另一个并行端口输出的商用程序,我可以通过在0到255之间传递一个值来检测所有八个输出位(D0-D7)的触发(状态改变),我想在自己的应用程序中进行操作。
I have followed all the advice from at least these pages: 我至少遵循了以下页面中的所有建议:
I am using Windows 7, 64-bit; 我使用的是Windows 7(64位); and my SIIG Cyberpro port is mapped as LPT3 at address 0xCCD8, with four status bits at address 0xCCD4.
我的SIIG Cyberpro端口映射为LPT3,位于地址0xCCD8,四个状态位位于地址0xCCD4。 I have another ECP printer port mapped as LPT1 at 0x0378, but that does not work either.
我在0x0378处将另一个ECP打印机端口映射为LPT1,但这也不起作用。
I know better than to try direct _inp(), _outp() calls on Win7. 我知道比在Win7上尝试直接_inp()和_outp()调用更好。
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: 我的最终代码版本使用32位编译,并连接到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. 并调用该函数而不是Out32(ushort addr,ushort值),代码可以正常工作。
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].
可能确实是因为建议的[在TBD某处] 16位端口地址上的符号扩展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.