Coverage for d7a/system_files/dll_config.py: 97%
33 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-24 08:03 +0200
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-24 08:03 +0200
1#
2# Copyright (c) 2015-2021 University of Antwerp, Aloxy NV.
3#
4# This file is part of pyd7a.
5# See https://github.com/Sub-IoT/pyd7a for further info.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19import struct
21from d7a.support.schema import Validatable, Types
22from d7a.system_files.file import File
23from d7a.system_files.system_file_ids import SystemFileIds
26class DllConfigFile(File, Validatable):
27 SCHEMA = [{
28 "active_access_class": Types.INTEGER(min=0, max=0xFF),
29 "LQ_filter": Types.INTEGER(min=0, max=0xFF),
30 "NF_CTRL": Types.INTEGER(min=0, max=0xFF),
31 "RX_NF_method_parameter": Types.INTEGER(min=0, max=0xFF),
32 "TX_NF_method_parameter": Types.INTEGER(min=0, max=0xFF)
33 }]
35 def __init__(self, active_access_class=0, lq_filter=0x00, nf_ctrl=0x00, rx_nf_method_parameter=0x00
36 , tx_nf_method_parameter=0x00):
37 self.active_access_class = active_access_class
38 self.lq_filter = lq_filter
39 self.nf_ctrl = nf_ctrl
40 self.rx_nf_method_parameter = rx_nf_method_parameter
41 self.tx_nf_method_parameter = tx_nf_method_parameter
42 File.__init__(self, SystemFileIds.DLL_CONFIG.value, 7)
43 Validatable.__init__(self)
45 @staticmethod
46 def parse(s, offset=0, length=7):
47 ac = s.read("uint:8")
48 _rfu = s.read("uint:16")
49 lq_filter = s.read("uint:8")
50 nf_ctrl = s.read("uint:8")
51 rx_nf_method_parameter = s.read("uint:8")
52 tx_nf_method_parameter = s.read("uint:8")
53 return DllConfigFile(active_access_class=ac, lq_filter=lq_filter, nf_ctrl=nf_ctrl,
54 rx_nf_method_parameter=rx_nf_method_parameter, tx_nf_method_parameter=tx_nf_method_parameter)
56 def __iter__(self):
57 yield self.active_access_class
58 for byte in bytearray(struct.pack(">H", 0)): # RFU
59 yield byte
60 yield self.lq_filter
61 yield self.nf_ctrl
62 yield self.rx_nf_method_parameter
63 yield self.tx_nf_method_parameter
66 def __str__(self):
67 return "active_access_class={}, lq_filter={}, nf_ctrl={}, rx_nf_method_parameter, tx_nf_method_parameter".format(self.active_access_class, self.lq_filter, self.nf_ctrl, self.rx_nf_method_parameter, self.tx_nf_method_parameter)