Logo
Explore Help
Register Sign In
fengqi/lv_micropython
1
0
Fork 0
You've already forked lv_micropython
Code Issues Pull Requests 1 Actions Packages Projects Releases Wiki Activity
lv_micropython/tests/basics/struct1.py

9 lines
260 B
Python
Raw Normal View History

py: Start implementing "struct" module. Only calcsize() and unpack() functions provided so far, for little-endian byte order. Format strings don't support repition spec (like "2b3i"). Unfortunately, dealing with all the various binary type sizes and alignments will lead to quite a bloated "binary" helper functions - if optimizing for speed. Need to think if using dynamic parametrized algos makes more sense.
2014-04-10 03:45:38 +03:00
import struct
print(struct.calcsize("<bI"))
print(struct.unpack("<bI", b"\x80\0\0\x01\0"))
modstruct: Refactor to support both LE and BE packed structs.
2014-04-10 22:19:32 +03:00
print(struct.calcsize(">bI"))
print(struct.unpack(">bI", b"\x80\0\0\x01\0"))
modstruct: Basic implementation of native struct alignment and types.
2014-04-11 03:47:21 +03:00
# 32-bit little-endian specific
#print(struct.unpack("bI", b"\x80\xaa\x55\xaa\0\0\x01\0"))
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 29ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API