如何在Windows中创建虚拟Com1端口?

发布于 2024-07-07 01:42:24 字数 149 浏览 6 评论 0原文

我正在开发一个在袖珍电脑上运行的移动应用程序。 我们有一个移动打印机和刷卡器,使用 com1 发送和获取信息。 我正在使用设备模拟器,并且想在没有打印机的情况下进行测试。 如何创建虚拟 com1 端口以进行读取? 我尝试了 com0com,但设备模拟器不会将其设置为串行 0。

I am developing a mobile app to run on a pocketpc. We have a mobile printer and card swipe that uses com1 to send and get info. I'm using the device emulator and want to test without the printer. How do I create a virtual com1 port to right to and read from? I tried com0com but the device emulator will not set that as serial 0.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不及他 2024-07-14 01:42:24

如果 PC 有 2 个串行端口(USB 转串行适配器工作良好),您可以使用与模拟器共享的端口到 PC 上另一个端口的空调制解调器,并将超级终端连接到该端口。 这会让你很容易重定向。

If the PC has 2 serial ports (USB to serial adapters work well) you can use a null modem from the port shared with the emulator to another on the PC and attach Hyperterminal to it. That would give you the redirect pretty easily.

完美的未来在梦里 2024-07-14 01:42:24

这不是一个直接的答案,但如果你足够绝望,我有一个朋友使用绕道 当他无法编辑另一个程序的源代码时,将与 COM 接口相关的输出重定向到他想要的位置。

This isn't a direct answer, but if you get desperate enough, I had a friend use Detours to redirect output relating to COM interfaces to where he wanted it when he couldn't edit another program's source.

自由范儿 2024-07-14 01:42:24

大约两天前,我对此进行了研究,以模拟 GPS 设备。 我唯一能想到的是一堆低级汇编代码。

I did research on this about 2 days ago to emulate a GPS device. The only thing I was able to come up with was a bunch of low level assembly code.

时光倒影 2024-07-14 01:42:24

我不确定我明白你在追求什么。 模拟器可以绑定到 PC 上的 COM 端口,因此您可以使用它从模拟器上的应用程序读取和写入 PC 上的物理端口。

现在,如果您问如何在不附加任何东西的情况下打开 COM 端口并进行读写,那就困难得多了。 编写很简单 - 我只需抽象出通信层并将模拟类拼凑在一起,然后写入就无济于事。 读取更具挑战性,因为您必须编写某种模拟器来以与外设相同的方式呈现数据。

IMO,无论如何,您都应该进行这种抽象,以便为软件编写单元和集成测试。

I'm not sure I understand what you're after. The emulator can be bound to a COM port on the PC, so you could use that to read and write from the app on the emulator to the physical ports on the PC.

Now if you're asking how you can just open the COM port and read and write with nothing attached, that's far more difficult. Writing is simple - I'd just abstract out the communication layer and slap together a mock class, then have writes go nowhere. Reads are a lot more challenging, as you're going to have to write some sort of simulator to present data in the same way as your peripheral.

IMO, you should be doing this abstraction anyway to allow you to write unit and integration tests for the software anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文