--- title: "Using the Serial Driver" slug: "using-the-serial-driver" updated: 2024-01-05T16:48:30Z published: 2024-01-05T16:48:30Z canonical: "support.tulip.co/using-the-serial-driver" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 使用串行驱动程序 *串行驱动程序使用指南* 本文介绍与 Tulip 串行驱动程序相关的功能和配置。 请注意,该驱动程序不同于目前仅适用于 Tulip I/O Gateway 和 Edge IO 的[通用串行驱动程序](https://support.tulip.co/docs/how-to-use-the-generic-serial-driver-on-io-gateway)。 ## 功能 串行驱动程序允许 Tulip 应用程序连接到串行设备并发送和接收信息。这包括所有类型的 USB 串行设备、通过 USB 转串行适配器连接的串行设备以及使用虚拟串行 (COM) 端口连接的串行设备。这些设备包括斑马打印机、mettler Toldeo 电子秤等。 该驱动程序仅适用于基于 Windows 的 Tulip Player,默认情况下已启用。 ### 功能 该驱动程序支持以下功能: - **列出端口**- 列出可用的串行(COM)端口 - **连接**(Connect)--连接串行端口以收发信息 - **Connect with Options(连接选项**)--串行连接的高级选项,如流量控制、奇偶校验、数据位和停止位。 *自 r252 版起可用,需要 Desktop Player 2.2 或更高版本。* - **发送**- 向连接的设备发送信息 - **断开连接**- 断开与已连接设备的连接 这些功能在 Tulip 应用程序编辑器中显示为 "设备功能",如下所示: **列出端口**![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Using%20the%20Serial%20Driver_259650152.png) **连接**![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Using%20the%20Serial%20Driver_259650586.png) **连接选项**![Serial Driver Connect with Options](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Serial%20Driver%20Connect%20with%20Options.png) **发送**![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Using%20the%20Serial%20Driver_259650744.png) **断开连接**![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Using%20the%20Serial%20Driver_259650871.png) 这三个函数都需要一个 "标识符 "作为参数传递。该标识符可在 Tulip App 中唯一标识连接,并可用于同时维护多个连接。 连接功能的其他参数描述如下: - **路径**- 要连接的设备的 COM 路径。 - **波特率**- 要连接的设备的[波特率](https://en.wikipedia.org/wiki/Baud)。这通常在设备文档中提供。如果设备具有自动配置的波特率,该值将被忽略。 - **信息分隔符**- 用于分隔*传入*信息的分隔字符串。每次*从*设备接收到信息分隔符时,上一次信息分隔符之后接收到的所有数据都将通过**信息**事件发送到应用程序。通常是换行符("\n")或带换行符的回车符("\r\n")。 - **Message Terminator(消息终止符**)--在每次*发送*函数后发送的字符串,用于表示消息已终止。通常是换行符("\n")或带换行符的回车符("\r\n")。 连接选项 "触发操作从 r252 版开始提供,需要 Windows Desktop Player 2.2 或更高版本。 附加选项支持以下值: | Option | Allowed Values | Commonly Used Values | | --- | --- | --- | | Data Bits | 5, 6, 7, 8 | 8 | Stop Bits | 1, 1.5, 2 | 1 | Parity | none, even, odd, mark, space | none | Flow Control | none, rts-cts, xon-xoff | none | 事件事件 ### 事件 驱动程序会发出两种事件:"Message(信息)"事件表示连接已发送信息;"Error(错误)"事件表示驱动程序或连接出现错误。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Using%20the%20Serial%20Driver_226548417.png) ## 配置 在连接设备所需的 Tulip 应用程序逻辑之外,无需进行任何配置。在上述示例中,我们展示了用于连接详细信息的静态值,但从变量或 Tulip 表记录中提取这些值以实现对这些值的集中管理是很常见的。 --- 找到您想要的了吗? 你还可以前往[community.tulip.co](https://community.tulip.co/?utm_source=intercom&utm_medium=article-link&utm_campaign=all)发布你的问题,或看看其他人是否也遇到过类似的问题!