Google Protobuf 库

MicroPython相关代码、库、软件、工具
回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

Google Protobuf 库

#1

帖子 shaoziyang »

MicroPython 1.17+ 的 Google Protobuf 实现

主要特点:
  • KISS 和 ideomatic 代码库
  • 嵌入式代码(包括自动生成的)应尽可能小且快
  • 纯python代码
  • 应该在尽可能多的设备上工作
支持的功能
  • Protobuf 2 syntax
  • Scalar types encoding and decoding with implicit and explicit defaults
  • Nested messages
  • Message type fields
  • Enums without implicit default value
  • Repeated fields (partly implemented)
TODO
  • Protobuf 3 syntax
  • Repeated fields complete and test (including packed)
  • Test message fields
  • OneOf fields
  • Maps
Groups won't be implemented since they are considered depricated. Required fields check is not implemented for now in favour of efficiency.

已测试的硬件
  • PC (Mac)
  • ESP32-wroom
  • ESP8266 (LoLin V3)

代码: 全选

import animal_upb2
animal = animal_upb2.Animal()

animal.name = "Dog"

encoded_message = animal.encode()
animal1 = Animal.decode(encoded_message)
隐藏内容
你必须登入/注册才可观看隐藏内容
 
 
 
 
 
 

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章