MCPcopy Create free account
hub / github.com/kiibohd/controller / read_args

Method read_args

Scan/TestIn/host.py:195–230  ·  view source on GitHub ↗

Using kll.json, read the arguments from the args pointer. @returns: List of arguments

(self)

Source from the content-addressed store, hash-verified

193 return name, arg_definitions
194
195 def read_args(self):
196 '''
197 Using kll.json, read the arguments from the args pointer.
198
199 @returns: List of arguments
200 '''
201 name, arg_definitions = self.read_capability()
202
203 # Build of args for namedtuple
204 arg_names = [arg['name'] for arg in arg_definitions]
205 ntuple = namedtuple(name, arg_names)
206
207 # Build list of extracted arguments
208 arg_values = []
209 position = 0
210 for arg in arg_definitions:
211 value = None
212
213 # Cast based on the width
214 if arg['width'] == 1:
215 value = cast(byref(self.args.contents, position), POINTER(c_uint8)).contents
216 position += 1
217 elif arg['width'] == 2:
218 value = cast(byref(self.args.contents, position), POINTER(c_uint16)).contents
219 position += 2
220 elif arg['width'] == 4:
221 value = cast(byref(self.args.contents, position), POINTER(c_uint32)).contents
222 position += 4
223 else:
224 logger.error("Unknown width: {}", arg['width'])
225
226 arg_values.append(value)
227
228 # Build namedtuple with read values
229 arg_values = tuple(arg_values)
230 return ntuple(*arg_values)
231
232 def __repr__(self):
233 '''

Callers 1

__repr__Method · 0.95

Calls 1

read_capabilityMethod · 0.95

Tested by

no test coverage detected