How to create a Virtual Com1 port in windows?

我是研究僧i 提交于 2019-12-12 14:53:30

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/209541/how-to-create-a-virtual-com1-port-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!