windows 使用USB转并口适配器可以正常访问并口吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4217352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:37:21  来源:igfitidea点击:

Can I access the Parallel Port normally when using USB to Parallel Port adapter?

windowsdelphiusbdelphi-2009parallel-port

提问by Heinrich Ulbricht

Preliminary story

初步故事

There is this program which uses the Parallel Port to synchronize with other hardware. It will set the Parallel Port output to a specified (byte) value. This works without problems when using the built-in Parallel Port of a PC. The target platforms are Windows XP to 7, all worked fine so far. Source code is in Delphi, accessible and can be modified.

有这个程序使用并行端口与其他硬件同步。它将并行端口输出设置为指定的(字节)值。这在使用 PC 的内置并行端口时没有问题。目标平台是 Windows XP 到 7,到目前为止一切正常。源代码在 Delphi 中,可访问并可修改。

How it works

这个怎么运作

In Delphi I can use the io.dllto set the value of the Parallel Port, but there are also other solutions available, like inpout32.dllor port.dll. I call something like PortOut, specify a port number and the byte value and the port is set.

在 Delphi 中,我可以使用io.dll来设置并行端口的值,但也有其他可用的解决方案,例如inpout32.dllport.dll。我调用类似的东西PortOut,指定端口号和字节值并设置端口。

What I now want to do - and where I need help

我现在想要做什么 - 以及我需要帮助的地方

Now the change: this needs to work on a machine which has no Parallel Port built-in (not even on the mainboard). There are several options available:

现在的变化:这需要在没有内置并行端口的机器上工作(甚至不在主板上)。有几个选项可用:

  • use a USB to Parallel Port adapter to add a LPT port to the PC
  • use a PCI card which adds a LPT port to the PC
  • use a PCI Express card which adds a LPT port to the PC
  • 使用 USB 转并口适配器将 LPT 端口添加到 PC
  • 使用为 PC 添加 LPT 端口的 PCI 卡
  • 使用为 PC 添加 LPT 端口的 PCI Express 卡

I am currently heading for and concentrating on the easiest and cheapest possibility: a USB to Parallel Port adapter.

我目前正在寻找并专注于最简单和最便宜的可能性:USB 到并行端口适配器。

Main question

主要问题

There seem to be differences between Parallel Port adapters which are made to connect just a printer and other adapters which seem to be more powerful. Is there really a difference? Or can I just use one of these 5$ printer-adapters, plug in my own hardware and access the port from Delphi code? Or do I need a special adapter? Has anyone experience with this? There is a related question here, but the different adapter types (if existent) are not mentioned there. This pagesuggests that there are indeed differences:

仅用于连接打印机的并行端口适配器与似乎更强大的其他适配器之间似乎存在差异。真的有区别吗?或者我可以只使用这些 5 美元的打印机适配器之一,插入我自己的硬件并从 Delphi 代码访问端口吗?或者我需要一个特殊的适配器?有没有人有这方面的经验?还有一个相关的问题在这里,但不同的适配器类型(如果存在的话)不存在提及。此页面表明确实存在差异:

Contrary to all other USB parallel ports which can connect to printers only, this makes connection to most hardware.

与所有其他只能连接打印机的 USB 并行端口相反,这可以连接到大多数硬件。

I hope there exists a solution via USB because for this you don't have to open the PC, which means the adapter can be added on demand.

我希望有一个通过 USB 的解决方案,因为为此您不必打开 PC,这意味着可以按需添加适配器。

Sub-question

子问题

Do you have experience with PCI (Express) solution? I have to use one if the USB approach is not successful.

您有使用 PCI (Express) 解决方案的经验吗?如果 USB 方法不成功,我必须使用一个。

回答by Allen Bauer

Since I've been wrestling with this very thing recently here's what I've discovered; If you mean by using IO port addressing (indicated by your reference to inpout32.dll), no. Unless your USB-parallel port driver supports full port emulation or virtualization, which most do not, this is generally not possible. If you need to directly access the port to do normal "bit-twiddling", you should get a separate Parallel port PCI-card. Most of them present themselves as normal IO at the standard address(es). I am presuming you're not planning on using the parallel port to actually communicate with a printer, right?

由于我最近一直在努力解决这个问题,这就是我发现的;如果您的意思是使用 IO 端口寻址(由您对 inpout32.dll 的引用表示),则不。除非您的 USB 并行端口驱动程序支持全端口仿真或虚拟化(大多数不支持),否则这通常是不可能的。如果您需要直接访问端口进行正常的“位操作”,您应该获得一个单独的并行端口 PCI 卡。它们中的大多数在标准地址处将自己显示为普通 IO。我假设您不打算使用并行端口与打印机进行实际通信,对吗?

What is interesting is that USB-Serial adapters are much easier to use since they appear as simple virtual devices where you can merely "open" them using a simple stream; TFileStream.Create("COM1", fmOpenRead) or Windows.CreateFile("COM2", ...);

有趣的是,USB 串行适配器更易于使用,因为它们显示为简单的虚拟设备,您只需使用简单的流“打开”它们即可;TFileStream.Create("COM1", fmOpenRead) 或 Windows.CreateFile("COM2", ...);

Here is some devices that purport to do full emulation of a parallel port through USB:

以下是一些声称可以通过 USB 完全模拟并行端口的设备:

https://www-user.tu-chemnitz.de/~ygu/bastelecke/PC/USB2LPT/index.en.htm

https://www-user.tu-chemnitz.de/~ygu/bastelecke/PC/USB2LPT/index.en.htm