pdf-icon

UIFlow 上手教程

UiFlow1 Blockly

Event

Unit

UiFlow1 项目配置

Unit RFID-UHF

案例程序

实现标签读取与数据锁定的完整流程

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
uhf_rfid_0 = unit.get(unit.UHF_RFID, unit.PORTC)

epc_no = None

uhf_rfid_0.set_region(uhf_rfid_0.REGIN_CN_800MHZ)
uhf_rfid_0.automatic_freq_hopping(0x00)
print(uhf_rfid_0.get_region())
print(uhf_rfid_0.get_channel_freq())
epc_no = 0
while not epc_no:
  epc_no = uhf_rfid_0.single_polling()
print(epc_no)
while not (uhf_rfid_0.select_tag_param(epc_no)):
  pass
print(uhf_rfid_0.get_select_tag_param())
epc_no = 0
while not epc_no:
  epc_no = uhf_rfid_0.read_memory_bank(2, 2, 0x00, 'FFFF3333')
print(epc_no[0])
print(epc_no[1])
epc_no = 0
while not epc_no:
  epc_no = uhf_rfid_0.lock_data_store(0, 2, 2, 0, 0, 0, 1, 1, 0, 0, 'FFFF3333')
print('Lock Success')

功能说明

uhf_rfid_0.uart_port_id(1)
  • 模块 UART 接口初始化
uhf_rfid_0.automatic_freq_hopping(0xFF)
  • 模块自动跳频
print((str('freq:') + str((uhf_rfid_0.get_channel_freq()))))
  • 获取模块信道频率
print((str('info:') + str((uhf_rfid_0.get_device_info(0x00)))))
  • 获取模块设备信息
print((str('code:') + str((uhf_rfid_0.get_region()))))
  • 获取模块工作区域
print((str('tag:') + str((uhf_rfid_0.get_select_tag_param()))))
  • 获取模块选卡参数
print((str('tx:') + str((uhf_rfid_0.get_tx_power()))))
  • 获取模块发射功率
print(uhf_rfid_0.lock_data_store(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ''))
  • 锁定模块数据存储区
uhf_rfid_0.multiple_polling_stop()
  • 停止模块多标签轮询
def uhf_rfid_eQuAncb(epc_no, dBm):
  global EPC1, dBm1
  EPC1 = epc_no
  dBm1 = dBm
  pass


print(uhf_rfid_0.multiple_polling_read(uhf_rfid_eQuAncb, 100))
  • 模块多标签读取计数
print(uhf_rfid_0.read_memory_bank(0, 0, 0x00, ''))
  • 读取模块存储器数据
uhf_rfid_0.set_channel_freq(920.375)
  • 设置模块信道频率
uhf_rfid_0.set_region(uhf_rfid_0.REGIN_CN_900MHZ)
  • 设置模块工作区域
uhf_rfid_0.set_select_mode(0x00)
  • 设置模块选卡模式
print((str('param:') + str((uhf_rfid_0.select_tag_param('EPC')))))
  • 设置模块选卡
uhf_rfid_0.set_tx_power(0)
  • 设置模块发射功率
print((str('reading:') + str((uhf_rfid_0.single_polling()))))
  • 模块单标签轮询
uhf_rfid_0.sleep()
  • 模块进入休眠状态
uhf_rfid_0.wakeup()
  • 唤醒模块
print((str('list:') + str((uhf_rfid_0.write_customer_command([0, 0, 0], True)))))
  • 向模块写入自定义命令
print(uhf_rfid_0.write_memory_bank('', 0, 0x00, ''))
  • 向模块存储器写入数据
On This Page