• VEXcode Robotics Logo VEX Robotics Logo
  • VEX API Home Button VEX API Home Button
  • VEX 123 logo in purple VEX 123 logo in white
  • VEX GO logo in lime green VEX GO logo in white
  • VEXcode AIM logo in blue VEXcode AIM logo in white
  • VEX IQ logo in blue VEX IQ logo in white
  • VEX EXP logo in red VEX EXP logo in white
  • VEX V5 logo in red VEX V5 logo in white
  • VEX CTE logo in green VEX CTE logo in white
  • VEX AIR logo in orange VEX AIR logo in white
  • VEXcode VR logo in gold VEXcode VR logo in white
跳至主要内容
Ctrl+K

< Back to Platform Select

  • VEX V5
  • 欢迎来到 VEX V5 的 API 参考网站
  • VEXlink
  • 消息链接
简体中文
  • English
  • Spanish
  • VEXcode Robotics Logo

版块导航

  • 区块
  • Python
  • C++
    • Drivetrain
    • 运动
    • Vision
    • 屏幕
    • 控制器
    • 传感
    • 惯性
    • 三线制设备
    • 气动元件
    • 脑
    • SD卡
    • VEXlink
      • 消息链接
      • 串行链接
    • 安慰
    • 逻辑
    • 电磁铁
    • SD卡
    • 竞赛

平台导航

  • VEX 123 logo in purple VEX 123 logo in white
  • VEX GO logo in lime green VEX GO logo in white
  • VEXcode AIM logo in blue VEXcode AIM logo in white
  • VEX IQ logo in blue VEX IQ logo in white
  • VEX EXP logo in red VEX EXP logo in white
  • VEX V5 logo in red VEX V5 logo in white
  • VEX CTE logo in green VEX CTE logo in white
  • VEX AIR logo in orange VEX AIR logo in white
  • VEXcode VR logo in gold VEXcode VR logo in white

消息链接#

  • 什么是消息链接?

  • 初始化 message_link 类

  • 类方法

    • 发送()

    • 收到()

    • 已收到()

什么是消息链接?#

VEXlink 使 V5 主控模块能够与其他 V5 主控模块通信,从而实现点对点连接并在多个机器人之间创建通信网。它支持无线和有线通信,有线连接建议使用改良的智能电缆以避免电源路由问题。对于无线通信,每个机器人都需要一个连接到智能端口的 V5 机器人无线电模块,VEXlink 无线电模块可以与 V5 控制器的 VEXnet 无线电模块配合使用,后者应连接到编号最高的智能端口以避免冲突。

VEXlink 中的 message_link 类便于向连接的机器人发送简单的消息,例如“播放”和“停止”,只需发送最少的数据。

初始化 message_link 类#

VEXlink 是通过使用以下构造函数创建的:

The message_link constructor creates a message_link object in the specified Port, with the specified ID and linktype, and sets the wired flag to the specified value.

范围

描述

port

A valid Smart Port that the VEXlink Radio is connected to.

name

此链接的名称。建议此唯一字符串足够长,以便 Vexos 对其进行哈希处理后能够生成唯一的 ID。不建议使用“vexlink”之类的通用名称,因为它可能已被其他团队使用。

linktype

The type of link, either linkType.MANAGER or linkType.WORKER. This information is used to correctly configure the radio and also determines available bandwidth for transmission and reception. A manager robot has double the available bandwidth (1040 bytes/second) to send information to the worker robot (520 bytes/second).

wired

Whether or not it is a wired link. Set to true if wired.

// Construct a VEXlink "link" with the message_link class.
message_link link = message_link(PORT1, "link", linkType::manager);

This link object will be used in all subsequent examples throughout this API documentation when referring to message_link class methods.

类方法#

send()#

该方法可通过以下方式调用:

The send(message) method sends a message through the Message Link.

参数

描述

message

要发送的信息。

返回值: 表示传输数据长度的整数。

// Send the message "test" with no parameters.
link.send("test");

The send(message, value) method sends a message through the Message Link.

参数

描述

message

要发送的信息。

value

表示消息 ID 的浮点数。

返回值: 表示传输数据长度的整数。

The send(message, index, value) method sends a message through the Message Link.

参数

描述

message

要发送的信息。

index

表示接收消息链路所连接的端口的整数。

value

表示消息 ID 的浮点数。

返回值: 表示传输数据长度的整数。

receive()#

The receive(timeout) command receives a message from the Message Link.

参数

描述

timeout

函数返回前接收消息的超时时间(以毫秒为单位)。

返回值: 收到的消息。

received()#

The received(callback) command registers a callback function for when a message is received. If the message is omitted then the callback function will be called for all messages.

这是一个非等待命令,允许下一个命令立即运行。

参数

描述

callback

收到消息时要调用的回调函数。

**返回值:**事件类的一个实例。

上一页

VEXlink

下一页

串行链接

On this page
  • 什么是消息链接?
  • 初始化 message_link 类
  • 类方法
    • send()
    • receive()
    • received()
Innovation First, International

VEX 和 VEX Robotics 是 Innovation First, Inc. 的商标或服务标志 版权所有 ©2025。保留所有权利。VEX Robotics, Inc. 是 Innovation First International, Inc. 的子公司。所有其他产品名称/商标均为其各自所有者的财产。专利和/或正在申请的专利 - innovationfirst.com/patents
网站隐私政策 / 网站使用条款 / Cookie 政策 / 软件隐私政策

访问 VEX Robotics Facebook 页面 访问 VEX Robotics Twitter 页面 访问 VEX Robotics Instagram 页面 访问 VEX Robotics YouTube 页面
VEX API 反馈表

我们重视您的反馈!请使用此表单分享建议、赞美或报告 VEX API 的错误。您的反馈有助于我们完善 VEX API 文档。

如果您遇到技术问题或需要客户支持,请访问 support.vex.com.

  • Send Happy Feedback
  • Send Sad Feedback

注意:当前 URL 将与您的消息共享

通过添加您的电子邮件地址,您同意如果我们对您的反馈有疑问,VEX 可以向您发送电子邮件。
隐私政策 >
请提供您的反馈。 反馈提交成功!
Choose Which VEX IQ Generation to View

VEX IQ (1st gen)

VEX IQ (2nd gen)