pyawe_ffs 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyawe_ffs/FfsBackend.py +4 -0
- pyawe_ffs/FfsContainer.py +105 -0
- pyawe_ffs/FfsEntry.py +33 -0
- pyawe_ffs/__init__.py +45 -0
- pyawe_ffs/_version.py +34 -0
- pyawe_ffs/backend_error.py +11 -0
- pyawe_ffs/bin/win/BuildFlash.exe +0 -0
- pyawe_ffs/buildflash_backend.py +63 -0
- pyawe_ffs/cli/__main__.py +179 -0
- pyawe_ffs/cli/show_docs.py +59 -0
- pyawe_ffs/doc/docs/api.md +16 -0
- pyawe_ffs/doc/docs/changelog.md +25 -0
- pyawe_ffs/doc/docs/img/dspconcepts_logo.png +0 -0
- pyawe_ffs/doc/docs/index.md +13 -0
- pyawe_ffs/doc/docs/license.md +5 -0
- pyawe_ffs/doc/docs/scripts.md +25 -0
- pyawe_ffs/doc/layout.svg +4 -0
- pyawe_ffs/doc/mkdocs.yml +54 -0
- pyawe_ffs/purepy/__init__.py +0 -0
- pyawe_ffs/purepy/constants.py +12 -0
- pyawe_ffs/purepy/ffs.py +180 -0
- pyawe_ffs/purepy/objects/__init__.py +0 -0
- pyawe_ffs/purepy/objects/allocationtable.py +26 -0
- pyawe_ffs/purepy/objects/emptyblock.py +18 -0
- pyawe_ffs/purepy/objects/fileentry.py +118 -0
- pyawe_ffs/purepy/objects/systeminfo.py +70 -0
- pyawe_ffs/py_backend.py +59 -0
- pyawe_ffs-1.0.0.dist-info/METADATA +75 -0
- pyawe_ffs-1.0.0.dist-info/RECORD +31 -0
- pyawe_ffs-1.0.0.dist-info/WHEEL +4 -0
- pyawe_ffs-1.0.0.dist-info/entry_points.txt +3 -0
pyawe_ffs/FfsBackend.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 DSP Concepts, Inc.
|
|
3
|
+
|
|
4
|
+
import csv
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
import numpy as np
|
|
10
|
+
from pyawe_ffs.FfsEntry import FfsEntry
|
|
11
|
+
from pyawe_ffs.buildflash_backend import FfsBackend
|
|
12
|
+
from pyawe_ffs.py_backend import FfsPyBackend
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FfsContainer:
|
|
18
|
+
""" A container for several FFS entries
|
|
19
|
+
"""
|
|
20
|
+
def __init__(self, max_size: int = 0x400000, old_backend: bool = False):
|
|
21
|
+
self._entries: list[FfsEntry] = []
|
|
22
|
+
self._cfg = {'max_size': max_size, 'coeff_table_size': 14}
|
|
23
|
+
self._old_backend = old_backend
|
|
24
|
+
|
|
25
|
+
def append(self, fname: str | Path, data: bytes | None = None):
|
|
26
|
+
""" adds a new file to the container """
|
|
27
|
+
self._entries.append(FfsEntry(str(Path(fname)), data))
|
|
28
|
+
logger.info("Added new entry %s to FfsContainer", fname)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def entries(self):
|
|
32
|
+
""" property to return the list of FfsEntry values """
|
|
33
|
+
return self._entries
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def from_file(cls, fname: Path, old_backend: bool = False):
|
|
37
|
+
""" creates a new FfsContainer based on an existing FFS file """
|
|
38
|
+
if old_backend:
|
|
39
|
+
raise NotImplementedError("Loading from existing file not implemented yet for old backend")
|
|
40
|
+
self = cls(old_backend=old_backend)
|
|
41
|
+
backend = FfsPyBackend.from_file(fname)
|
|
42
|
+
for entry in backend.files:
|
|
43
|
+
self.append(entry.input_file, entry.data)
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def save(self, fname: str | os.PathLike, dry_run=False):
|
|
47
|
+
""" stores the added file data into the bin buffer
|
|
48
|
+
calls to the backend to convert the data
|
|
49
|
+
"""
|
|
50
|
+
fname = Path(fname)
|
|
51
|
+
fname.parent.mkdir(parents=True, exist_ok=True)
|
|
52
|
+
|
|
53
|
+
logger.info("Creating FFS data file %s", fname)
|
|
54
|
+
if self._old_backend:
|
|
55
|
+
writer = FfsBackend(self._cfg['max_size'], dry_run)
|
|
56
|
+
else:
|
|
57
|
+
writer = FfsPyBackend(self._cfg['max_size'], dry_run)
|
|
58
|
+
file_paths = [e.path for e in self._entries]
|
|
59
|
+
output = writer.write(fname, file_paths)
|
|
60
|
+
|
|
61
|
+
if not dry_run:
|
|
62
|
+
# also store TXT and CSV file with the entry names
|
|
63
|
+
self.save_filelist_txt(fname.with_suffix(".txt"))
|
|
64
|
+
self.save_filelist_csv(fname.with_suffix(".csv"))
|
|
65
|
+
|
|
66
|
+
return output
|
|
67
|
+
|
|
68
|
+
def save_filelist_txt(self, fname: Path):
|
|
69
|
+
""" saves the list of entries into a TXT file as plain name """
|
|
70
|
+
with open(fname, "w", encoding="utf-8") as f:
|
|
71
|
+
for idx, e in enumerate(self._entries):
|
|
72
|
+
f.write(f"{idx}: {e.path.name}\n")
|
|
73
|
+
|
|
74
|
+
def save_filelist_csv(self, fname: Path):
|
|
75
|
+
""" saves the list of entries in a CSV file that can directly be used in Designer
|
|
76
|
+
|
|
77
|
+
This file is typically directly used in an Arrayset module which controls
|
|
78
|
+
the file name property of a WaveOneShotPlayerFFS module.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
# TODO: find a better way without numpy dependency,
|
|
82
|
+
# this is how a UINT32 buffer can be converted to byte buffer/string:
|
|
83
|
+
# struct.pack("i" * len(cmd.payload['values']), *(cmd.payload['values'])).decode().rstrip('\0')
|
|
84
|
+
# there should be a similar approach
|
|
85
|
+
# keeping older (ugly, but known to work) implementation here for now.
|
|
86
|
+
|
|
87
|
+
coeff_table_size = self._cfg['coeff_table_size']
|
|
88
|
+
coeff_table = np.zeros((coeff_table_size, len(self._entries)), dtype=np.uint32)
|
|
89
|
+
|
|
90
|
+
for idx_file, e in enumerate(self._entries):
|
|
91
|
+
|
|
92
|
+
file_bytes = bytearray(e.path.name, 'utf-8')
|
|
93
|
+
for _ in range(4 - len(file_bytes) % 4):
|
|
94
|
+
file_bytes += b'\x00'
|
|
95
|
+
file_bytes_size = min(len(file_bytes), coeff_table_size * 4 - 1)
|
|
96
|
+
for word in range(0, file_bytes_size, 4):
|
|
97
|
+
coeff_table[int(word / 4), idx_file] += file_bytes[word + 3] << 24
|
|
98
|
+
coeff_table[int(word / 4), idx_file] += file_bytes[word + 2] << 16
|
|
99
|
+
coeff_table[int(word / 4), idx_file] += file_bytes[word + 1] << 8
|
|
100
|
+
coeff_table[int(word / 4), idx_file] += file_bytes[word]
|
|
101
|
+
|
|
102
|
+
with open(fname, "w", encoding="utf-8") as csv_file:
|
|
103
|
+
my_writer = csv.writer(csv_file, delimiter=',')
|
|
104
|
+
for row_idx in range(np.shape(coeff_table)[0]):
|
|
105
|
+
my_writer.writerow(coeff_table[row_idx, :])
|
pyawe_ffs/FfsEntry.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 DSP Concepts, Inc.
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FfsEntry:
|
|
12
|
+
""" a data entry in an FFS container
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
def __init__(self, fname: str, data: bytes | None = None):
|
|
16
|
+
self._fname = fname
|
|
17
|
+
self._content = data
|
|
18
|
+
|
|
19
|
+
def __str__(self):
|
|
20
|
+
return f"FfsEntry: {str(self._fname)} - {len(self._content)} bytes"
|
|
21
|
+
|
|
22
|
+
def store(self, outdir: str | Path):
|
|
23
|
+
""" store the data of this FFS entry in an output directory """
|
|
24
|
+
outdir = Path(outdir)
|
|
25
|
+
outdir.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
logger.info("Writing to %s", outdir / self._fname)
|
|
27
|
+
with (outdir / self._fname).open("wb") as f:
|
|
28
|
+
f.write(self._content)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def path(self):
|
|
32
|
+
""" returns the path to the mentioned file """
|
|
33
|
+
return Path(self._fname)
|
pyawe_ffs/__init__.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 DSP Concepts, Inc.
|
|
3
|
+
"""
|
|
4
|
+
# AWE FFS Creator/Parser
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
The programming interface is quite simple.
|
|
8
|
+
|
|
9
|
+
This is how to create a new file:
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from pyawe_ffs.FfsContainer import FfsContainer
|
|
13
|
+
ffs = FfsContainer()
|
|
14
|
+
ffs.append("my_wavedata_1.wav")
|
|
15
|
+
ffs.append("my_wavedata_2.wav")
|
|
16
|
+
ffs.save("my_ffs_buffer.bin")
|
|
17
|
+
```
|
|
18
|
+
This also generates `my_ffs_buffer.txt` and `my_ffs_buffer.csv`.
|
|
19
|
+
The CSV file can typically be used in a [TableSourceV2](https://documentation.dspconcepts.com/awe-designer/latest-version/tablesourcev2)
|
|
20
|
+
module to map indices to file names.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
An FFS buffer file can be read with and data extracted to a directory:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
ffs = FfsContainer.from_file("my_ffs_buffer.bin")
|
|
28
|
+
for entry in ffs.entries:
|
|
29
|
+
print(f"- {entry}")
|
|
30
|
+
entry.store("/tmp")
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you also want to generate corresponding list and csv files (see above), you can use:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
ffs = FfsContainer.from_file("my_ffs_buffer.bin")
|
|
37
|
+
ffs.save_filelist_txt("/tmp/mybuffer.txt")
|
|
38
|
+
ffs.save_filelist_csv("/tmp/mybuffer.csv")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
__all__ = ['version']
|
|
44
|
+
|
|
45
|
+
from ._version import version
|
pyawe_ffs/_version.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '1.0.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 0, 0)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class FfsBackendError(Exception):
|
|
2
|
+
""" contains information about why BuildFlash failed
|
|
3
|
+
- errcode is the return code of executable
|
|
4
|
+
- output is the stdout string
|
|
5
|
+
- command is the command which led to the problem
|
|
6
|
+
"""
|
|
7
|
+
def __init__(self, message: str, errcode: int, output: str, full_command: str):
|
|
8
|
+
super().__init__(message)
|
|
9
|
+
self.errcode = errcode
|
|
10
|
+
self.output = output
|
|
11
|
+
self.command = full_command
|
|
Binary file
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 DSP Concepts, Inc.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
from pyawe_ffs.backend_error import FfsBackendError
|
|
12
|
+
|
|
13
|
+
PLATFORM_DIR = "win" if sys.platform == "win32" else "linux_x64"
|
|
14
|
+
BUILDFL_EXE = "BuildFlash.exe" if sys.platform == "win32" else "BuildFlash"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# pylint: disable=too-few-public-methods
|
|
21
|
+
class FfsBackend:
|
|
22
|
+
""" Encapsulates the final writing to a file
|
|
23
|
+
|
|
24
|
+
Uses the BuildFlash tool executable to create a BIN file;
|
|
25
|
+
the constructor selects the (platform specific) executable,
|
|
26
|
+
the write() method
|
|
27
|
+
"""
|
|
28
|
+
def __init__(self, max_size: int, dry_run: bool = False):
|
|
29
|
+
self._exe = Path(__file__).parent / "bin" / PLATFORM_DIR / BUILDFL_EXE
|
|
30
|
+
self.max_size = max_size
|
|
31
|
+
self.dry_run = dry_run
|
|
32
|
+
if not self._exe.exists():
|
|
33
|
+
raise FileNotFoundError(f"BuildFlash executable not found: {self._exe}. Package only comes with Win32 executable")
|
|
34
|
+
|
|
35
|
+
def write(self, outputfile: Path, list_of_files: list[Path]):
|
|
36
|
+
"""
|
|
37
|
+
Takes input a list of files and writes them into an output file,
|
|
38
|
+
will call BuildFlash executable
|
|
39
|
+
"""
|
|
40
|
+
cmdargs = [
|
|
41
|
+
f'-size:{hex(self.max_size)}',
|
|
42
|
+
'-start:0x0',
|
|
43
|
+
'-flip:0',
|
|
44
|
+
'-pad',
|
|
45
|
+
f'-out:{outputfile}'
|
|
46
|
+
]
|
|
47
|
+
cmdargs += [f'-file:104:{fname}' for fname in list_of_files]
|
|
48
|
+
full_cmd = [self._exe] + cmdargs
|
|
49
|
+
logger.info("Calling BuildFlash : %s", full_cmd)
|
|
50
|
+
if self.dry_run:
|
|
51
|
+
return full_cmd, None
|
|
52
|
+
try:
|
|
53
|
+
env = dict(os.environ)
|
|
54
|
+
# keeping possibility to use a Linux version of BuildFlash
|
|
55
|
+
if sys.platform != "win32":
|
|
56
|
+
env['LD_LIBRARY_PATH'] = self._exe.parent.as_posix()
|
|
57
|
+
output = subprocess.check_output(full_cmd, env=env)
|
|
58
|
+
except subprocess.CalledProcessError as e:
|
|
59
|
+
logger.error("BuildFlash failed with %s", e.returncode)
|
|
60
|
+
raise FfsBackendError("BuildFlash failed", e.returncode, e.output, str(full_cmd)) from e
|
|
61
|
+
|
|
62
|
+
# TODO: check/parse output
|
|
63
|
+
return full_cmd, output
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 DSP Concepts, Inc.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import logging
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pyawe_ffs
|
|
11
|
+
from pyawe_ffs.backend_error import FfsBackendError
|
|
12
|
+
from pyawe_ffs.FfsContainer import FfsContainer
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
DEFAULT_FFS_MAX_SIZE = 0x400000
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def add_to_ffs(args):
|
|
22
|
+
print(f"Adding to file: {args.ffs_file} (max size: {args.max})")
|
|
23
|
+
ffs = FfsContainer(max_size=args.max, old_backend=args.buildflash)
|
|
24
|
+
for newfile in args.files:
|
|
25
|
+
ffs.append(newfile)
|
|
26
|
+
print(f" {newfile}")
|
|
27
|
+
try:
|
|
28
|
+
ffs.save(args.ffs_file)
|
|
29
|
+
print("Also generated TXT/CSV files")
|
|
30
|
+
except FfsBackendError as e:
|
|
31
|
+
print(f"ERROR: {str(e)}")
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def list_ffs(args):
|
|
36
|
+
print(f"Displaying content of file: {args.ffs_file}")
|
|
37
|
+
try:
|
|
38
|
+
ffs = FfsContainer.from_file(args.ffs_file)
|
|
39
|
+
for entry in ffs.entries:
|
|
40
|
+
print(f"- {entry}")
|
|
41
|
+
except FfsBackendError as e:
|
|
42
|
+
print(f"ERROR: {str(e)}")
|
|
43
|
+
sys.exit(1)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def extract_ffs(args):
|
|
47
|
+
print(f"Extract data from file: {args.ffs_file} into {args.output}")
|
|
48
|
+
try:
|
|
49
|
+
ffs = FfsContainer.from_file(args.ffs_file)
|
|
50
|
+
for entry in ffs.entries:
|
|
51
|
+
entry.store(args.output)
|
|
52
|
+
print(f"- {entry}")
|
|
53
|
+
|
|
54
|
+
print("Writing TXT/CSV files")
|
|
55
|
+
out_path = Path(args.output)
|
|
56
|
+
orig_file_path = Path(args.ffs_file)
|
|
57
|
+
ffs.save_filelist_txt(out_path / orig_file_path.with_suffix(".txt").name)
|
|
58
|
+
ffs.save_filelist_csv(out_path / orig_file_path.with_suffix(".csv").name)
|
|
59
|
+
|
|
60
|
+
except FfsBackendError as e:
|
|
61
|
+
print(f"ERROR: {str(e)}")
|
|
62
|
+
sys.exit(1)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def main(*sysargs):
|
|
66
|
+
"""
|
|
67
|
+
Creates or parses an FFS binary file
|
|
68
|
+
"""
|
|
69
|
+
parser = argparse.ArgumentParser(description=f"Creates or parses an FFS binary file.\n"
|
|
70
|
+
f"Version: {pyawe_ffs.version}",
|
|
71
|
+
formatter_class=argparse.RawTextHelpFormatter)
|
|
72
|
+
|
|
73
|
+
parser.add_argument(
|
|
74
|
+
'--version',
|
|
75
|
+
action='store_true',
|
|
76
|
+
help="Shows program version."
|
|
77
|
+
)
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
'-v', '--verbose',
|
|
80
|
+
action='count',
|
|
81
|
+
default=0,
|
|
82
|
+
help="Enables more verbosity. Use -vv to get even more."
|
|
83
|
+
)
|
|
84
|
+
parser.add_argument(
|
|
85
|
+
'--show-docs',
|
|
86
|
+
action='store_true',
|
|
87
|
+
help="Shows full HTML package documentation"
|
|
88
|
+
)
|
|
89
|
+
parser.add_argument(
|
|
90
|
+
'-B', '--buildflash',
|
|
91
|
+
action='store_true', help="Use legacy BuildFlash executable backend (to be removed soon)"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
subparsers = parser.add_subparsers(dest="command", required=False)
|
|
95
|
+
|
|
96
|
+
parser_add = subparsers.add_parser(
|
|
97
|
+
"add",
|
|
98
|
+
help="Add files to FFS Container"
|
|
99
|
+
)
|
|
100
|
+
parser_add.add_argument(
|
|
101
|
+
"ffs_file",
|
|
102
|
+
help="FFS Container to be created or extended",
|
|
103
|
+
type=str
|
|
104
|
+
)
|
|
105
|
+
parser_add.add_argument(
|
|
106
|
+
"files",
|
|
107
|
+
nargs="+",
|
|
108
|
+
help="Files that will be added to FFS Container",
|
|
109
|
+
type=str
|
|
110
|
+
)
|
|
111
|
+
parser_add.add_argument(
|
|
112
|
+
"-m", "--max",
|
|
113
|
+
help=f"Maximum size of FFS Container in number of bytes. Default (4MB) {DEFAULT_FFS_MAX_SIZE}",
|
|
114
|
+
default=DEFAULT_FFS_MAX_SIZE,
|
|
115
|
+
type=int
|
|
116
|
+
)
|
|
117
|
+
parser_add.add_argument(
|
|
118
|
+
"--strict",
|
|
119
|
+
help="Only allow WAV and OGG file input [NOT USED YET]",
|
|
120
|
+
action="store_false"
|
|
121
|
+
)
|
|
122
|
+
parser_add.set_defaults(func=add_to_ffs)
|
|
123
|
+
|
|
124
|
+
parser_list = subparsers.add_parser(
|
|
125
|
+
"list",
|
|
126
|
+
help="List files in FFS Container"
|
|
127
|
+
)
|
|
128
|
+
parser_list.add_argument(
|
|
129
|
+
"ffs_file",
|
|
130
|
+
help="FFS Container to be analyzed",
|
|
131
|
+
type=str
|
|
132
|
+
)
|
|
133
|
+
parser_add.add_argument(
|
|
134
|
+
"-f", "--format",
|
|
135
|
+
help="List files as CSV or TXT",
|
|
136
|
+
choices=['txt', 'csv']
|
|
137
|
+
)
|
|
138
|
+
parser_list.set_defaults(func=list_ffs)
|
|
139
|
+
|
|
140
|
+
parser_extract = subparsers.add_parser(
|
|
141
|
+
"extract",
|
|
142
|
+
help="Extract data from FFS Container"
|
|
143
|
+
)
|
|
144
|
+
parser_extract.add_argument(
|
|
145
|
+
"ffs_file",
|
|
146
|
+
help="FFS Container to be extracted",
|
|
147
|
+
type=str
|
|
148
|
+
)
|
|
149
|
+
parser_extract.add_argument(
|
|
150
|
+
"-o", "--output",
|
|
151
|
+
help="Directory into which FFS content is extracted",
|
|
152
|
+
default="."
|
|
153
|
+
)
|
|
154
|
+
parser_extract.set_defaults(func=extract_ffs)
|
|
155
|
+
|
|
156
|
+
args = parser.parse_args(*sysargs)
|
|
157
|
+
|
|
158
|
+
FORMAT = '%(name)s:%(levelname)7s: %(threadName)10s: %(asctime)-15s : %(message)s'
|
|
159
|
+
levels = [logging.WARNING, logging.INFO, logging.DEBUG]
|
|
160
|
+
level = levels[min(args.verbose, len(levels) - 1)] # cap to last level index
|
|
161
|
+
logging.basicConfig(format=FORMAT, level=level)
|
|
162
|
+
|
|
163
|
+
if args.version:
|
|
164
|
+
print(pyawe_ffs.version)
|
|
165
|
+
sys.exit(0)
|
|
166
|
+
|
|
167
|
+
if args.show_docs:
|
|
168
|
+
print("--show_docs not implemented here (yet). Use: awe-ffs-docs")
|
|
169
|
+
sys.exit(0)
|
|
170
|
+
|
|
171
|
+
if not args.command:
|
|
172
|
+
parser.print_help()
|
|
173
|
+
sys.exit(0)
|
|
174
|
+
|
|
175
|
+
args.func(args)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
if __name__ == "__main__":
|
|
179
|
+
main(sys.argv[1:])
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2025 DSP Concepts, Inc.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import socket
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def find_free_port(start: int = 8000, end: int = 8080, verbose: int = 0) -> int:
|
|
13
|
+
""" trying to find a next suitable port to run the service on """
|
|
14
|
+
for port in range(start, end):
|
|
15
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
16
|
+
try:
|
|
17
|
+
sock.bind(("0.0.0.0", port))
|
|
18
|
+
if verbose:
|
|
19
|
+
print(f"Port {port} found to serve HTML!")
|
|
20
|
+
port_to_use = port
|
|
21
|
+
break
|
|
22
|
+
except socket.error:
|
|
23
|
+
if verbose:
|
|
24
|
+
print(f"Port {port} busy it seems.")
|
|
25
|
+
pass
|
|
26
|
+
finally:
|
|
27
|
+
sock.close()
|
|
28
|
+
|
|
29
|
+
if not port_to_use:
|
|
30
|
+
raise SystemError("No open port found to serve documentation!")
|
|
31
|
+
return port_to_use
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def main():
|
|
35
|
+
parser = argparse.ArgumentParser(description="Displays the HTML documentation.")
|
|
36
|
+
parser.add_argument('-v', '--verbose', action='count', default=0,
|
|
37
|
+
help="Be a bit more verbose")
|
|
38
|
+
args = parser.parse_args()
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
from mkdocs.__main__ import cli
|
|
42
|
+
except ImportError:
|
|
43
|
+
print("Feature unavailable! Install pyawe_ffs[doc] to view docs.")
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
pkg_dir = sys.modules["pyawe_ffs"].__path__[0]
|
|
47
|
+
doc_dir = Path(pkg_dir) / "doc"
|
|
48
|
+
os.chdir(doc_dir)
|
|
49
|
+
|
|
50
|
+
port = find_free_port(verbose=args.verbose)
|
|
51
|
+
|
|
52
|
+
print(f"Serving documentation from {doc_dir} at localhost:{port}")
|
|
53
|
+
print("Press Ctrl-C to stop ")
|
|
54
|
+
|
|
55
|
+
cli(['serve', '--open', '-q', '-a', f"localhost:{port}"], standalone_mode=True)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
main()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## 1.0.0 - 2026-01-16
|
|
7
|
+
|
|
8
|
+
- **NEW**: Python only backend added as default, no Windows/Linux executable required anymore. Note that this legacy backend using BuildFlash executable is still available with [-B][awe-ffs] parameter (windows only!)
|
|
9
|
+
- **NEW**: User documentation updated and improved - get with [awe-ffs-docs][]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## 0.1.2 - 2025-06-07
|
|
13
|
+
|
|
14
|
+
Internal CM/CI changes
|
|
15
|
+
|
|
16
|
+
## 0.1.1
|
|
17
|
+
|
|
18
|
+
Internal editorial changes
|
|
19
|
+
|
|
20
|
+
## 0.1.0 - 2025-04-09
|
|
21
|
+
|
|
22
|
+
- **NEW**: very first version; copied over from another project and repackaged;
|
|
23
|
+
|
|
24
|
+
- wrapping Windows/Linux executables for building flash file (BuildFlash.exe)
|
|
25
|
+
- lean library API interface
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
This is the documentation of {{name}}.
|
|
4
|
+
|
|
5
|
+
Version: _{{pkg.version}}_
|
|
6
|
+
|
|
7
|
+
This Python library provides a small programmatic interface to create an FFS file container.
|
|
8
|
+
|
|
9
|
+
These containers are used in the integration and deployment of large audio (WAV, OGG) data
|
|
10
|
+
to a platform which runs AWE Core.
|
|
11
|
+
See https://documentation.dspconcepts.com/awe-core/latest-version/flash-file-system-integration-guide for more detail.
|
|
12
|
+
|
|
13
|
+
The package provides an [API][], and some [command line scripts][scripts].
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Scripts
|
|
2
|
+
|
|
3
|
+
After installation of the `{{pkg.name}}` package the following scripts are available:
|
|
4
|
+
|
|
5
|
+
## awe-ffs
|
|
6
|
+
|
|
7
|
+
```python exec="on"
|
|
8
|
+
import subprocess
|
|
9
|
+
from textwrap import indent
|
|
10
|
+
|
|
11
|
+
output = subprocess.check_output(["awe-ffs", "-h"])
|
|
12
|
+
|
|
13
|
+
print(indent(f"""{output.decode("utf-8")}""", " "))
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## awe-ffs-docs
|
|
17
|
+
|
|
18
|
+
```python exec="on"
|
|
19
|
+
import subprocess
|
|
20
|
+
from textwrap import indent
|
|
21
|
+
|
|
22
|
+
output = subprocess.check_output(["awe-ffs-docs", "-h"])
|
|
23
|
+
|
|
24
|
+
print(indent(f"""{output.decode("utf-8")}""", " "))
|
|
25
|
+
```
|