Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def scan_storage(self, area_name, callable, start=0, stop=None): if area_name == u'storage': data = self.storage_data elif area_name == u'streaming': data = self.streaming_data else: raise ArgumentError("U...
[ "Iterate over streaming or storage areas, calling callable.\n\n Args:\n area_name (str): Either 'storage' or 'streaming' to indicate which\n storage area to scan.\n callable (callable): A function that will be called as (offset, reading)\n for each reading ...
Please provide a description of the function:def push(self, value): stream = DataStream.FromEncoded(value.stream) if stream.stream_type == DataStream.OutputType: if len(self.streaming_data) == self.streaming_length: raise StorageFullError('Streaming buffer full') ...
[ "Store a new value for the given stream.\n\n Args:\n value (IOTileReading): The value to store. The stream\n parameter must have the correct value\n " ]
Please provide a description of the function:def get(self, buffer_type, offset): if buffer_type == u'streaming': chosen_buffer = self.streaming_data else: chosen_buffer = self.storage_data if offset >= len(chosen_buffer): raise StreamEmptyError("Inv...
[ "Get a reading from the buffer at offset.\n\n Offset is specified relative to the start of the data buffer.\n This means that if the buffer rolls over, the offset for a given\n item will appear to change. Anyone holding an offset outside of this\n engine object will need to be notified ...
Please provide a description of the function:def popn(self, buffer_type, count): buffer_type = str(buffer_type) if buffer_type == u'streaming': chosen_buffer = self.streaming_data else: chosen_buffer = self.storage_data if count > len(chosen_buffer): ...
[ "Remove and return the oldest count values from the named buffer\n\n Args:\n buffer_type (str): The buffer to pop from (either u\"storage\" or u\"streaming\")\n count (int): The number of readings to pop\n\n Returns:\n list(IOTileReading): The values popped from the bu...
Please provide a description of the function:async def connect(self, conn_id, connection_string): self._ensure_connection(conn_id, False) msg = dict(connection_string=connection_string) await self._send_command(OPERATIONS.CONNECT, msg, COMMANDS.ConnectResponse) self._setup_co...
[ "Connect to a device.\n\n See :meth:`AbstractDeviceAdapter.connect`.\n " ]
Please provide a description of the function:async def disconnect(self, conn_id): self._ensure_connection(conn_id, True) msg = dict(connection_string=self._get_property(conn_id, "connection_string")) try: await self._send_command(OPERATIONS.DISCONNECT, msg, COMMANDS.Disco...
[ "Disconnect from a connected device.\n\n See :meth:`AbstractDeviceAdapter.disconnect`.\n " ]
Please provide a description of the function:async def open_interface(self, conn_id, interface): self._ensure_connection(conn_id, True) connection_string = self._get_property(conn_id, "connection_string") msg = dict(interface=interface, connection_string=connection_string) awa...
[ "Open an interface on an IOTile device.\n\n See :meth:`AbstractDeviceAdapter.open_interface`.\n " ]
Please provide a description of the function:async def close_interface(self, conn_id, interface): self._ensure_connection(conn_id, True) connection_string = self._get_property(conn_id, "connection_string") msg = dict(interface=interface, connection_string=connection_string) aw...
[ "Close an interface on this IOTile device.\n\n See :meth:`AbstractDeviceAdapter.close_interface`.\n " ]
Please provide a description of the function:async def send_rpc(self, conn_id, address, rpc_id, payload, timeout): self._ensure_connection(conn_id, True) connection_string = self._get_property(conn_id, "connection_string") msg = dict(address=address, rpc_id=rpc_id, payload=base64.b64e...
[ "Send an RPC to a device.\n\n See :meth:`AbstractDeviceAdapter.send_rpc`.\n " ]
Please provide a description of the function:async def send_script(self, conn_id, data): self._ensure_connection(conn_id, True) connection_string = self._get_property(conn_id, "connection_string") msg = dict(connection_string=connection_string, fragment_count=1, fragment_index=0, ...
[ "Send a a script to this IOTile device\n\n Args:\n conn_id (int): A unique identifier that will refer to this connection\n data (bytes): the script to send to the device\n " ]
Please provide a description of the function:async def _on_report_notification(self, event): conn_string = event.get('connection_string') report = self._report_parser.deserialize_report(event.get('serialized_report')) self.notify_event(conn_string, 'report', report)
[ "Callback function called when a report event is received.\n\n Args:\n event (dict): The report_event\n " ]
Please provide a description of the function:async def _on_trace_notification(self, trace_event): conn_string = trace_event.get('connection_string') payload = trace_event.get('payload') await self.notify_event(conn_string, 'trace', payload)
[ "Callback function called when a trace chunk is received.\n\n Args:\n trace_chunk (dict): The received trace chunk information\n " ]
Please provide a description of the function:async def _on_progress_notification(self, progress): conn_string = progress.get('connection_string') done = progress.get('done_count') total = progress.get('total_count') operation = progress.get('operation') await self.noti...
[ "Callback function called when a progress notification is received.\n\n Args:\n progress (dict): The received notification containing the progress information\n " ]
Please provide a description of the function:async def _on_websocket_disconnect(self, _event): self.logger.info('Forcibly disconnected from the WebSocket server') conns = self._connections.copy() for conn_id in conns: conn_string = self._get_property(conn_id, 'connection_s...
[ "Callback function called when we have been disconnected from the server (by error or not).\n Allows to clean all if the disconnection was unexpected." ]
Please provide a description of the function:def _complete_parameters(param, variables): if isinstance(param, list): return [_complete_parameters(x, variables) for x in param] elif isinstance(param, dict): return {key: _complete_parameters(value, variables) for key, value in param.items()} ...
[ "Replace any parameters passed as {} in the yaml file with the variable names that are passed in\n\n Only strings, lists of strings, and dictionaries of strings can have\n replaceable values at the moment.\n\n " ]
Please provide a description of the function:def _extract_variables(param): variables = set() if isinstance(param, list): variables.update(*[_extract_variables(x) for x in param]) elif isinstance(param, dict): variables.update(*[_extract_variables(x) for x in param.values()]) elif...
[ "Find all template variables in args." ]
Please provide a description of the function:def _run_step(step_obj, step_declaration, initialized_resources): start_time = time.time() # Open any resources that need to be opened before we run this step for res_name in step_declaration.resources.opened: initialized_resources[res_name].open()...
[ "Actually run a step." ]
Please provide a description of the function:def archive(self, output_path): if self.path is None: raise ArgumentError("Cannot archive a recipe yet without a reference to its original yaml file in self.path") outfile = zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) ...
[ "Archive this recipe and all associated files into a .ship archive.\n\n Args:\n output_path (str): The path where the .ship file should be saved.\n " ]
Please provide a description of the function:def FromArchive(cls, path, actions_dict, resources_dict, temp_dir=None): if not path.endswith(".ship"): raise ArgumentError("Attempted to unpack a recipe archive from a file that did not end in .ship", path=path) name = os.path.basename...
[ "Create a RecipeObject from a .ship archive.\n\n This archive should have been generated from a previous call to\n iotile-ship -a <path to yaml file>\n\n or via iotile-build using autobuild_shiparchive().\n\n Args:\n path (str): The path to the recipe file that we wish to load...
Please provide a description of the function:def FromFile(cls, path, actions_dict, resources_dict, file_format="yaml", name=None): format_map = { "yaml": cls._process_yaml } format_handler = format_map.get(file_format) if format_handler is None: raise A...
[ "Create a RecipeObject from a file.\n\n The file should be a specially constructed yaml file that describes\n the recipe as well as the actions that it performs.\n\n Args:\n path (str): The path to the recipe file that we wish to load\n actions_dict (dict): A dictionary of...
Please provide a description of the function:def _parse_file_usage(cls, action_class, args): fixed_files = {} variable_files = [] if not hasattr(action_class, 'FILES'): return fixed_files, variable_files for file_arg in action_class.FILES: arg_value = ...
[ "Find all external files referenced by an action." ]
Please provide a description of the function:def _parse_resource_declarations(cls, declarations, resource_map): resources = {} for decl in declarations: name = decl.pop('name') typename = decl.pop('type') desc = decl.pop('description', None) aut...
[ "Parse out what resources are declared as shared for this recipe." ]
Please provide a description of the function:def _parse_variable_defaults(cls, defaults): default_dict = {} for item in defaults: key = next(iter(item)) value = item[key] if key in default_dict: raise RecipeFileInvalid("Default variable val...
[ "Parse out all of the variable defaults." ]
Please provide a description of the function:def _parse_resource_usage(cls, action_dict, declarations): raw_used = action_dict.pop('use', []) opened = [x.strip() for x in action_dict.pop('open_before', [])] closed = [x.strip() for x in action_dict.pop('close_after', [])] used ...
[ "Parse out what resources are used, opened and closed in an action step." ]
Please provide a description of the function:def prepare(self, variables): initializedsteps = [] if variables is None: variables = dict() for step, params, _resources, _files in self.steps: new_params = _complete_parameters(params, variables) initiali...
[ "Initialize all steps in this recipe using their parameters.\n\n Args:\n variables (dict): A dictionary of global variable definitions\n that may be used to replace or augment the parameters given\n to each step.\n\n Returns:\n list of RecipeActionOb...
Please provide a description of the function:def _prepare_resources(self, variables, overrides=None): if overrides is None: overrides = {} res_map = {} own_map = {} for decl in self.resources.values(): resource = overrides.get(decl.name) i...
[ "Create and optionally open all shared resources." ]
Please provide a description of the function:def _cleanup_resources(self, initialized_resources): cleanup_errors = [] # Make sure we clean up all resources that we can and don't error out at the # first one. for name, res in initialized_resources.items(): try: ...
[ "Cleanup all resources that we own that are open." ]
Please provide a description of the function:def run(self, variables=None, overrides=None): old_dir = os.getcwd() try: os.chdir(self.run_directory) initialized_steps = self.prepare(variables) owned_resources = {} try: print("Run...
[ "Initialize and run this recipe.\n\n By default all necessary shared resources are created and destroyed in\n this function unless you pass them preinitizlied in overrides, in\n which case they are used as is. The overrides parameter is designed\n to allow testability of iotile-ship rec...
Please provide a description of the function:def generate(env): c_file, cxx_file = SCons.Tool.createCFileBuilders(env) # C c_file.add_action('.y', YaccAction) c_file.add_emitter('.y', yEmitter) c_file.add_action('.yacc', YaccAction) c_file.add_emitter('.yacc', yEmitter) # Objective-C...
[ "Add Builders and construction variables for yacc to an Environment." ]
Please provide a description of the function:def generate(env): SCons.Tool.createSharedLibBuilder(env) SCons.Tool.createProgBuilder(env) env['LINK'] = '$CC' env['LINKFLAGS'] = SCons.Util.CLVar('') env['LINKCOM'] = '$LINK -q $LINKFLAGS -e$TARGET $SOURCES $LIBS' env['LIBDIRPREFI...
[ "Add Builders and construction variables for Borland ilink to an\n Environment." ]
Please provide a description of the function:def find_sdk_dir(self): if not SCons.Util.can_read_reg: debug('find_sdk_dir(): can not read registry') return None hkey = self.HKEY_FMT % self.hkey_data debug('find_sdk_dir(): checking registry:{}'.format(hkey)) ...
[ "Try to find the MS SDK from the registry.\n\n Return None if failed or the directory does not exist.\n " ]
Please provide a description of the function:def get_sdk_dir(self): try: return self._sdk_dir except AttributeError: sdk_dir = self.find_sdk_dir() self._sdk_dir = sdk_dir return sdk_dir
[ "Return the MSSSDK given the version string." ]
Please provide a description of the function:def get_sdk_vc_script(self,host_arch, target_arch): if (host_arch == 'amd64' and target_arch == 'x86'): # No cross tools needed compiling 32 bits on 64 bit machine host_arch=target_arch arch_string=target_arch if (ho...
[ " Return the script to initialize the VC compiler installed by SDK\n " ]
Please provide a description of the function:def execute(self, sensor_graph, scope_stack): parent = scope_stack[-1] try: slot = parent.resolve_identifier('current_slot', SlotIdentifier) except UnresolvedIdentifierError: raise SensorGraphSemanticError("set confi...
[ "Execute this statement on the sensor_graph given the current scope tree.\n\n This adds a single config variable assignment to the current sensor graph\n\n Args:\n sensor_graph (SensorGraph): The sensor graph that we are building or\n modifying\n scope_stack (list(...
Please provide a description of the function:def format_rpc(data): address, rpc_id, args, resp, _status = data name = rpc_name(rpc_id) if isinstance(args, (bytes, bytearray)): arg_str = hexlify(args) else: arg_str = repr(args) if isinstance(resp, (bytes, bytearray)): ...
[ "Format an RPC call and response.\n\n Args:\n data (tuple): A tuple containing the address, rpc_id, argument and\n response payloads and any error code.\n\n Returns:\n str: The formated RPC string.\n " ]
Please provide a description of the function:def execute(self, sensor_graph, scope_stack): self.execute_before(sensor_graph, scope_stack) for child in self.children: child.execute(sensor_graph, scope_stack) self.execute_after(sensor_graph, scope_stack)
[ "Execute this statement on the sensor_graph given the current scope tree.\n\n This function will likely modify the sensor_graph and will possibly\n also add to or remove from the scope_tree. If there are children nodes\n they will be called after execute_before and before execute_after,\n ...
Please provide a description of the function:async def _cleanup_old_connections(self): retval = await self._command_task.future_command(['_query_systemstate']) for conn in retval['active_connections']: self._logger.info("Forcible disconnecting connection %d", conn) awa...
[ "Remove all active connections and query the maximum number of supported connections\n " ]
Please provide a description of the function:async def start(self): self._command_task.start() try: await self._cleanup_old_connections() except Exception: await self.stop() raise #FIXME: This is a temporary hack, get the actual device we a...
[ "Start serving access to devices over bluetooth." ]
Please provide a description of the function:async def stop(self): await self._command_task.future_command(['_set_mode', 0, 0]) # Disable advertising await self._cleanup_old_connections() self._command_task.stop() self._stream.stop() self._serial_port.close() ...
[ "Safely shut down this interface" ]
Please provide a description of the function:async def _call_rpc(self, header): length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header)) rpc_id = (feature << 8) | cmd payload = self.rpc_payload[:length] self._logger.debug("Calling RPC %d:%04X with %s", addres...
[ "Call an RPC given a header and possibly a previously sent payload\n\n Args:\n header (bytearray): The RPC header we should call\n " ]
Please provide a description of the function:def format_script(sensor_graph): records = [] records.append(SetGraphOnlineRecord(False, address=8)) records.append(ClearDataRecord(address=8)) records.append(ResetGraphRecord(address=8)) for node in sensor_graph.nodes: records.append(AddN...
[ "Create a binary script containing this sensor graph.\n\n This function produces a repeatable script by applying a known sorting\n order to all constants and config variables when iterating over those\n dictionaries.\n\n Args:\n sensor_graph (SensorGraph): the sensor graph that we want to format\...
Please provide a description of the function:def dump(self): walkers = {} walkers.update({str(walker.selector): walker.dump() for walker in self._queue_walkers}) walkers.update({str(walker.selector): walker.dump() for walker in self._virtual_walkers}) return { u'en...
[ "Dump the state of this SensorLog.\n\n The purpose of this method is to be able to restore the same state\n later. However there are links in the SensorLog for stream walkers.\n\n So the dump process saves the state of each stream walker and upon\n restore, it looks through the current ...
Please provide a description of the function:def restore(self, state, permissive=False): self._engine.restore(state.get(u'engine')) self._last_values = {DataStream.FromString(stream): IOTileReading.FromDict(reading) for stream, reading in state.get(u"last_values", ...
[ "Restore a state previously dumped by a call to dump().\n\n The purpose of this method is to be able to restore a previously\n dumped state. However there are links in the SensorLog for stream\n walkers.\n\n So the restore process looks through the current set of stream walkers\n ...
Please provide a description of the function:def set_rollover(self, area, enabled): if area == u'streaming': self._rollover_streaming = enabled elif area == u'storage': self._rollover_storage = enabled else: raise ArgumentError("You must pass one of ...
[ "Configure whether rollover is enabled for streaming or storage streams.\n\n Normally a SensorLog is used in ring-buffer mode which means that old\n readings are automatically overwritten as needed when new data is saved.\n\n However, you can configure it into fill-stop mode by using:\n ...
Please provide a description of the function:def dump_constants(self): constants = [] for walker in self._virtual_walkers: if not walker.selector.inexhaustible: continue constants.append((walker.selector.as_stream(), walker.reading)) return co...
[ "Dump (stream, value) pairs for all constant streams.\n\n This method walks the internal list of defined stream walkers and\n dumps the current value for all constant streams.\n\n Returns:\n list of (DataStream, IOTileReading): A list of all of the defined constants.\n " ]
Please provide a description of the function:def watch(self, selector, callback): if selector not in self._monitors: self._monitors[selector] = set() self._monitors[selector].add(callback)
[ "Call a function whenever a stream changes.\n\n Args:\n selector (DataStreamSelector): The selector to watch.\n If this is None, it is treated as a wildcard selector\n that matches every stream.\n callback (callable): The function to call when a new\n ...
Please provide a description of the function:def create_walker(self, selector, skip_all=True): if selector.buffered: walker = BufferedStreamWalker(selector, self._engine, skip_all=skip_all) self._queue_walkers.append(walker) return walker if selector.match_...
[ "Create a stream walker based on the given selector.\n\n This function returns a StreamWalker subclass that will\n remain up to date and allow iterating over and popping readings\n from the stream(s) specified by the selector.\n\n When the stream walker is done, it should be passed to\n ...
Please provide a description of the function:def destroy_walker(self, walker): if walker.buffered: self._queue_walkers.remove(walker) else: self._virtual_walkers.remove(walker)
[ "Destroy a previously created stream walker.\n\n Args:\n walker (StreamWalker): The walker to remove from internal updating\n lists.\n " ]
Please provide a description of the function:def restore_walker(self, dumped_state): selector_string = dumped_state.get(u'selector') if selector_string is None: raise ArgumentError("Invalid stream walker state in restore_walker, missing 'selector' key", state=dumped_state) ...
[ "Restore a stream walker that was previously serialized.\n\n Since stream walkers need to be tracked in an internal list for\n notification purposes, we need to be careful with how we restore\n them to make sure they remain part of the right list.\n\n Args:\n dumped_state (dic...
Please provide a description of the function:def clear(self): for walker in self._virtual_walkers: walker.skip_all() self._engine.clear() for walker in self._queue_walkers: walker.skip_all() self._last_values = {}
[ "Clear all data from this sensor_log.\n\n All readings in all walkers are skipped and buffered data is\n destroyed.\n " ]
Please provide a description of the function:def push(self, stream, reading): # Make sure the stream is correct reading = copy.copy(reading) reading.stream = stream.encode() if stream.buffered: output_buffer = stream.output if self.id_assigner is not N...
[ "Push a reading into a stream, updating any associated stream walkers.\n\n Args:\n stream (DataStream): the stream to push the reading into\n reading (IOTileReading): the reading to push\n " ]
Please provide a description of the function:def _erase_buffer(self, output_buffer): erase_size = self._model.get(u'buffer_erase_size') buffer_type = u'storage' if output_buffer: buffer_type = u'streaming' old_readings = self._engine.popn(buffer_type, erase_size) ...
[ "Erase readings in the specified buffer to make space." ]
Please provide a description of the function:def inspect_last(self, stream, only_allocated=False): if only_allocated: found = False for walker in self._virtual_walkers: if walker.matches(stream): found = True break ...
[ "Return the last value pushed into a stream.\n\n This function works even if the stream is virtual and no\n virtual walker has been created for it. It is primarily\n useful to aid in debugging sensor graphs.\n\n Args:\n stream (DataStream): The stream to inspect.\n ...
Please provide a description of the function:def _run_exitfuncs(): while _exithandlers: func, targs, kargs = _exithandlers.pop() func(*targs, **kargs)
[ "run any registered exit functions\n\n _exithandlers is traversed in reverse order so functions are executed\n last in, first out.\n " ]
Please provide a description of the function:def generate(env): link.generate(env) if env['PLATFORM'] == 'hpux': env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared -fPIC') # __RPATH is set to $_RPATH in the platform specification if that # platform supports it. env['RPATHPREFIX...
[ "Add Builders and construction variables for gnulink to an Environment." ]
Please provide a description of the function:def _windowsLdmodTargets(target, source, env, for_signature): return _dllTargets(target, source, env, for_signature, 'LDMODULE')
[ "Get targets for loadable modules." ]
Please provide a description of the function:def _windowsLdmodSources(target, source, env, for_signature): return _dllSources(target, source, env, for_signature, 'LDMODULE')
[ "Get sources for loadable modules." ]
Please provide a description of the function:def _dllEmitter(target, source, env, paramtp): SCons.Tool.msvc.validate_vars(env) extratargets = [] extrasources = [] dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) no_import_lib = env.get('no_import_lib', 0) if not dll...
[ "Common implementation of dll emitter." ]
Please provide a description of the function:def embedManifestDllCheck(target, source, env): if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + '.manifest' if os.path.exists(manifestSrc): ret = (embedManifestDllAction) ([target[0]],None,env) ...
[ "Function run by embedManifestDllCheckAction to check for existence of manifest\n and other conditions, and embed the manifest by calling embedManifestDllAction if so." ]
Please provide a description of the function:def embedManifestExeCheck(target, source, env): if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + '.manifest' if os.path.exists(manifestSrc): ret = (embedManifestExeAction) ([target[0]],None,env) ...
[ "Function run by embedManifestExeCheckAction to check for existence of manifest\n and other conditions, and embed the manifest by calling embedManifestExeAction if so." ]
Please provide a description of the function:def generate(env): SCons.Tool.createSharedLibBuilder(env) SCons.Tool.createProgBuilder(env) env['SHLINK'] = '$LINK' env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS /dll') env['_SHLINK_TARGETS'] = windowsShlinkTargets env['_SHLINK_SOURCES'...
[ "Add Builders and construction variables for ar to an Environment." ]
Please provide a description of the function:def DviPsStrFunction(target = None, source= None, env=None): if env.GetOption("no_exec"): result = env.subst('$PSCOM',0,target,source) else: result = '' return result
[ "A strfunction for dvipdf that returns the appropriate\n command string for the no_exec options." ]
Please provide a description of the function:def generate(env): global PSAction if PSAction is None: PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') global DVIPSAction if DVIPSAction is None: DVIPSAction = SCons.Action.Action(DviPsFunction, strfunction = DviPsStrFunction) ...
[ "Add Builders and construction variables for dvips to an Environment." ]
Please provide a description of the function:def execute(self, sensor_graph, scope_stack): streamer = DataStreamer(self.selector, self.dest, self.report_format, self.auto, report_type=self.report_type, with_other=self.with_other) sensor_graph.add_streamer(streamer)
[ "Execute this statement on the sensor_graph given the current scope tree.\n\n This adds a single DataStreamer to the current sensor graph\n\n Args:\n sensor_graph (SensorGraph): The sensor graph that we are building or\n modifying\n scope_stack (list(Scope)): A sta...
Please provide a description of the function:def build_program(tile, elfname, chip, patch=True): dirs = chip.build_dirs() output_name = '%s_%s.elf' % (elfname, chip.arch_name(),) output_binname = '%s_%s.bin' % (elfname, chip.arch_name(),) patched_name = '%s_%s_patched.elf' % (elfname, chip.arch_n...
[ "\n Build an ARM cortex executable\n " ]
Please provide a description of the function:def build_library(tile, libname, chip): dirs = chip.build_dirs() output_name = '%s_%s.a' % (libname, chip.arch_name()) # Support both firmware/src and just src locations for source code if os.path.exists('firmware'): VariantDir(dirs['build'], ...
[ "Build a static ARM cortex library" ]
Please provide a description of the function:def setup_environment(chip, args_file=None): config = ConfigManager() # Make sure we never get MSVC settings for windows since that has the wrong command line flags for gcc if platform.system() == 'Windows': env = Environment(tools=['mingw'], ENV=o...
[ "Setup the SCons environment for compiling arm cortex code.\n\n This will return an env that has all of the correct settings and create a\n command line arguments file for GCC that contains all of the required\n flags. The use of a command line argument file passed with @./file_path is\n important since...
Please provide a description of the function:def compile_tilebus(files, env, outdir=None, header_only=False): if outdir is None: dirs = env["ARCH"].build_dirs() outdir = dirs['build'] cmdmap_c_path = os.path.join(outdir, 'command_map_c.c') cmdmap_h_path = os.path.join(outdir, 'command...
[ "Given a path to a *.cdb file, process it and generate c tables and/or headers containing the information." ]
Please provide a description of the function:def tb_c_file_creation(target, source, env): files = [str(x) for x in source] try: desc = TBDescriptor(files) except pyparsing.ParseException as e: raise BuildError("Could not parse tilebus file", parsing_exception=e) block = desc.get_...
[ "Compile tilebus file into a .h/.c pair for compilation into an ARM object" ]
Please provide a description of the function:def tb_h_file_creation(target, source, env): files = [str(x) for x in source] try: desc = TBDescriptor(files) except pyparsing.ParseException as e: raise BuildError("Could not parse tilebus file", parsing_exception=e) block = desc.get_...
[ "Compile tilebus file into only .h files corresponding to config variables for inclusion in a library" ]
Please provide a description of the function:def checksum_creation_action(target, source, env): # Important Notes: # There are apparently many ways to calculate a CRC-32 checksum, we use the following options # Initial seed value prepended to the input: 0xFFFFFFFF # Whether the input is fed into t...
[ "Create a linker command file for patching an application checksum into a firmware image" ]
Please provide a description of the function:def create_arg_file(target, source, env): output_name = str(target[0]) with open(output_name, "w") as outfile: for define in env.get('CPPDEFINES', []): outfile.write(define + '\n') include_folders = target[0].RDirs(tuple(env.get('C...
[ "Create an argument file containing -I and -D arguments to gcc.\n\n This file will be passed to gcc using @<path>.\n " ]
Please provide a description of the function:def merge_hex_executables(target, source, env): output_name = str(target[0]) hex_final = IntelHex() for image in source: file = str(image) root, ext = os.path.splitext(file) file_format = ext[1:] if file_format == 'elf': ...
[ "Combine all hex files into a singular executable file." ]
Please provide a description of the function:def ensure_image_is_hex(input_path): family = utilities.get_family('module_settings.json') target = family.platform_independent_target() build_dir = target.build_dirs()['build'] if platform.system() == 'Windows': env = Environment(tools=['mingw...
[ "Return a path to a hex version of a firmware image.\n\n If the input file is already in hex format then input_path\n is returned and nothing is done. If it is not in hex format\n then an SCons action is added to convert it to hex and the\n target output file path is returned.\n\n A cache is kept so...
Please provide a description of the function:def _dispatch_rpc(self, address, rpc_id, arg_payload): if self.emulator.is_tile_busy(address): self._track_change('device.rpc_busy_response', (address, rpc_id, arg_payload, None, None), formatter=format_rpc) raise BusyRPCResponse() ...
[ "Background work queue handler to dispatch RPCs." ]
Please provide a description of the function:def finish_async_rpc(self, address, rpc_id, response): try: self.emulator.finish_async_rpc(address, rpc_id, response) self._track_change('device.rpc_finished', (address, rpc_id, None, response, None), formatter=format_rpc) ex...
[ "Finish a previous asynchronous RPC.\n\n This method should be called by a peripheral tile that previously\n had an RPC called on it and chose to response asynchronously by\n raising ``AsynchronousRPCResponse`` in the RPC handler itself.\n\n The response passed to this function will be r...
Please provide a description of the function:def start(self, channel=None): super(EmulatedDevice, self).start(channel) self.emulator.start()
[ "Start this emulated device.\n\n This triggers the controller to call start on all peripheral tiles in\n the device to make sure they start after the controller does and then\n it waits on each one to make sure they have finished initializing\n before returning.\n\n Args:\n ...
Please provide a description of the function:def dump_state(self): state = {} state['tile_states'] = {} for address, tile in self._tiles.items(): state['tile_states'][address] = tile.dump_state() return state
[ "Dump the current state of this emulated object as a dictionary.\n\n Returns:\n dict: The current state of the object that could be passed to load_state.\n " ]
Please provide a description of the function:def rpc(self, address, rpc_id, *args, **kwargs): if isinstance(rpc_id, RPCDeclaration): arg_format = rpc_id.arg_format resp_format = rpc_id.resp_format rpc_id = rpc_id.rpc_id else: arg_format = kwargs....
[ "Immediately dispatch an RPC inside this EmulatedDevice.\n\n This function is meant to be used for testing purposes as well as by\n tiles inside a complex EmulatedDevice subclass that need to\n communicate with each other. It should only be called from the main\n virtual device thread w...
Please provide a description of the function:def call_rpc(self, address, rpc_id, payload=b""): return self.emulator.call_rpc_external(address, rpc_id, payload)
[ "Call an RPC by its address and ID.\n\n This will send the RPC to the background rpc dispatch thread and\n synchronously wait for the response.\n\n Args:\n address (int): The address of the mock tile this RPC is for\n rpc_id (int): The number of the RPC\n payloa...
Please provide a description of the function:def trace_sync(self, data, timeout=5.0): done = AwaitableResponse() self.trace(data, callback=done.set_result) return done.wait(timeout)
[ "Send tracing data and wait for it to finish.\n\n This awaitable coroutine wraps VirtualIOTileDevice.trace() and turns\n the callback into an awaitable object. The appropriate usage of this\n method is by calling it inside the event loop as:\n\n await device.trace_sync(data)\n\n ...
Please provide a description of the function:def stream_sync(self, report, timeout=120.0): done = AwaitableResponse() self.stream(report, callback=done.set_result) return done.wait(timeout)
[ "Send a report and wait for it to finish.\n\n This awaitable coroutine wraps VirtualIOTileDevice.stream() and turns\n the callback into an awaitable object. The appropriate usage of this\n method is by calling it inside the event loop as:\n\n await device.stream_sync(data)\n\n Ar...
Please provide a description of the function:def synchronize_task(self, func, *args, **kwargs): async def _runner(): return func(*args, **kwargs) return self.emulator.run_task_external(_runner())
[ "Run callable in the rpc thread and wait for it to finish.\n\n The callable ``func`` will be passed into the EmulationLoop and run\n there. This method will block until ``func`` is finished and\n return/raise whatever that callable returns/raises.\n\n This method is mainly useful for pe...
Please provide a description of the function:def restore_state(self, state): tile_states = state.get('tile_states', {}) for address, tile_state in tile_states.items(): address = int(address) tile = self._tiles.get(address) if tile is None: r...
[ "Restore the current state of this emulated device.\n\n Args:\n state (dict): A previously dumped state produced by dump_state.\n " ]
Please provide a description of the function:def load_metascenario(self, scenario_list): for scenario in scenario_list: name = scenario.get('name') if name is None: raise DataError("Scenario in scenario list is missing a name parameter", scenario=scenario) ...
[ "Load one or more scenarios from a list.\n\n Each entry in scenario_list should be a dict containing at least a\n name key and an optional tile key and args key. If tile is present\n and its value is not None, the scenario specified will be loaded into\n the given tile only. Otherwise ...
Please provide a description of the function:def generate(env): SCons.Tool.createStaticLibBuilder(env) # Set-up ms tools paths msvc_setup_env_once(env) env['AR'] = 'lib' env['ARFLAGS'] = SCons.Util.CLVar('/nologo') env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $...
[ "Add Builders and construction variables for lib to an Environment." ]
Please provide a description of the function:def call_rpc(self, rpc_id, payload=bytes()): # If we define the RPC locally, call that one. We use this for reporting # our status if super(ServiceDelegateTile, self).has_rpc(rpc_id): return super(ServiceDelegateTile, self).call...
[ "Call an RPC by its ID.\n\n Args:\n rpc_id (int): The number of the RPC\n payload (bytes): A byte string of payload parameters up to 20 bytes\n\n Returns:\n str: The response payload from the RPC\n " ]
Please provide a description of the function:def associated_stream(self): if not self.important: raise InternalError("You may only call autocopied_stream on when DataStream.important is True", stream=self) if self.stream_id >= DataStream.ImportantSystemStorageStart: st...
[ "Return the corresponding output or storage stream for an important system input.\n\n Certain system inputs are designed as important and automatically\n copied to output streams without requiring any manual interaction.\n\n This method returns the corresponding stream for an important system\n...
Please provide a description of the function:def FromString(cls, string_rep): rep = str(string_rep) parts = rep.split() if len(parts) > 3: raise ArgumentError("Too many whitespace separated parts of stream designator", input_string=string_rep) elif len(parts) == 3 ...
[ "Create a DataStream from a string representation.\n\n The format for stream designators when encoded as strings is:\n [system] (buffered|unbuffered|constant|input|count|output) <integer>\n\n Args:\n string_rep (str): The string representation to turn into a\n DataStre...
Please provide a description of the function:def FromEncoded(self, encoded): stream_type = (encoded >> 12) & 0b1111 stream_system = bool(encoded & (1 << 11)) stream_id = (encoded & ((1 << 11) - 1)) return DataStream(stream_type, stream_id, stream_system)
[ "Create a DataStream from an encoded 16-bit unsigned integer.\n\n Returns:\n DataStream: The decoded DataStream object\n " ]
Please provide a description of the function:def as_stream(self): if not self.singular: raise ArgumentError("Attempted to convert a non-singular selector to a data stream, it matches multiple", selector=self) return DataStream(self.match_type, self.match_id, self.match_spec == Dat...
[ "Convert this selector to a DataStream.\n\n This function will only work if this is a singular selector that\n matches exactly one DataStream.\n " ]
Please provide a description of the function:def FromStream(cls, stream): if stream.system: specifier = DataStreamSelector.MatchSystemOnly else: specifier = DataStreamSelector.MatchUserOnly return DataStreamSelector(stream.stream_type, stream.stream_id, specifi...
[ "Create a DataStreamSelector from a DataStream.\n\n Args:\n stream (DataStream): The data stream that we want to convert.\n " ]
Please provide a description of the function:def FromEncoded(cls, encoded): match_spec = encoded & ((1 << 11) | (1 << 15)) match_type = (encoded & (0b111 << 12)) >> 12 match_id = encoded & ((1 << 11) - 1) if match_spec not in cls.SpecifierEncodingMap: raise Argumen...
[ "Create a DataStreamSelector from an encoded 16-bit value.\n\n The binary value must be equivalent to what is produced by\n a call to self.encode() and will turn that value back into\n a a DataStreamSelector.\n\n Note that the following operation is a no-op:\n\n DataStreamSelector...
Please provide a description of the function:def FromString(cls, string_rep): rep = str(string_rep) rep = rep.replace(u'node', '') rep = rep.replace(u'nodes', '') if rep.startswith(u'all'): parts = rep.split() spec_string = u'' if len(par...
[ "Create a DataStreamSelector from a string.\n\n The format of the string should either be:\n\n all <type>\n OR\n <type> <id>\n\n Where type is [system] <stream type>, with <stream type>\n defined as in DataStream\n\n Args:\n rep (str): The string represent...
Please provide a description of the function:def matches(self, stream): if self.match_type != stream.stream_type: return False if self.match_id is not None: return self.match_id == stream.stream_id if self.match_spec == DataStreamSelector.MatchUserOnly: ...
[ "Check if this selector matches the given stream\n\n Args:\n stream (DataStream): The stream to check\n\n Returns:\n bool: True if this selector matches the stream\n " ]
Please provide a description of the function:def encode(self): match_id = self.match_id if match_id is None: match_id = (1 << 11) - 1 return (self.match_type << 12) | DataStreamSelector.SpecifierEncodings[self.match_spec] | match_id
[ "Encode this stream as a packed 16-bit unsigned integer.\n\n Returns:\n int: The packed encoded stream\n " ]
Please provide a description of the function:def EnumVariable(key, help, default, allowed_values, map={}, ignorecase=0): help = '%s (%s)' % (help, '|'.join(allowed_values)) # define validator if ignorecase >= 1: validator = lambda key, val, env: \ _validator(key, val.lower(...
[ "\n The input parameters describe an option with only certain values\n allowed. They are returned with an appropriate converter and\n validator appended. The result is usable for input to\n Variables.Add().\n\n 'key' and 'default' are the values to be passed on to Variables.Add().\n\n 'help' will ...
Please provide a description of the function:def generate(env): M4Action = SCons.Action.Action('$M4COM', '$M4COMSTR') bld = SCons.Builder.Builder(action = M4Action, src_suffix = '.m4') env['BUILDERS']['M4'] = bld # .m4 files might include other files, and it would be pretty hard # to write a ...
[ "Add Builders and construction variables for m4 to an Environment." ]
Please provide a description of the function:async def future_command(self, cmd): if self._asyncio_cmd_lock is None: raise HardwareError("Cannot use future_command because no event loop attached") async with self._asyncio_cmd_lock: return await self._future_command_unl...
[ "Run command as a coroutine and return a future.\n\n Args:\n loop (BackgroundEventLoop): The loop that we should attach\n the future too.\n cmd (list): The command and arguments that we wish to call.\n\n Returns:\n asyncio.Future: An awaitable future wit...
Please provide a description of the function:def _future_command_unlocked(self, cmd): future = self._loop.create_future() asyncio_loop = self._loop.get_loop() def _done_callback(result): retval = result['return_value'] if not result['result']: ...
[ "Run command as a coroutine and return a future.\n\n Args:\n loop (BackgroundEventLoop): The loop that we should attach\n the future too.\n cmd (list): The command and arguments that we wish to call.\n\n Returns:\n asyncio.Future: An awaitable future wit...