如何在没有虚拟COM端口的情况下从微控制器到PC进行通信? [英] How do I communicate from microcontroller to PC without a virtual COM port?

查看:68
本文介绍了如何在没有虚拟COM端口的情况下从微控制器到PC进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Arduino创建可编程键盘。实际上很简单,只需使用键盘库,按下按钮时打印一个字符:没问题。我还在PC上创建了一个通过串口与Arduino进行通信的应用程序,我可以发送一个新的配置并告诉Arduino按下按钮1时我想要的字符:有点复杂但仍然可以。



我的问题:我不希望Arduino和PC之间的通信过串口。

- 串口号有时会改变

- 另一个应用程序可以窃取端口并终止通信

- 它不会被加密



我有什么选择Arduino /微控制器和PC之间的通信?



我尝试过:



我查看了HID和CDC协议,我使用HID报告,以便我的Arduino被PC识别为键盘。我认为CDC实际上目前用于Arduino的串行通信。



一个完美的解决方案是CDC类,它允许我像常规串口一样进行通信,但不知何故会被隐藏。我将能够找到具有PID和VID的USB设备。

I am trying to create a programmable Keyboard with an Arduino. It was actually pretty easy, just using the keyboard library, printing a character when a button is pressed: no problems. I also created an application on the PC to communicate over the serial port with the Arduino, I can send a new configuration and tell the Arduino which character I want when button 1 is pressed: a bit more complicated but still ok.

My problem: I do not want the communication between Arduino and PC to be over serial port.
- serial port number changes sometimes
- another application can "steal" the port and kill the communication
- it is not crypted

What are my options to communicate between Arduino/Microcontroller and PC?

What I have tried:

I looked into HID and CDC protocol, I use HID report so that my Arduino is recognized as a keyboard by the PC. I think CDC is actually currently used for the serial communication of the Arduino.

A perfect solution would be a CDC class which allows me to communicate like a regular serial port, but would somehow be "hidden". I would be able to find the USB device with PID and VID.

推荐答案

引用:

- 有时串口号更改

- serial port number changes sometimes

将USB转串口转换器插入不同的连接器时可能会发生这种情况。但是不应该拔掉转换器。



That might happen when plugging the USB-to-Serial converter into a different connector. But it should not happen when not unplugging the converter.

引用:

- 另一个应用程序可以窃取端口并终止通信

- another application can "steal" the port and kill the communication

COM端口是独占资源。这也适用于虚拟端口。这意味着一旦应用程序打开它,它就不能被另一个应用程序(甚至是同一个应用程序)打开。因此,通信不能被另一个应用程序杀死。但是,另一个应用程序可能会在您的端口之前打开端口。



COM ports are exclusive resources. That applies to virtual ports too. That means once an application has opened it, it can't be opened anymore by another application (or even the same application). So the communication can't be killed by another application. However, another application may open the port before yours.

Quote:

- 它不加密

这与物理接口和低级通信协议无关。如有必要,您可以使用某种加密方式进行数据传输。



That is not related to the physical interface and low level communication protocol. If necessary, you can use some kind of encryption for data transfers.

引用:

我有什么选择在Arduino / Microcontroller和PC之间进行通信?

What are my options to communicate between Arduino/Microcontroller and PC?

根据可用或可安装的接口类型,有很多选择。对于低速,你甚至可以使用SPI和I2C。



我假设你在PC端有一个USB转串口转换器。如果有FTDI芯片,您可以使用 D2XX直接驱动程序 [ ^ ](其他芯片可能有类似的驱动程序)。使用它可以通过VID和PID而不是虚拟COM端口访问转换器,并避免更改COM端口的问题。您甚至可以卸载或禁用虚拟COM端口驱动程序,以便其他应用程序必须使用相同的方法来访问转换器。

There are many depending on the kind of interfaces available or installable. For low speed you can even use SPI and I2C.

I assume that you have an USB-to-Serial converter at the PC side. If that has an FTDI chip, you can use the D2XX Direct Drivers[^] (with other chips there may be similar drivers). Using that you can access the converter by VID and PID instead of the virtual COM port and avoid the problem of changing COM ports. You can even uninstall or disable the virtual COM port driver so that other applications would have to use the same method to access the converter.


这篇关于如何在没有虚拟COM端口的情况下从微控制器到PC进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆