Skip to content

Commit 6ff21fa

Browse files
authored
Merge pull request #8 from sl8vz/fix_upstream_driver_support
fix pds_compress usage from other module
2 parents e5b77b5 + 7ca5906 commit 6ff21fa

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

test-feature/pds_compress.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ def main(options):
527527
elif options.out_format == "tlv":
528528
# We may apply this encoding to all the other outputs. However, the TLV
529529
# is the only one which generates binary data.
530-
options.output.reconfigure(encoding='charmap', newline='')
530+
if __name__ == '__main__':
531+
options.output.reconfigure(encoding='charmap', newline='')
531532
formattlv(options.output, str_result)
532533
elif options.out_format == "pds":
533534
options.output.write(str_result)
@@ -538,14 +539,20 @@ def main(options):
538539
# This function is only an help for third-party tools that import pds_compress
539540
# as a python module (also note it is necessary to add .py extention to this in
540541
# order to import it).
541-
def compress_string(str_in, extra_options=""):
542+
def compress_string(str_in, extra_options="", format="pds"):
542543
global g_defs, g_result, g_ret_value
543544
g_defs = {}
544545
g_result = []
545546
g_ret_value = 0
547+
if format == "tlv":
548+
extra_options += " --out=tlv"
546549
options = parse_cmdline([ "-" ] + extra_options.split())
547550
options.input = io.StringIO(str_in)
548-
options.output = io.StringIO()
551+
if format == "tlv":
552+
options.output = io.StringIO(newline='')
553+
else:
554+
options.output = io.StringIO()
555+
549556
main(options)
550557
return options.output.getvalue()
551558

test-feature/wfx_test_target.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
pds_env['SEND_PDS_FILE'] = "/sys/kernel/debug/ieee80211/phy0/wfx/send_pds"
2222
pds_env['PDS_DEFINITION_ROOT'] = ""
2323
pds_env['PDS_DEFINITION_FILE'] = "definitions.in"
24-
# If using the upstream wfx driver, set below `pds_env['required_options'] = "--out=tlv"`
2524
pds_env['required_options'] = []
2625
pds_env['useful_options'] = []
26+
# If using mainstream driver, set pds_output_format to "tlv"
27+
pds_env['pds_output_format'] = "pds"
2728

2829

2930
class WfxTestTarget(object):
@@ -44,6 +45,7 @@ def __init__(self, nickname, **kwargs):
4445
self.link = None
4546
self.required_options = pds_env['required_options']
4647
self.useful_options = pds_env['useful_options']
48+
self.pds_output_format = pds_env['pds_output_format']
4749
self.fmac_cli = False
4850

4951
if 'host' in kwargs:
@@ -120,7 +122,13 @@ def _prepare_test_data(self, parameters):
120122

121123
pds_string = "#include \"" + pds_env['PDS_DEFINITION_ROOT'] + pds_env['PDS_DEFINITION_FILE']\
122124
+ "\"\n\n" + pds_compatibility_text + pds_sections
123-
compressed_string = compress_string(pds_string, self.required_options)
125+
126+
compressed_string = compress_string(pds_string, format=self.pds_output_format)
127+
128+
# The TLV format has some binary data that needs to be included
129+
if self.pds_output_format == "tlv":
130+
compressed_string = repr(compressed_string).strip("'")
131+
124132
if self.human_trace:
125133
print('human readable: ' + pds_string)
126134
if self.compressed_trace:

0 commit comments

Comments
 (0)