Merge ~dirksu/plainbox-provider-resource:check_wifi6e into plainbox-provider-resource:master

Proposed by Dirk Su
Status: Superseded
Proposed branch: ~dirksu/plainbox-provider-resource:check_wifi6e
Merge into: plainbox-provider-resource:master
Diff against target: 54 lines (+38/-0)
2 files modified
bin/check_wifi6e.py (+37/-0)
jobs/resource.pxu (+1/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Needs Fixing
Checkbox Developers Pending
Review via email: mp+416646@code.launchpad.net

This proposal supersedes a proposal from 2022-03-09.

This proposal has been superseded by a proposal from 2022-03-11.

Commit message

Add 802.11ax 6GHz band check

To post a comment you must log in.
Revision history for this message
StanleyHuang (stanley31) wrote : Posted in a previous version of this proposal

You have to call system.exit or raise SystemExit in python script, or this job would always return ax_6g is supported

https://docs.python.org/3/library/sys.html#sys.exit

review: Needs Fixing
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

I'd simplify a bit the python code:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re
import subprocess
import sys

def main():
    if len(sys.argv) < 2:
        sys.exit(1)

    _6ghz_start = 5945
    _6ghz_end = 7125

    data = subprocess.getoutput(
        "iw phy{} info".format(sys.argv[1])).splitlines()
    check = False
    for line in data:
        if 'Frequencies' in line:
            check = True
            continue
        if check:
            if 'disabled' in line:
                continue
            match = re.search('^\s+\*\s+(\d{4})\s+MHz', line)
            if match:
                freq = int(match.group(1))
                if freq > _6ghz_start and freq < _6ghz_end:
                    sys.exit(0)
            else:
                check = False
    sys.exit(1)

if __name__ == '__main__':
    main()

review: Needs Fixing
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

to work the script that I propose requires the job definition to be modified like this:

for i in $(iw dev | grep -oP 'Interface\s+\K\w+'); do check_wifi6e.py $(iw dev "$i" info | grep -oP 'wiphy\s+\K\d+') && echo "$i""_ax_6GHz: supported" || echo "$i""_ax_6GHz: unsupported"; done

review: Needs Fixing

Unmerged commits

f1e433a... by Dirk Su

Add 802.11ax 6GHz band check

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/check_wifi6e.py b/bin/check_wifi6e.py
0new file mode 1007550new file mode 100755
index 0000000..79650e9
--- /dev/null
+++ b/bin/check_wifi6e.py
@@ -0,0 +1,37 @@
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4import subprocess
5import sys
6
7
8def main():
9 if len(sys.argv) < 2:
10 print(sys.argv[0] + " [interface]")
11 sys.exit(1)
12
13 _6ghz_start = 5945
14 _6ghz_end = 7125
15
16 data = subprocess.run(
17 ['iw', sys.argv[1], 'info'],
18 capture_output=True,
19 encoding='utf-8')
20 if data.returncode:
21 print(sys.argv[1] + " is not valid wireless interface")
22 sys.exit(1)
23 index = data.stdout[data.stdout.find('wiphy') + 6]
24 data = subprocess.getoutput("iw phy" + index + " info").splitlines()
25 for i, line in enumerate(data):
26 if 'Frequencies' in line:
27 while data[i + 1].startswith('\t\t\t'):
28 if 'disabled' not in (data[i + 1]):
29 freq = int(data[i + 1].split()[1])
30 if freq > _6ghz_start and freq < _6ghz_end:
31 sys.exit(0)
32 i = i + 1
33 sys.exit(1)
34
35
36if __name__ == '__main__':
37 main()
diff --git a/jobs/resource.pxu b/jobs/resource.pxu
index b84432e..da969eb 100644
--- a/jobs/resource.pxu
+++ b/jobs/resource.pxu
@@ -276,6 +276,7 @@ command:
276 # MCS 10 and 11 if present support the ax only 1024-QAM 276 # MCS 10 and 11 if present support the ax only 1024-QAM
277 # shellcheck disable=SC2046277 # shellcheck disable=SC2046
278 for i in $(iw dev | grep -oP 'Interface\s+\K\w+'); do iw phy phy$(iw dev "$i" info | grep -oP 'wiphy\s+\K\d+') info | grep -q 'MCS 0-11' && echo "$i""_ax: supported" || echo "$i""_ax: unsupported"; done278 for i in $(iw dev | grep -oP 'Interface\s+\K\w+'); do iw phy phy$(iw dev "$i" info | grep -oP 'wiphy\s+\K\d+') info | grep -q 'MCS 0-11' && echo "$i""_ax: supported" || echo "$i""_ax: unsupported"; done
279 for i in $(iw dev | grep -oP 'Interface\s+\K\w+'); do check_wifi6e.py $i && echo "$i""_ax_6GHz: supported" || echo "$i""_ax_6GHz: unsupported"; done
279estimated_duration: 0.5280estimated_duration: 0.5
280flags: preserve-locale281flags: preserve-locale
281282

Subscribers

People subscribed via source and target branches