Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ED_scan.py
00001 """ 00002 Copyright (c) 2017, Arm Limited and affiliates. 00003 SPDX-License-Identifier: Apache-2.0 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 """ 00017 00018 import threading 00019 import os,sys 00020 from icetea_lib.bench import Bench 00021 00022 class Testcase(Bench): 00023 def __init__(self): 00024 Bench.__init__(self, name = "ED_scan", 00025 title = "ED scan test", 00026 status = "development", 00027 type = "smoke", 00028 subtype = "", 00029 execution = { 00030 "skip": { 00031 "value": False, 00032 "reason": "" 00033 } 00034 }, 00035 author = "Valtteri Erkkila", 00036 purpose = "Tests reading the ED values from channels 11-16", 00037 feature = ["MLME-SCAN (ED)"], 00038 component = ["MAC"], 00039 requirements = { 00040 "duts": { 00041 '*': { 00042 "count":3, 00043 "type": "hardware", 00044 "allowed_platforms": ["K64F", "K66F", "NUCLEO_F429ZI", "KW24D", "UBLOX_EVK_ODIN_W2"], 00045 "application": { 00046 "name": "TEST_APPS-device-nanostack_mac_tester" 00047 } 00048 }, 00049 "1":{"nick": "First"}, 00050 "2":{"nick": "Second"}, 00051 "3":{"nick": "Third"} 00052 }} 00053 ) 00054 00055 def setUp(self): 00056 self.channel = 11 00057 self.command("First", "addr --64-bit 01:02:03:00:00:00:00:01") 00058 self.command("Second", "addr --64-bit 01:02:03:00:00:00:00:02") 00059 self.command("Third", "addr --64-bit 01:02:03:00:00:00:00:03") 00060 00061 def spam_channel(self, event): 00062 while not event.wait(0.1): 00063 self.lock_th.acquire() 00064 self.command("First", "data --dst_addr 01:02:03:00:00:00:00:03 --msdu {} --msdu_length {} --wait_for_confirm false".format(self.payload, len(self.payload))) 00065 self.command("Third", "data --dst_addr 01:02:03:00:00:00:00:01 --msdu {} --msdu_length {} --wait_for_confirm false".format(self.payload, len(self.payload))) 00066 self.lock_th.release() 00067 00068 def mask_from_channel_list(self, channels): 00069 res = 0 00070 for ch in channels: 00071 res = res | ( 1 << ch) 00072 return hex(res) 00073 00074 def case(self): 00075 self.lock_th = threading.Lock() 00076 self.payload = "01234567890123456789012345678901234567890123456789" 00077 00078 self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel)) 00079 self.command("Second", "start --pan_coordinator false --logical_channel {}".format(self.channel)) 00080 self.command("Third", "start --pan_coordinator false --logical_channel {}".format(self.channel)) 00081 00082 #No reason to print their spamming 00083 self.command("First", "silent-mode on") 00084 self.command("Third", "silent-mode on") 00085 00086 self.stop_event = threading.Event() 00087 self.th = threading.Thread(target=self.spam_channel, args=(self.stop_event,)) 00088 self.th.start() 00089 self.stopped = True 00090 channels = range(11,27) 00091 for i in range(0, 3): 00092 self.lock_th.acquire() 00093 self.command("First", "mlme-reset") 00094 self.command("First", "start --pan_coordinator true --logical_channel {}".format(self.channel)) 00095 self.command("Third", "mlme-reset") 00096 self.command("Third", "start --pan_coordinator false --logical_channel {}".format(self.channel)) 00097 self.lock_th.release() 00098 self.command("Second", "scan --scan_type 0 --scan_duration 7 --channel_mask {}".format(self.mask_from_channel_list(channels))) 00099 self.command("Second", "analyze-ed --channel {} --above 100".format(self.channel)) 00100 00101 def tearDown(self): 00102 self.command("First", "silent-mode off") 00103 self.command("Third", "silent-mode off") 00104 self.stop_event.set() 00105 self.th.join() 00106 del self.th 00107 self.reset_dut()
Generated on Tue Aug 9 2022 00:37:06 by
1.7.2