I need to use an embedded system running Python 1.5.2+ (!!!) with very few modules.
And there is no “struct” module usable…
Here is the list of usable modules :
marshal
imp
_main_
_builtin_
sys
md5
binascii
Yes that’s it, no struct module…
So, I need to create a 4 bytes representation of an unsigned short integer to send to serial…
With struct :
date = day + month * 32 + (year - 2000) * 512
time = 100 * hour + minute
data = struct.pack(b'HH', date, time)
date on 2 bytes time on 2 bytes and everybody’s happy…
But without using ‘struct’ module, how can I do that?
Here is a complete translation for you
Before
And after