mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 08:06:46 +01:00
created Python port for packagebinaries.php to create Tag_FW_Pack.bin
This commit is contained in:
@@ -1364,7 +1364,7 @@ int getJsonTemplateUrl(String &filename, String URL, time_t fetched, String MAC,
|
||||
void drawJsonStream(Stream &stream, String &filename, tagRecord *&taginfo, imgParam &imageParams) {
|
||||
TFT_eSprite spr = TFT_eSprite(&tft);
|
||||
initSprite(spr, imageParams.width, imageParams.height, imageParams);
|
||||
DynamicJsonDocument doc(300);
|
||||
DynamicJsonDocument doc(500);
|
||||
if (stream.find("[")) {
|
||||
do {
|
||||
DeserializationError error = deserializeJson(doc, stream);
|
||||
|
||||
@@ -443,7 +443,7 @@ bool flasher::writeFlashFromPackOffset(fs::File *file, uint16_t length) {
|
||||
}
|
||||
|
||||
bool flasher::writeFlashFromPack(String filename, uint8_t type) {
|
||||
StaticJsonDocument<512> doc;
|
||||
DynamicJsonDocument doc(1024);
|
||||
fs::File readfile = contentFS->open(filename, "r");
|
||||
DeserializationError err = deserializeJson(doc, readfile);
|
||||
if (!err) {
|
||||
@@ -466,6 +466,7 @@ bool flasher::writeFlashFromPack(String filename, uint8_t type) {
|
||||
}
|
||||
Serial.print("Failed to find this tag's type in the FW pack database.\n");
|
||||
} else {
|
||||
Serial.println(err.c_str());
|
||||
Serial.print("Failed to read json header from FW pack\n");
|
||||
}
|
||||
readfile.close();
|
||||
|
||||
BIN
binaries/Tag/Tag_FW_Pack.bin
Normal file
BIN
binaries/Tag/Tag_FW_Pack.bin
Normal file
Binary file not shown.
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
$types[0x00] = "Tag_FW_1.54.bin";
|
||||
$types[0x01] = "Tag_FW_2.9.bin";
|
||||
$types[0x00] = "SOLUM_154_SSD1619-tag-00-0022.bin";
|
||||
$types[0x01] = "SOLUM_29_SSD1619-tag-01-0022";
|
||||
$types[0xF0] = "Tag_FW_Segmented_UK.bin";
|
||||
$types[0x02] = "Tag_FW_4.2.bin";
|
||||
$types[0x11] = "Tag_FW_2.9-uc8151.bin";
|
||||
$types[0x02] = "SOLUM_42_SSD1619-tag-02-0022.bin";
|
||||
$types[0x11] = "SOLUM_29_UC8151-tag-11-0022.bin";
|
||||
|
||||
$binpath = "../binaries/";
|
||||
$binpath = "../binaries/Tag";
|
||||
$tocmaxsize = 512;
|
||||
|
||||
$toc = array();
|
||||
@@ -21,6 +21,7 @@ $version = hexdec($version);
|
||||
*/
|
||||
$version = 0;
|
||||
|
||||
// *** fixme: this should select only filenames containing the latest version. See python version of this script.
|
||||
exec("ls -1 $binpath | grep 'Tag_FW' | grep -v battery | grep -v Pack | grep -v M3", $binaries);
|
||||
foreach($binaries as $file){
|
||||
$file = trim($file);
|
||||
@@ -30,7 +31,7 @@ foreach($binaries as $file){
|
||||
$type = $typeid;
|
||||
}
|
||||
}
|
||||
if($type==-1)die("We don't recognize filetype <$file>, sorry...\n");
|
||||
if($type!=-1)echo("Adding filetype <$file>\n");
|
||||
$binary = file_get_contents($binpath.$file);
|
||||
$length = strlen($binary);
|
||||
$offset = strlen($output);
|
||||
|
||||
58
zbs243_Tag_FW/packagebinaries.py
Normal file
58
zbs243_Tag_FW/packagebinaries.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
version = "0022" # You can set your desired version here.
|
||||
|
||||
types = {
|
||||
0x00: "SOLUM_154_SSD1619-tag-00-" + version + ".bin",
|
||||
0x01: "SOLUM_29_SSD1619-tag-01-" + version + ".bin",
|
||||
0xF0: "Tag_FW_Segmented_UK.bin",
|
||||
0x02: "SOLUM_42_SSD1619-tag-02-" + version + ".bin",
|
||||
0x11: "SOLUM_29_UC8151-tag-11-" + version + ".bin",
|
||||
}
|
||||
|
||||
binpath = "../binaries/Tag"
|
||||
tocmaxsize = 512
|
||||
|
||||
toc = []
|
||||
output = b'\0' * tocmaxsize # Initialize as bytes
|
||||
|
||||
binaries = [file for file in os.listdir(binpath) if 'Pack' not in file and version in file]
|
||||
for file in binaries:
|
||||
file = file.strip()
|
||||
type = -1
|
||||
for typeid, typefile in types.items():
|
||||
if typefile == file:
|
||||
type = typeid
|
||||
if type != -1:
|
||||
print("Adding filetype <{}>".format(file))
|
||||
with open(os.path.join(binpath, file), 'rb') as binary_file:
|
||||
binary = binary_file.read()
|
||||
length = len(binary)
|
||||
offset = len(output)
|
||||
subarr = {
|
||||
'type': type,
|
||||
'version': version,
|
||||
'name': file,
|
||||
'offset': offset,
|
||||
'length': length,
|
||||
}
|
||||
toc.append(subarr)
|
||||
output += binary
|
||||
|
||||
jtoc = json.dumps(toc)
|
||||
jtoc = jtoc.replace("'", '"')
|
||||
tocsize = len(jtoc)
|
||||
if tocsize > tocmaxsize:
|
||||
raise ValueError("TOC is too big! (" + str(tocsize) + "). Adjust size and try again")
|
||||
|
||||
# Encode jtoc as bytes
|
||||
jtoc = jtoc.encode('utf-8')
|
||||
|
||||
# Concatenate bytes and write to the file
|
||||
output = jtoc + output[len(jtoc):]
|
||||
with open(os.path.join(binpath, "Tag_FW_Pack.bin"), 'wb') as output_file:
|
||||
output_file.write(output)
|
||||
|
||||
print(toc)
|
||||
print("All done.")
|
||||
Reference in New Issue
Block a user