Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 927 Bytes

裁判系统串口.md

File metadata and controls

32 lines (23 loc) · 927 Bytes

裁判系统串口

简介

本例程演示如何利用librm中的裁判系统协议实现来接收裁判系统发来的数据。

这一部分代码在编写时有移植性方面的考虑,所以设计为和串口HAL解耦;因此,例程代码不和硬件平台相关,程序中编造了一串假数据来模拟裁判系统发来的数据。

代码

#include <librm.hpp>

const unsigned char mock_data[10] = {0xa5, 0x05, 0x00, 0x00, 0x00,
                                     0x01, 0x00, 0x00, 0x00, 0x00};

int main() {
  rm::device::Referee<rm::device::RefereeRevision::kV170> ref;

  // 把接收到的数据一个字节一个字节地扔进Referee对象即可
  for (const auto &data : mock_data) {
    ref << data;
  }

  // 通过Referee对象的data()方法获取数据
  ref.data().custom_robot_data;
  ref.data().event_data;
  ref.data().game_robot_HP.blue_3_robot_HP;
  // ...
  return 0;
}