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
1diff --git a/bin/check_wifi6e.py b/bin/check_wifi6e.py
2new file mode 100755
3index 0000000..79650e9
4--- /dev/null
5+++ b/bin/check_wifi6e.py
6@@ -0,0 +1,37 @@
7+#!/usr/bin/env python3
8+# -*- coding: utf-8 -*-
9+
10+import subprocess
11+import sys
12+
13+
14+def main():
15+ if len(sys.argv) < 2:
16+ print(sys.argv[0] + " [interface]")
17+ sys.exit(1)
18+
19+ _6ghz_start = 5945
20+ _6ghz_end = 7125
21+
22+ data = subprocess.run(
23+ ['iw', sys.argv[1], 'info'],
24+ capture_output=True,
25+ encoding='utf-8')
26+ if data.returncode:
27+ print(sys.argv[1] + " is not valid wireless interface")
28+ sys.exit(1)
29+ index = data.stdout[data.stdout.find('wiphy') + 6]
30+ data = subprocess.getoutput("iw phy" + index + " info").splitlines()
31+ for i, line in enumerate(data):
32+ if 'Frequencies' in line:
33+ while data[i + 1].startswith('\t\t\t'):
34+ if 'disabled' not in (data[i + 1]):
35+ freq = int(data[i + 1].split()[1])
36+ if freq > _6ghz_start and freq < _6ghz_end:
37+ sys.exit(0)
38+ i = i + 1
39+ sys.exit(1)
40+
41+
42+if __name__ == '__main__':
43+ main()
44diff --git a/jobs/resource.pxu b/jobs/resource.pxu
45index b84432e..da969eb 100644
46--- a/jobs/resource.pxu
47+++ b/jobs/resource.pxu
48@@ -276,6 +276,7 @@ command:
49 # MCS 10 and 11 if present support the ax only 1024-QAM
50 # shellcheck disable=SC2046
51 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
52+ 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
53 estimated_duration: 0.5
54 flags: preserve-locale
55

Subscribers

People subscribed via source and target branches