当前页面为 开发中 版本,查看特定版本的文档,请在页面左下角的下拉菜单中进行选择。

Sub-1G: Packet reception rate

重要

此例程仅存在于特殊版本的SDK中,如有需要请联系Panchip。

1 功能概述

Packet reception rate演示了Sub-1G的收包率测试程序。此程序实现了Tx和RX两端的程序,是辅助测试当前的信号质量的一种手段。

2 环境准备

  • PAN3730 EVB两块

  • Type-C USB线两条(用于供电和查看串口打印Log)

  • 硬件接线:

    • 使用USB线,将PC USB与EVB Type-C USB(USB->UART)相连

    • 使用杜邦线或者跳线帽将EVB上的:

      • TX0 与 P00相连

      • RX0 与 P01相连

  • PC软件: 串口调试助手(UartAssist)或终端工具(SecureCRT),波特率921600

  • 码表或者其他ANT接收设备,手机(nrf connect)

3 编译和烧录

例程位置:zephyr\samples_panchip\sub_1G\packet_reception_rate

编译时Board选择pan3730_evb,Config选择prj.conf

使用 ZAL 工具可以对其进行编译、烧录、打开 VS Code 调试等操作。关于 ZAL 工具的详细介绍请参考:Zephyr APP Launcher 工具介绍

4 演示说明

烧录时我们需要要给一个开发板烧录TX固件另一个开发板烧录RX固件,所以需要我们修改main.c文件最上方的宏来控制当前是TX端还是RX端。

#define TEST_DEVICE_TYPE                  0x01                /* 0x01 - TX     0x02 - RX */

例程上电初始化会打印如下日志:

TX端:
*** Booting Zephyr OS build zephyr-v2.7.0-1025-g76f2f15ea6d2  ***
packet reception rate TX node start!
Sub-1G initialize success

RX端:
*** Booting Zephyr OS build zephyr-v2.7.0-1025-g76f2f15ea6d2  ***
packet reception rate RX node start!
Sub-1G initialize success

例程在开始测试之前会有同步的操作,所以当距离太远或者其他信号不佳的情况下导致两边的设备没有同步成功的情况下,收包测试是不能正常开始的。当同步成功时,tx和rx两端分别会输出如下日志:

TX端:
start send data package

RX端:
start receive data package

收包率测试完成后,在RX端会输出测试结果,日志如下:

 Total number of package:                       100              -- 设置的总测试包数
 Send Success number of package:                100              -- 发送端成功发送的包数
 Receive Success number of package:             100              -- 接收端成功接收的包数
 packet reception rate:                         100%             -- 收包率

TX端结束测试之后会打印如下日志:

正常日志:
test flow finish, Reset if you need to retest

如出现如下日志,说明在结束时同步信息的时候没有收到RX端的响应,所以有可能是RX端收到了同步信息包但是它回复的ack包TX端没有收到,也有可能RX端根本就没有收到TX端的同步信息包。所以在这种情况下RX有可能打印测试信息也可能不会打印测试信息。
Cannot connect to rx terminal, end request packet may fail to send.

5 开发者说明

  1. 启用ANT模块,需要在prj.conf文件中添加”CONFIG_SUB_ONEG=y”和”CONFIG_NEWLIB_LIBC=y”

    CONFIG_SUB_ONEG=y
    CONFIG_NEWLIB_LIBC=y
    
  2. Sub-1G初始化

    /**
     * @brief Configure the sub-1G module.
     *
     * @param cfg Pointer to the sub-1G config struct.
     *
     * @retval 0 If successful.
     * @retval -errno Negative errno code on failure.
     */
    int sub_oneg_configure(sub_oneg_cfg *cfg);
    
  3. Sub-1G发送数据

    /**
     * @brief Start send mode.
     *
     * @param cfg      Pointer to the sub-1G config struct.
     * @param buffer   Send data buffer.
     * @param length   Send data length.
     * @return int     The time it takes to send.
     */
    int sub_oneg_send(sub_oneg_cfg *cfg, uint8_t *buffer, size_t length);
    
  4. Sub-1G接收启动

    /**
     * @brief Start receive mode.
     *
     * @param cfg      Pointer to the sub-1G config struct.
     * @param mode     Set continue rx mode or single rx mode.
     *					CONTINUE_RX_MODE: After the rx is finished,
     *						it will not exit the rx mode and will remain in the rx mode.
     *					SINGLE_RX_MODE: When rx is finished, it exits rx mode
     * @param timeout  Set rx timeout(ms), 0 indicates no timeout until data is received.
     *
     * @retval 0 If successful.
     * @retval -errno Negative errno code on failure.
     */
    int sub_oneg_receive_start(sub_oneg_cfg *cfg, sub_oneg_rx_mode_t mode, uint32_t timeout);
    

更多有关sub-1G的介绍请参考 Sub-1G使用指南文档

6 RAM/Flash资源使用情况

Memory region         Used Size  Region Size  %age Used
FLASH:       41280 B       384 KB     10.50%
SRAM:        5920 B        64 KB      9.03%