Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Quecpython's data serialization format -- QpyTLV

[中文](README_ZH.md) | English

## Overview

`TLV` stands for `Tag`, `Length` and `Value`, which is a data serialization format. It features a simple structure, fast parsing speed, supports nested messages, and sequential concatenation. It is commonly used in serial communication, Bluetooth, and even network data transmission.

`QpyTLV` is a TLV structure encoder and decoder written in the Quecpython language, which also supports EMV tags.

## Usage

- [API Reference Manual](./docs/en/API_Reference.md)
- [Example Code](./code/demo.py)

## Contribution

We welcome contributions to improve this project! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/your-feature`).
3. Commit your changes (`git commit -m 'Add your feature'`).
4. Push to the branch (`git push origin feature/your-feature`).
5. Open a Pull Request.

## License

This project is licensed under the Apache License. See the [LICENSE](LICENSE) file for details.

## Support

If you have any questions or need support, please refer to the [QuecPython documentation](https://python.quectel.com/doc/en) or open an issue in this repository.
32 changes: 32 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Quecpython 数据序列化格式 -- QpyTLV

中文 | [English](README.md)

## 概述

`TLV`是`Tag(标签)`、`Length(长度)`和`Value(数值)`的简称,是一种数据序列化的格式。其结构简单、解析速度快,支持报文嵌套和顺序拼接。在串口、蓝牙甚至网络数据传输中比较常用。

`QpyTLV`是用Quecpython语言编写的TLV结构编解码器,支持emv tags。

## 用法

- [API 参考手册](./docs/zh/API参考手册.md)
- [示例代码](./code/demo.py)

## 贡献

我们欢迎对本项目的改进做出贡献!请按照以下步骤进行贡献:

1. Fork 此仓库。
2. 创建一个新分支(`git checkout -b feature/your-feature`)。
3. 提交您的更改(`git commit -m 'Add your feature'`)。
4. 推送到分支(`git push origin feature/your-feature`)。
5. 打开一个 Pull Request。

## 许可证

本项目使用 Apache 许可证。详细信息请参阅 [LICENSE](LICENSE) 文件。

## 支持

如果您有任何问题或需要支持,请参阅 [QuecPython 文档](https://python.quectel.com/doc) 或在本仓库中打开一个 issue。
31 changes: 31 additions & 0 deletions code/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Import module from usr
from usr.qpytlv import QpyTLV

# Define your tags list or dict if necessary
tags = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'a5a5', 'e1e1']

# Create a object of class QpyTLV
tlv = QpyTLV(tags)

# Pack user data as a specific format dict
d = {
"aaaa": b'\xaa\xaa',
"bbbb": {
"cccc": b'\xcc\xcc',
"dddd": b'\xdd\xdd'
},
"eeee": {
"ffff": b'\xff\xff',
"a5a5": {
"e1e1": b'\xe1\xe1'
}
}
}

# Build a TLV structure
b = tlv.build(d)
print(b)

# Parse a TLV structure
d = tlv.parse(b)
print(d)
Loading