repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex._tobinarray_really
def _tobinarray_really(self, start, end, pad, size): """Return binary array.""" if pad is None: pad = self.padding bin = array('B') if self._buf == {} and None in (start, end): return bin if size is not None and size <= 0: raise ValueError("tob...
python
def _tobinarray_really(self, start, end, pad, size): """Return binary array.""" if pad is None: pad = self.padding bin = array('B') if self._buf == {} and None in (start, end): return bin if size is not None and size <= 0: raise ValueError("tob...
[ "def", "_tobinarray_really", "(", "self", ",", "start", ",", "end", ",", "pad", ",", "size", ")", ":", "if", "pad", "is", "None", ":", "pad", "=", "self", ".", "padding", "bin", "=", "array", "(", "'B'", ")", "if", "self", ".", "_buf", "==", "{",...
Return binary array.
[ "Return", "binary", "array", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L348-L360
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.tobinstr
def tobinstr(self, start=None, end=None, pad=_DEPRECATED, size=None): ''' Convert to binary form and return as binary string. @param start start address of output bytes. @param end end address of output bytes (inclusive). @param pad [DEPRECATED PARAMETER, please use self.pad...
python
def tobinstr(self, start=None, end=None, pad=_DEPRECATED, size=None): ''' Convert to binary form and return as binary string. @param start start address of output bytes. @param end end address of output bytes (inclusive). @param pad [DEPRECATED PARAMETER, please use self.pad...
[ "def", "tobinstr", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ",", "pad", "=", "_DEPRECATED", ",", "size", "=", "None", ")", ":", "if", "not", "isinstance", "(", "pad", ",", "_DeprecatedParam", ")", ":", "print", "(", "\"IntelHe...
Convert to binary form and return as binary string. @param start start address of output bytes. @param end end address of output bytes (inclusive). @param pad [DEPRECATED PARAMETER, please use self.padding instead] fill empty spaces with this value ...
[ "Convert", "to", "binary", "form", "and", "return", "as", "binary", "string", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L362-L381
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.tobinfile
def tobinfile(self, fobj, start=None, end=None, pad=_DEPRECATED, size=None): '''Convert to binary and write to file. @param fobj file name or file object for writing output bytes. @param start start address of output bytes. @param end end address of output bytes (inclusive)....
python
def tobinfile(self, fobj, start=None, end=None, pad=_DEPRECATED, size=None): '''Convert to binary and write to file. @param fobj file name or file object for writing output bytes. @param start start address of output bytes. @param end end address of output bytes (inclusive)....
[ "def", "tobinfile", "(", "self", ",", "fobj", ",", "start", "=", "None", ",", "end", "=", "None", ",", "pad", "=", "_DEPRECATED", ",", "size", "=", "None", ")", ":", "if", "not", "isinstance", "(", "pad", ",", "_DeprecatedParam", ")", ":", "print", ...
Convert to binary and write to file. @param fobj file name or file object for writing output bytes. @param start start address of output bytes. @param end end address of output bytes (inclusive). @param pad [DEPRECATED PARAMETER, please use self.padding instead] ...
[ "Convert", "to", "binary", "and", "write", "to", "file", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L386-L415
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.todict
def todict(self): '''Convert to python dictionary. @return dict suitable for initializing another IntelHex object. ''' r = {} r.update(self._buf) if self.start_addr: r['start_addr'] = self.start_addr return r
python
def todict(self): '''Convert to python dictionary. @return dict suitable for initializing another IntelHex object. ''' r = {} r.update(self._buf) if self.start_addr: r['start_addr'] = self.start_addr return r
[ "def", "todict", "(", "self", ")", ":", "r", "=", "{", "}", "r", ".", "update", "(", "self", ".", "_buf", ")", "if", "self", ".", "start_addr", ":", "r", "[", "'start_addr'", "]", "=", "self", ".", "start_addr", "return", "r" ]
Convert to python dictionary. @return dict suitable for initializing another IntelHex object.
[ "Convert", "to", "python", "dictionary", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L417-L426
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.tofile
def tofile(self, fobj, format): """Write data to hex or bin file. Preferred method over tobin or tohex. @param fobj file name or file-like object @param format file format ("hex" or "bin") """ if format == 'hex': self.write_hex_file(fobj) elif f...
python
def tofile(self, fobj, format): """Write data to hex or bin file. Preferred method over tobin or tohex. @param fobj file name or file-like object @param format file format ("hex" or "bin") """ if format == 'hex': self.write_hex_file(fobj) elif f...
[ "def", "tofile", "(", "self", ",", "fobj", ",", "format", ")", ":", "if", "format", "==", "'hex'", ":", "self", ".", "write_hex_file", "(", "fobj", ")", "elif", "format", "==", "'bin'", ":", "self", ".", "tobinfile", "(", "fobj", ")", "else", ":", ...
Write data to hex or bin file. Preferred method over tobin or tohex. @param fobj file name or file-like object @param format file format ("hex" or "bin")
[ "Write", "data", "to", "hex", "or", "bin", "file", ".", "Preferred", "method", "over", "tobin", "or", "tohex", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L720-L732
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.gets
def gets(self, addr, length): """Get string of bytes from given address. If any entries are blank from addr through addr+length, a NotEnoughDataError exception will be raised. Padding is not used. """ a = array('B', asbytes('\0'*length)) try: for i in range_g(...
python
def gets(self, addr, length): """Get string of bytes from given address. If any entries are blank from addr through addr+length, a NotEnoughDataError exception will be raised. Padding is not used. """ a = array('B', asbytes('\0'*length)) try: for i in range_g(...
[ "def", "gets", "(", "self", ",", "addr", ",", "length", ")", ":", "a", "=", "array", "(", "'B'", ",", "asbytes", "(", "'\\0'", "*", "length", ")", ")", "try", ":", "for", "i", "in", "range_g", "(", "length", ")", ":", "a", "[", "i", "]", "=",...
Get string of bytes from given address. If any entries are blank from addr through addr+length, a NotEnoughDataError exception will be raised. Padding is not used.
[ "Get", "string", "of", "bytes", "from", "given", "address", ".", "If", "any", "entries", "are", "blank", "from", "addr", "through", "addr", "+", "length", "a", "NotEnoughDataError", "exception", "will", "be", "raised", ".", "Padding", "is", "not", "used", ...
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L734-L745
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.puts
def puts(self, addr, s): """Put string of bytes at given address. Will overwrite any previous entries. """ a = array('B', asbytes(s)) for i in range_g(len(a)): self._buf[addr+i] = a[i]
python
def puts(self, addr, s): """Put string of bytes at given address. Will overwrite any previous entries. """ a = array('B', asbytes(s)) for i in range_g(len(a)): self._buf[addr+i] = a[i]
[ "def", "puts", "(", "self", ",", "addr", ",", "s", ")", ":", "a", "=", "array", "(", "'B'", ",", "asbytes", "(", "s", ")", ")", "for", "i", "in", "range_g", "(", "len", "(", "a", ")", ")", ":", "self", ".", "_buf", "[", "addr", "+", "i", ...
Put string of bytes at given address. Will overwrite any previous entries.
[ "Put", "string", "of", "bytes", "at", "given", "address", ".", "Will", "overwrite", "any", "previous", "entries", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L747-L753
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.getsz
def getsz(self, addr): """Get zero-terminated bytes string from given address. Will raise NotEnoughDataError exception if a hole is encountered before a 0. """ i = 0 try: while True: if self._buf[addr+i] == 0: break ...
python
def getsz(self, addr): """Get zero-terminated bytes string from given address. Will raise NotEnoughDataError exception if a hole is encountered before a 0. """ i = 0 try: while True: if self._buf[addr+i] == 0: break ...
[ "def", "getsz", "(", "self", ",", "addr", ")", ":", "i", "=", "0", "try", ":", "while", "True", ":", "if", "self", ".", "_buf", "[", "addr", "+", "i", "]", "==", "0", ":", "break", "i", "+=", "1", "except", "KeyError", ":", "raise", "NotEnoughD...
Get zero-terminated bytes string from given address. Will raise NotEnoughDataError exception if a hole is encountered before a 0.
[ "Get", "zero", "-", "terminated", "bytes", "string", "from", "given", "address", ".", "Will", "raise", "NotEnoughDataError", "exception", "if", "a", "hole", "is", "encountered", "before", "a", "0", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L755-L768
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.putsz
def putsz(self, addr, s): """Put bytes string in object at addr and append terminating zero at end.""" self.puts(addr, s) self._buf[addr+len(s)] = 0
python
def putsz(self, addr, s): """Put bytes string in object at addr and append terminating zero at end.""" self.puts(addr, s) self._buf[addr+len(s)] = 0
[ "def", "putsz", "(", "self", ",", "addr", ",", "s", ")", ":", "self", ".", "puts", "(", "addr", ",", "s", ")", "self", ".", "_buf", "[", "addr", "+", "len", "(", "s", ")", "]", "=", "0" ]
Put bytes string in object at addr and append terminating zero at end.
[ "Put", "bytes", "string", "in", "object", "at", "addr", "and", "append", "terminating", "zero", "at", "end", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L770-L773
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.dump
def dump(self, tofile=None, width=16, withpadding=False): """Dump object content to specified file object or to stdout if None. Format is a hexdump with some header information at the beginning, addresses on the left, and data on right. @param tofile file-like object to dump t...
python
def dump(self, tofile=None, width=16, withpadding=False): """Dump object content to specified file object or to stdout if None. Format is a hexdump with some header information at the beginning, addresses on the left, and data on right. @param tofile file-like object to dump t...
[ "def", "dump", "(", "self", ",", "tofile", "=", "None", ",", "width", "=", "16", ",", "withpadding", "=", "False", ")", ":", "if", "not", "isinstance", "(", "width", ",", "int", ")", "or", "width", "<", "1", ":", "raise", "ValueError", "(", "'width...
Dump object content to specified file object or to stdout if None. Format is a hexdump with some header information at the beginning, addresses on the left, and data on right. @param tofile file-like object to dump to @param width number of bytes per line (i.e. colu...
[ "Dump", "object", "content", "to", "specified", "file", "object", "or", "to", "stdout", "if", "None", ".", "Format", "is", "a", "hexdump", "with", "some", "header", "information", "at", "the", "beginning", "addresses", "on", "the", "left", "and", "data", "...
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L775-L834
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.segments
def segments(self): """Return a list of ordered tuple objects, representing contiguous occupied data addresses. Each tuple has a length of two and follows the semantics of the range and xrange objects. The second entry of the tuple is always an integer greater than the first entry. """ ...
python
def segments(self): """Return a list of ordered tuple objects, representing contiguous occupied data addresses. Each tuple has a length of two and follows the semantics of the range and xrange objects. The second entry of the tuple is always an integer greater than the first entry. """ ...
[ "def", "segments", "(", "self", ")", ":", "addresses", "=", "self", ".", "addresses", "(", ")", "if", "not", "addresses", ":", "return", "[", "]", "elif", "len", "(", "addresses", ")", "==", "1", ":", "return", "(", "[", "(", "addresses", "[", "0",...
Return a list of ordered tuple objects, representing contiguous occupied data addresses. Each tuple has a length of two and follows the semantics of the range and xrange objects. The second entry of the tuple is always an integer greater than the first entry.
[ "Return", "a", "list", "of", "ordered", "tuple", "objects", "representing", "contiguous", "occupied", "data", "addresses", ".", "Each", "tuple", "has", "a", "length", "of", "two", "and", "follows", "the", "semantics", "of", "the", "range", "and", "xrange", "...
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L884-L900
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.get_memory_size
def get_memory_size(self): """Returns the approximate memory footprint for data.""" n = sys.getsizeof(self) n += sys.getsizeof(self.padding) n += total_size(self.start_addr) n += total_size(self._buf) n += sys.getsizeof(self._offset) return n
python
def get_memory_size(self): """Returns the approximate memory footprint for data.""" n = sys.getsizeof(self) n += sys.getsizeof(self.padding) n += total_size(self.start_addr) n += total_size(self._buf) n += sys.getsizeof(self._offset) return n
[ "def", "get_memory_size", "(", "self", ")", ":", "n", "=", "sys", ".", "getsizeof", "(", "self", ")", "n", "+=", "sys", ".", "getsizeof", "(", "self", ".", "padding", ")", "n", "+=", "total_size", "(", "self", ".", "start_addr", ")", "n", "+=", "to...
Returns the approximate memory footprint for data.
[ "Returns", "the", "approximate", "memory", "footprint", "for", "data", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L902-L909
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
Record._from_bytes
def _from_bytes(bytes): """Takes a list of bytes, computes the checksum, and outputs the entire record as a string. bytes should be the hex record without the colon or final checksum. @param bytes list of byte values so far to pack into record. @return String represen...
python
def _from_bytes(bytes): """Takes a list of bytes, computes the checksum, and outputs the entire record as a string. bytes should be the hex record without the colon or final checksum. @param bytes list of byte values so far to pack into record. @return String represen...
[ "def", "_from_bytes", "(", "bytes", ")", ":", "assert", "len", "(", "bytes", ")", ">=", "4", "s", "=", "(", "-", "sum", "(", "bytes", ")", ")", "&", "0x0FF", "bin", "=", "array", "(", "'B'", ",", "bytes", "+", "[", "s", "]", ")", "return", "'...
Takes a list of bytes, computes the checksum, and outputs the entire record as a string. bytes should be the hex record without the colon or final checksum. @param bytes list of byte values so far to pack into record. @return String representation of one HEX record
[ "Takes", "a", "list", "of", "bytes", "computes", "the", "checksum", "and", "outputs", "the", "entire", "record", "as", "a", "string", ".", "bytes", "should", "be", "the", "hex", "record", "without", "the", "colon", "or", "final", "checksum", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L1130-L1142
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/release.py
create_release_settings_action
def create_release_settings_action(target, source, env): """Copy module_settings.json and add release and build information """ with open(str(source[0]), "r") as fileobj: settings = json.load(fileobj) settings['release'] = True settings['release_date'] = datetime.datetime.utcnow().isoforma...
python
def create_release_settings_action(target, source, env): """Copy module_settings.json and add release and build information """ with open(str(source[0]), "r") as fileobj: settings = json.load(fileobj) settings['release'] = True settings['release_date'] = datetime.datetime.utcnow().isoforma...
[ "def", "create_release_settings_action", "(", "target", ",", "source", ",", "env", ")", ":", "with", "open", "(", "str", "(", "source", "[", "0", "]", ")", ",", "\"r\"", ")", "as", "fileobj", ":", "settings", "=", "json", ".", "load", "(", "fileobj", ...
Copy module_settings.json and add release and build information
[ "Copy", "module_settings", ".", "json", "and", "add", "release", "and", "build", "information" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/release.py#L16-L34
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/release.py
copy_extra_files
def copy_extra_files(tile): """Copy all files listed in a copy_files and copy_products section. Files listed in copy_files will be copied from the specified location in the current component to the specified path under the output folder. Files listed in copy_products will be looked up with a Produ...
python
def copy_extra_files(tile): """Copy all files listed in a copy_files and copy_products section. Files listed in copy_files will be copied from the specified location in the current component to the specified path under the output folder. Files listed in copy_products will be looked up with a Produ...
[ "def", "copy_extra_files", "(", "tile", ")", ":", "env", "=", "Environment", "(", "tools", "=", "[", "]", ")", "outputbase", "=", "os", ".", "path", ".", "join", "(", "'build'", ",", "'output'", ")", "for", "src", ",", "dest", "in", "tile", ".", "s...
Copy all files listed in a copy_files and copy_products section. Files listed in copy_files will be copied from the specified location in the current component to the specified path under the output folder. Files listed in copy_products will be looked up with a ProductResolver and copied copied to...
[ "Copy", "all", "files", "listed", "in", "a", "copy_files", "and", "copy_products", "section", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/release.py#L99-L125
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/masm.py
generate
def generate(env): """Add Builders and construction variables for masm to an Environment.""" static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in ASSuffixes: static_obj.add_action(suffix, SCons.Defaults.ASAction) shared_obj.add_action(suffix, SCons.Defaults.ASAction) ...
python
def generate(env): """Add Builders and construction variables for masm to an Environment.""" static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in ASSuffixes: static_obj.add_action(suffix, SCons.Defaults.ASAction) shared_obj.add_action(suffix, SCons.Defaults.ASAction) ...
[ "def", "generate", "(", "env", ")", ":", "static_obj", ",", "shared_obj", "=", "SCons", ".", "Tool", ".", "createObjBuilders", "(", "env", ")", "for", "suffix", "in", "ASSuffixes", ":", "static_obj", ".", "add_action", "(", "suffix", ",", "SCons", ".", "...
Add Builders and construction variables for masm to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "masm", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/masm.py#L47-L68
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/bench.py
median
def median(values): """Return median value for the list of values. @param values: list of values for processing. @return: median value. """ values.sort() n = int(len(values) / 2) return values[n]
python
def median(values): """Return median value for the list of values. @param values: list of values for processing. @return: median value. """ values.sort() n = int(len(values) / 2) return values[n]
[ "def", "median", "(", "values", ")", ":", "values", ".", "sort", "(", ")", "n", "=", "int", "(", "len", "(", "values", ")", "/", "2", ")", "return", "values", "[", "n", "]" ]
Return median value for the list of values. @param values: list of values for processing. @return: median value.
[ "Return", "median", "value", "for", "the", "list", "of", "values", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/bench.py#L45-L52
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/bench.py
time_coef
def time_coef(tc, nc, tb, nb): """Return time coefficient relative to base numbers. @param tc: current test time @param nc: current test data size @param tb: base test time @param nb: base test data size @return: time coef. """ tc = float(tc) nc = float(nc)...
python
def time_coef(tc, nc, tb, nb): """Return time coefficient relative to base numbers. @param tc: current test time @param nc: current test data size @param tb: base test time @param nb: base test data size @return: time coef. """ tc = float(tc) nc = float(nc)...
[ "def", "time_coef", "(", "tc", ",", "nc", ",", "tb", ",", "nb", ")", ":", "tc", "=", "float", "(", "tc", ")", "nc", "=", "float", "(", "nc", ")", "tb", "=", "float", "(", "tb", ")", "nb", "=", "float", "(", "nb", ")", "q", "=", "(", "tc",...
Return time coefficient relative to base numbers. @param tc: current test time @param nc: current test data size @param tb: base test time @param nb: base test data size @return: time coef.
[ "Return", "time", "coefficient", "relative", "to", "base", "numbers", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/bench.py#L100-L113
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/bench.py
main
def main(argv=None): """Main function to run benchmarks. @param argv: command-line arguments. @return: exit code (0 is OK). """ import getopt # default values test_read = None test_write = None n = 3 # number of repeat if argv is None: argv = sys.argv[1:...
python
def main(argv=None): """Main function to run benchmarks. @param argv: command-line arguments. @return: exit code (0 is OK). """ import getopt # default values test_read = None test_write = None n = 3 # number of repeat if argv is None: argv = sys.argv[1:...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "import", "getopt", "test_read", "=", "None", "test_write", "=", "None", "n", "=", "3", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", "try", ":", "opts", ...
Main function to run benchmarks. @param argv: command-line arguments. @return: exit code (0 is OK).
[ "Main", "function", "to", "run", "benchmarks", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/bench.py#L240-L284
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/bench.py
Measure.measure_one
def measure_one(self, data): """Do measuring of read and write operations. @param data: 3-tuple from get_test_data @return: (time readhex, time writehex) """ _unused, hexstr, ih = data tread, twrite = 0.0, 0.0 if self.read: tread = run_readte...
python
def measure_one(self, data): """Do measuring of read and write operations. @param data: 3-tuple from get_test_data @return: (time readhex, time writehex) """ _unused, hexstr, ih = data tread, twrite = 0.0, 0.0 if self.read: tread = run_readte...
[ "def", "measure_one", "(", "self", ",", "data", ")", ":", "_unused", ",", "hexstr", ",", "ih", "=", "data", "tread", ",", "twrite", "=", "0.0", ",", "0.0", "if", "self", ".", "read", ":", "tread", "=", "run_readtest_N_times", "(", "intelhex", ".", "I...
Do measuring of read and write operations. @param data: 3-tuple from get_test_data @return: (time readhex, time writehex)
[ "Do", "measuring", "of", "read", "and", "write", "operations", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/bench.py#L174-L185
train
iotile/coretools
iotilecore/iotile/core/hw/auth/env_auth_provider.py
EnvAuthProvider._get_key
def _get_key(cls, device_id): """Attempt to get a user key from an environment variable """ var_name = "USER_KEY_{0:08X}".format(device_id) if var_name not in os.environ: raise NotFoundError("No user key could be found for devices", device_id=device_id, ...
python
def _get_key(cls, device_id): """Attempt to get a user key from an environment variable """ var_name = "USER_KEY_{0:08X}".format(device_id) if var_name not in os.environ: raise NotFoundError("No user key could be found for devices", device_id=device_id, ...
[ "def", "_get_key", "(", "cls", ",", "device_id", ")", ":", "var_name", "=", "\"USER_KEY_{0:08X}\"", ".", "format", "(", "device_id", ")", "if", "var_name", "not", "in", "os", ".", "environ", ":", "raise", "NotFoundError", "(", "\"No user key could be found for d...
Attempt to get a user key from an environment variable
[ "Attempt", "to", "get", "a", "user", "key", "from", "an", "environment", "variable" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/auth/env_auth_provider.py#L23-L48
train
iotile/coretools
iotilecore/iotile/core/hw/auth/env_auth_provider.py
EnvAuthProvider.decrypt_report
def decrypt_report(self, device_id, root, data, **kwargs): """Decrypt a buffer of report data on behalf of a device. Args: device_id (int): The id of the device that we should encrypt for root (int): The root key type that should be used to generate the report data (...
python
def decrypt_report(self, device_id, root, data, **kwargs): """Decrypt a buffer of report data on behalf of a device. Args: device_id (int): The id of the device that we should encrypt for root (int): The root key type that should be used to generate the report data (...
[ "def", "decrypt_report", "(", "self", ",", "device_id", ",", "root", ",", "data", ",", "**", "kwargs", ")", ":", "report_key", "=", "self", ".", "_verify_derive_key", "(", "device_id", ",", "root", ",", "**", "kwargs", ")", "try", ":", "from", "Crypto", ...
Decrypt a buffer of report data on behalf of a device. Args: device_id (int): The id of the device that we should encrypt for root (int): The root key type that should be used to generate the report data (bytearray): The data that we should decrypt **kwargs: Ther...
[ "Decrypt", "a", "buffer", "of", "report", "data", "on", "behalf", "of", "a", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/auth/env_auth_provider.py#L147-L186
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/utilities.py
join_path
def join_path(path): """If given a string, return it, otherwise combine a list into a string using os.path.join""" if isinstance(path, str): return path return os.path.join(*path)
python
def join_path(path): """If given a string, return it, otherwise combine a list into a string using os.path.join""" if isinstance(path, str): return path return os.path.join(*path)
[ "def", "join_path", "(", "path", ")", ":", "if", "isinstance", "(", "path", ",", "str", ")", ":", "return", "path", "return", "os", ".", "path", ".", "join", "(", "*", "path", ")" ]
If given a string, return it, otherwise combine a list into a string using os.path.join
[ "If", "given", "a", "string", "return", "it", "otherwise", "combine", "a", "list", "into", "a", "string", "using", "os", ".", "path", ".", "join" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/utilities.py#L49-L55
train
iotile/coretools
iotilebuild/iotile/build/config/site_scons/utilities.py
build_defines
def build_defines(defines): """Build a list of `-D` directives to pass to the compiler. This will drop any definitions whose value is None so that you can get rid of a define from another architecture by setting its value to null in the `module_settings.json`. """ return ['-D"%s=%s"' % (x, str...
python
def build_defines(defines): """Build a list of `-D` directives to pass to the compiler. This will drop any definitions whose value is None so that you can get rid of a define from another architecture by setting its value to null in the `module_settings.json`. """ return ['-D"%s=%s"' % (x, str...
[ "def", "build_defines", "(", "defines", ")", ":", "return", "[", "'-D\"%s=%s\"'", "%", "(", "x", ",", "str", "(", "y", ")", ")", "for", "x", ",", "y", "in", "defines", ".", "items", "(", ")", "if", "y", "is", "not", "None", "]" ]
Build a list of `-D` directives to pass to the compiler. This will drop any definitions whose value is None so that you can get rid of a define from another architecture by setting its value to null in the `module_settings.json`.
[ "Build", "a", "list", "of", "-", "D", "directives", "to", "pass", "to", "the", "compiler", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/utilities.py#L58-L66
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._open_interface
def _open_interface(self, conn_id, iface, callback): """Open an interface on this device Args: conn_id (int): the unique identifier for the connection iface (string): the interface name to open callback (callback): Callback to be called when this command finishes ...
python
def _open_interface(self, conn_id, iface, callback): """Open an interface on this device Args: conn_id (int): the unique identifier for the connection iface (string): the interface name to open callback (callback): Callback to be called when this command finishes ...
[ "def", "_open_interface", "(", "self", ",", "conn_id", ",", "iface", ",", "callback", ")", ":", "try", ":", "context", "=", "self", ".", "conns", ".", "get_context", "(", "conn_id", ")", "except", "ArgumentError", ":", "callback", "(", "conn_id", ",", "s...
Open an interface on this device Args: conn_id (int): the unique identifier for the connection iface (string): the interface name to open callback (callback): Callback to be called when this command finishes callback(conn_id, adapter_id, success, failure_reas...
[ "Open", "an", "interface", "on", "this", "device" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L259-L280
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter.stop_sync
def stop_sync(self): """Synchronously stop this adapter """ conn_ids = self.conns.get_connections() # If we have any open connections, try to close them here before shutting down for conn in list(conn_ids): try: self.disconnect_sync(conn) ...
python
def stop_sync(self): """Synchronously stop this adapter """ conn_ids = self.conns.get_connections() # If we have any open connections, try to close them here before shutting down for conn in list(conn_ids): try: self.disconnect_sync(conn) ...
[ "def", "stop_sync", "(", "self", ")", ":", "conn_ids", "=", "self", ".", "conns", ".", "get_connections", "(", ")", "for", "conn", "in", "list", "(", "conn_ids", ")", ":", "try", ":", "self", ".", "disconnect_sync", "(", "conn", ")", "except", "Hardwar...
Synchronously stop this adapter
[ "Synchronously", "stop", "this", "adapter" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L282-L296
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter.probe_async
def probe_async(self, callback): """Probe for visible devices connected to this DeviceAdapter. Args: callback (callable): A callback for when the probe operation has completed. callback should have signature callback(adapter_id, success, failure_reason) where: ...
python
def probe_async(self, callback): """Probe for visible devices connected to this DeviceAdapter. Args: callback (callable): A callback for when the probe operation has completed. callback should have signature callback(adapter_id, success, failure_reason) where: ...
[ "def", "probe_async", "(", "self", ",", "callback", ")", ":", "topics", "=", "MQTTTopicValidator", "(", "self", ".", "prefix", ")", "self", ".", "client", ".", "publish", "(", "topics", ".", "probe", ",", "{", "'type'", ":", "'command'", ",", "'operation...
Probe for visible devices connected to this DeviceAdapter. Args: callback (callable): A callback for when the probe operation has completed. callback should have signature callback(adapter_id, success, failure_reason) where: success: bool fail...
[ "Probe", "for", "visible", "devices", "connected", "to", "this", "DeviceAdapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L298-L310
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter.periodic_callback
def periodic_callback(self): """Periodically help maintain adapter internal state """ while True: try: action = self._deferred.get(False) action() except queue.Empty: break except Exception: self...
python
def periodic_callback(self): """Periodically help maintain adapter internal state """ while True: try: action = self._deferred.get(False) action() except queue.Empty: break except Exception: self...
[ "def", "periodic_callback", "(", "self", ")", ":", "while", "True", ":", "try", ":", "action", "=", "self", ".", "_deferred", ".", "get", "(", "False", ")", "action", "(", ")", "except", "queue", ".", "Empty", ":", "break", "except", "Exception", ":", ...
Periodically help maintain adapter internal state
[ "Periodically", "help", "maintain", "adapter", "internal", "state" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L312-L323
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._bind_topics
def _bind_topics(self, topics): """Subscribe to all the topics we need to communication with this device Args: topics (MQTTTopicValidator): The topic validator for this device that we are connecting to. """ # FIXME: Allow for these subscriptions to fail and ...
python
def _bind_topics(self, topics): """Subscribe to all the topics we need to communication with this device Args: topics (MQTTTopicValidator): The topic validator for this device that we are connecting to. """ # FIXME: Allow for these subscriptions to fail and ...
[ "def", "_bind_topics", "(", "self", ",", "topics", ")", ":", "self", ".", "client", ".", "subscribe", "(", "topics", ".", "status", ",", "self", ".", "_on_status_message", ")", "self", ".", "client", ".", "subscribe", "(", "topics", ".", "tracing", ",", ...
Subscribe to all the topics we need to communication with this device Args: topics (MQTTTopicValidator): The topic validator for this device that we are connecting to.
[ "Subscribe", "to", "all", "the", "topics", "we", "need", "to", "communication", "with", "this", "device" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L325-L339
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._unbind_topics
def _unbind_topics(self, topics): """Unsubscribe to all of the topics we needed for communication with device Args: topics (MQTTTopicValidator): The topic validator for this device that we have connected to. """ self.client.unsubscribe(topics.status) ...
python
def _unbind_topics(self, topics): """Unsubscribe to all of the topics we needed for communication with device Args: topics (MQTTTopicValidator): The topic validator for this device that we have connected to. """ self.client.unsubscribe(topics.status) ...
[ "def", "_unbind_topics", "(", "self", ",", "topics", ")", ":", "self", ".", "client", ".", "unsubscribe", "(", "topics", ".", "status", ")", "self", ".", "client", ".", "unsubscribe", "(", "topics", ".", "tracing", ")", "self", ".", "client", ".", "uns...
Unsubscribe to all of the topics we needed for communication with device Args: topics (MQTTTopicValidator): The topic validator for this device that we have connected to.
[ "Unsubscribe", "to", "all", "of", "the", "topics", "we", "needed", "for", "communication", "with", "device" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L341-L352
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._find_connection
def _find_connection(self, topic): """Attempt to find a connection id corresponding with a topic The device is found by assuming the topic ends in <slug>/[control|data]/channel Args: topic (string): The topic we received a message on Returns: int: The internal ...
python
def _find_connection(self, topic): """Attempt to find a connection id corresponding with a topic The device is found by assuming the topic ends in <slug>/[control|data]/channel Args: topic (string): The topic we received a message on Returns: int: The internal ...
[ "def", "_find_connection", "(", "self", ",", "topic", ")", ":", "parts", "=", "topic", ".", "split", "(", "'/'", ")", "if", "len", "(", "parts", ")", "<", "3", ":", "return", "None", "slug", "=", "parts", "[", "-", "3", "]", "return", "slug" ]
Attempt to find a connection id corresponding with a topic The device is found by assuming the topic ends in <slug>/[control|data]/channel Args: topic (string): The topic we received a message on Returns: int: The internal connect id (device slug) associated with this ...
[ "Attempt", "to", "find", "a", "connection", "id", "corresponding", "with", "a", "topic" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L364-L381
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._on_report
def _on_report(self, sequence, topic, message): """Process a report received from a device. Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ ...
python
def _on_report(self, sequence, topic, message): """Process a report received from a device. Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ ...
[ "def", "_on_report", "(", "self", ",", "sequence", ",", "topic", ",", "message", ")", ":", "try", ":", "conn_key", "=", "self", ".", "_find_connection", "(", "topic", ")", "conn_id", "=", "self", ".", "conns", ".", "get_connection_id", "(", "conn_key", "...
Process a report received from a device. Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself
[ "Process", "a", "report", "received", "from", "a", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L394-L421
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._on_trace
def _on_trace(self, sequence, topic, message): """Process a trace received from a device. Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ t...
python
def _on_trace(self, sequence, topic, message): """Process a trace received from a device. Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ t...
[ "def", "_on_trace", "(", "self", ",", "sequence", ",", "topic", ",", "message", ")", ":", "try", ":", "conn_key", "=", "self", ".", "_find_connection", "(", "topic", ")", "conn_id", "=", "self", ".", "conns", ".", "get_connection_id", "(", "conn_key", ")...
Process a trace received from a device. Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself
[ "Process", "a", "trace", "received", "from", "a", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L423-L443
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._on_status_message
def _on_status_message(self, sequence, topic, message): """Process a status message received Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ ...
python
def _on_status_message(self, sequence, topic, message): """Process a status message received Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ ...
[ "def", "_on_status_message", "(", "self", ",", "sequence", ",", "topic", ",", "message", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"Received message on (topic=%s): %s\"", "%", "(", "topic", ",", "message", ")", ")", "try", ":", "conn_key", "=", ...
Process a status message received Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself
[ "Process", "a", "status", "message", "received" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L445-L469
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py
AWSIOTDeviceAdapter._on_response_message
def _on_response_message(self, sequence, topic, message): """Process a response message received Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ ...
python
def _on_response_message(self, sequence, topic, message): """Process a response message received Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself """ ...
[ "def", "_on_response_message", "(", "self", ",", "sequence", ",", "topic", ",", "message", ")", ":", "try", ":", "conn_key", "=", "self", ".", "_find_connection", "(", "topic", ")", "context", "=", "self", ".", "conns", ".", "get_context", "(", "conn_key",...
Process a response message received Args: sequence (int): The sequence number of the packet received topic (string): The topic this message was received on message (dict): The message itself
[ "Process", "a", "response", "message", "received" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L471-L517
train
iotile/coretools
iotilesensorgraph/iotile/sg/scripts/iotile_sgcompile.py
write_output
def write_output(output, text=True, output_path=None): """Write binary or text output to a file or stdout.""" if output_path is None and text is False: print("ERROR: You must specify an output file using -o/--output for binary output formats") sys.exit(1) if output_path is not None: ...
python
def write_output(output, text=True, output_path=None): """Write binary or text output to a file or stdout.""" if output_path is None and text is False: print("ERROR: You must specify an output file using -o/--output for binary output formats") sys.exit(1) if output_path is not None: ...
[ "def", "write_output", "(", "output", ",", "text", "=", "True", ",", "output_path", "=", "None", ")", ":", "if", "output_path", "is", "None", "and", "text", "is", "False", ":", "print", "(", "\"ERROR: You must specify an output file using -o/--output for binary outp...
Write binary or text output to a file or stdout.
[ "Write", "binary", "or", "text", "output", "to", "a", "file", "or", "stdout", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/scripts/iotile_sgcompile.py#L23-L45
train
iotile/coretools
iotilesensorgraph/iotile/sg/scripts/iotile_sgcompile.py
main
def main(): """Main entry point for iotile-sgcompile.""" arg_parser = build_args() args = arg_parser.parse_args() model = DeviceModel() parser = SensorGraphFileParser() parser.parse_file(args.sensor_graph) if args.format == u'ast': write_output(parser.dump_tree(), True, args.outp...
python
def main(): """Main entry point for iotile-sgcompile.""" arg_parser = build_args() args = arg_parser.parse_args() model = DeviceModel() parser = SensorGraphFileParser() parser.parse_file(args.sensor_graph) if args.format == u'ast': write_output(parser.dump_tree(), True, args.outp...
[ "def", "main", "(", ")", ":", "arg_parser", "=", "build_args", "(", ")", "args", "=", "arg_parser", ".", "parse_args", "(", ")", "model", "=", "DeviceModel", "(", ")", "parser", "=", "SensorGraphFileParser", "(", ")", "parser", ".", "parse_file", "(", "a...
Main entry point for iotile-sgcompile.
[ "Main", "entry", "point", "for", "iotile", "-", "sgcompile", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/scripts/iotile_sgcompile.py#L48-L80
train
iotile/coretools
iotilecore/iotile/core/utilities/typedargs/__init__.py
load_external_components
def load_external_components(typesys): """Load all external types defined by iotile plugins. This allows plugins to register their own types for type annotations and allows all registered iotile components that have associated type libraries to add themselves to the global type system. """ # F...
python
def load_external_components(typesys): """Load all external types defined by iotile plugins. This allows plugins to register their own types for type annotations and allows all registered iotile components that have associated type libraries to add themselves to the global type system. """ # F...
[ "def", "load_external_components", "(", "typesys", ")", ":", "from", "iotile", ".", "core", ".", "dev", ".", "registry", "import", "ComponentRegistry", "reg", "=", "ComponentRegistry", "(", ")", "modules", "=", "reg", ".", "list_components", "(", ")", "typelib...
Load all external types defined by iotile plugins. This allows plugins to register their own types for type annotations and allows all registered iotile components that have associated type libraries to add themselves to the global type system.
[ "Load", "all", "external", "types", "defined", "by", "iotile", "plugins", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/typedargs/__init__.py#L10-L29
train
iotile/coretools
iotileship/iotile/ship/recipe_manager.py
RecipeManager.add_recipe_folder
def add_recipe_folder(self, recipe_folder, whitelist=None): """Add all recipes inside a folder to this RecipeManager with an optional whitelist. Args: recipe_folder (str): The path to the folder of recipes to add. whitelist (list): Only include files whose os.basename() matches ...
python
def add_recipe_folder(self, recipe_folder, whitelist=None): """Add all recipes inside a folder to this RecipeManager with an optional whitelist. Args: recipe_folder (str): The path to the folder of recipes to add. whitelist (list): Only include files whose os.basename() matches ...
[ "def", "add_recipe_folder", "(", "self", ",", "recipe_folder", ",", "whitelist", "=", "None", ")", ":", "if", "whitelist", "is", "not", "None", ":", "whitelist", "=", "set", "(", "whitelist", ")", "if", "recipe_folder", "==", "''", ":", "recipe_folder", "=...
Add all recipes inside a folder to this RecipeManager with an optional whitelist. Args: recipe_folder (str): The path to the folder of recipes to add. whitelist (list): Only include files whose os.basename() matches something on the whitelist
[ "Add", "all", "recipes", "inside", "a", "folder", "to", "this", "RecipeManager", "with", "an", "optional", "whitelist", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe_manager.py#L58-L85
train
iotile/coretools
iotileship/iotile/ship/recipe_manager.py
RecipeManager.add_recipe_actions
def add_recipe_actions(self, recipe_actions): """Add additional valid recipe actions to RecipeManager args: recipe_actions (list): List of tuples. First value of tuple is the classname, second value of tuple is RecipeAction Object """ for action_name, action...
python
def add_recipe_actions(self, recipe_actions): """Add additional valid recipe actions to RecipeManager args: recipe_actions (list): List of tuples. First value of tuple is the classname, second value of tuple is RecipeAction Object """ for action_name, action...
[ "def", "add_recipe_actions", "(", "self", ",", "recipe_actions", ")", ":", "for", "action_name", ",", "action", "in", "recipe_actions", ":", "self", ".", "_recipe_actions", "[", "action_name", "]", "=", "action" ]
Add additional valid recipe actions to RecipeManager args: recipe_actions (list): List of tuples. First value of tuple is the classname, second value of tuple is RecipeAction Object
[ "Add", "additional", "valid", "recipe", "actions", "to", "RecipeManager" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe_manager.py#L87-L96
train
iotile/coretools
iotileship/iotile/ship/recipe_manager.py
RecipeManager.get_recipe
def get_recipe(self, recipe_name): """Get a recipe by name. Args: recipe_name (str): The name of the recipe to fetch. Can be either the yaml file name or the name of the recipe. """ if recipe_name.endswith('.yaml'): recipe = self._recipes.get(Reci...
python
def get_recipe(self, recipe_name): """Get a recipe by name. Args: recipe_name (str): The name of the recipe to fetch. Can be either the yaml file name or the name of the recipe. """ if recipe_name.endswith('.yaml'): recipe = self._recipes.get(Reci...
[ "def", "get_recipe", "(", "self", ",", "recipe_name", ")", ":", "if", "recipe_name", ".", "endswith", "(", "'.yaml'", ")", ":", "recipe", "=", "self", ".", "_recipes", ".", "get", "(", "RecipeObject", ".", "FromFile", "(", "recipe_name", ",", "self", "."...
Get a recipe by name. Args: recipe_name (str): The name of the recipe to fetch. Can be either the yaml file name or the name of the recipe.
[ "Get", "a", "recipe", "by", "name", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe_manager.py#L98-L112
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/timeout.py
TimeoutInterval._check_time_backwards
def _check_time_backwards(self): """Make sure a clock reset didn't cause time to go backwards """ now = time.time() if now < self.start: self.start = now self.end = self.start + self.length
python
def _check_time_backwards(self): """Make sure a clock reset didn't cause time to go backwards """ now = time.time() if now < self.start: self.start = now self.end = self.start + self.length
[ "def", "_check_time_backwards", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "if", "now", "<", "self", ".", "start", ":", "self", ".", "start", "=", "now", "self", ".", "end", "=", "self", ".", "start", "+", "self", ".", "len...
Make sure a clock reset didn't cause time to go backwards
[ "Make", "sure", "a", "clock", "reset", "didn", "t", "cause", "time", "to", "go", "backwards" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/timeout.py#L27-L35
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/timeout.py
TimeoutInterval.expired
def expired(self): """Boolean property if this timeout has expired """ if self._expired_latch: return True self._check_time_backwards() if time.time() > self.end: self._expired_latch = True return True return False
python
def expired(self): """Boolean property if this timeout has expired """ if self._expired_latch: return True self._check_time_backwards() if time.time() > self.end: self._expired_latch = True return True return False
[ "def", "expired", "(", "self", ")", ":", "if", "self", ".", "_expired_latch", ":", "return", "True", "self", ".", "_check_time_backwards", "(", ")", "if", "time", ".", "time", "(", ")", ">", "self", ".", "end", ":", "self", ".", "_expired_latch", "=", ...
Boolean property if this timeout has expired
[ "Boolean", "property", "if", "this", "timeout", "has", "expired" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/timeout.py#L38-L50
train
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink_background.py
JLinkControlThread.command
def command(self, cmd_name, callback, *args): """Run an asynchronous command. Args: cmd_name (int): The unique code for the command to execute. callback (callable): The optional callback to run when the command finishes. The signature should be callback(cmd_name,...
python
def command(self, cmd_name, callback, *args): """Run an asynchronous command. Args: cmd_name (int): The unique code for the command to execute. callback (callable): The optional callback to run when the command finishes. The signature should be callback(cmd_name,...
[ "def", "command", "(", "self", ",", "cmd_name", ",", "callback", ",", "*", "args", ")", ":", "cmd", "=", "JLinkCommand", "(", "cmd_name", ",", "args", ",", "callback", ")", "self", ".", "_commands", ".", "put", "(", "cmd", ")" ]
Run an asynchronous command. Args: cmd_name (int): The unique code for the command to execute. callback (callable): The optional callback to run when the command finishes. The signature should be callback(cmd_name, result, exception) *args: Any arguments that...
[ "Run", "an", "asynchronous", "command", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink_background.py#L96-L106
train
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink_background.py
JLinkControlThread._send_rpc
def _send_rpc(self, device_info, control_info, address, rpc_id, payload, poll_interval, timeout): """Write and trigger an RPC.""" write_address, write_data = control_info.format_rpc(address, rpc_id, payload) self._jlink.memory_write32(write_address, write_data) self._trigger_rpc(device...
python
def _send_rpc(self, device_info, control_info, address, rpc_id, payload, poll_interval, timeout): """Write and trigger an RPC.""" write_address, write_data = control_info.format_rpc(address, rpc_id, payload) self._jlink.memory_write32(write_address, write_data) self._trigger_rpc(device...
[ "def", "_send_rpc", "(", "self", ",", "device_info", ",", "control_info", ",", "address", ",", "rpc_id", ",", "payload", ",", "poll_interval", ",", "timeout", ")", ":", "write_address", ",", "write_data", "=", "control_info", ".", "format_rpc", "(", "address",...
Write and trigger an RPC.
[ "Write", "and", "trigger", "an", "RPC", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink_background.py#L112-L140
train
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink_background.py
JLinkControlThread._send_script
def _send_script(self, device_info, control_info, script, progress_callback): """Send a script by repeatedly sending it as a bunch of RPCs. This function doesn't do anything special, it just sends a bunch of RPCs with each chunk of the script until it's finished. """ for i in r...
python
def _send_script(self, device_info, control_info, script, progress_callback): """Send a script by repeatedly sending it as a bunch of RPCs. This function doesn't do anything special, it just sends a bunch of RPCs with each chunk of the script until it's finished. """ for i in r...
[ "def", "_send_script", "(", "self", ",", "device_info", ",", "control_info", ",", "script", ",", "progress_callback", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "script", ")", ",", "20", ")", ":", "chunk", "=", "script", "[", "i"...
Send a script by repeatedly sending it as a bunch of RPCs. This function doesn't do anything special, it just sends a bunch of RPCs with each chunk of the script until it's finished.
[ "Send", "a", "script", "by", "repeatedly", "sending", "it", "as", "a", "bunch", "of", "RPCs", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink_background.py#L142-L153
train
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink_background.py
JLinkControlThread._trigger_rpc
def _trigger_rpc(self, device_info): """Trigger an RPC in a device specific way.""" method = device_info.rpc_trigger if isinstance(method, devices.RPCTriggerViaSWI): self._jlink.memory_write32(method.register, [1 << method.bit]) else: raise HardwareError("Unknown...
python
def _trigger_rpc(self, device_info): """Trigger an RPC in a device specific way.""" method = device_info.rpc_trigger if isinstance(method, devices.RPCTriggerViaSWI): self._jlink.memory_write32(method.register, [1 << method.bit]) else: raise HardwareError("Unknown...
[ "def", "_trigger_rpc", "(", "self", ",", "device_info", ")", ":", "method", "=", "device_info", ".", "rpc_trigger", "if", "isinstance", "(", "method", ",", "devices", ".", "RPCTriggerViaSWI", ")", ":", "self", ".", "_jlink", ".", "memory_write32", "(", "meth...
Trigger an RPC in a device specific way.
[ "Trigger", "an", "RPC", "in", "a", "device", "specific", "way", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink_background.py#L155-L162
train
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink_background.py
JLinkControlThread._find_control_structure
def _find_control_structure(self, start_address, search_length): """Find the control structure in RAM for this device. Returns: ControlStructure: The decoded contents of the shared memory control structure used for communication with this IOTile device. """ ...
python
def _find_control_structure(self, start_address, search_length): """Find the control structure in RAM for this device. Returns: ControlStructure: The decoded contents of the shared memory control structure used for communication with this IOTile device. """ ...
[ "def", "_find_control_structure", "(", "self", ",", "start_address", ",", "search_length", ")", ":", "words", "=", "self", ".", "_read_memory", "(", "start_address", ",", "search_length", ",", "chunk_size", "=", "4", ",", "join", "=", "False", ")", "found_offs...
Find the control structure in RAM for this device. Returns: ControlStructure: The decoded contents of the shared memory control structure used for communication with this IOTile device.
[ "Find", "the", "control", "structure", "in", "RAM", "for", "this", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink_background.py#L213-L247
train
iotile/coretools
transport_plugins/jlink/iotile_transport_jlink/jlink_background.py
JLinkControlThread._verify_control_structure
def _verify_control_structure(self, device_info, control_info=None): """Verify that a control structure is still valid or find one. Returns: ControlStructure: The verified or discovered control structure. """ if control_info is None: control_info = self._find_co...
python
def _verify_control_structure(self, device_info, control_info=None): """Verify that a control structure is still valid or find one. Returns: ControlStructure: The verified or discovered control structure. """ if control_info is None: control_info = self._find_co...
[ "def", "_verify_control_structure", "(", "self", ",", "device_info", ",", "control_info", "=", "None", ")", ":", "if", "control_info", "is", "None", ":", "control_info", "=", "self", ".", "_find_control_structure", "(", "device_info", ".", "ram_start", ",", "dev...
Verify that a control structure is still valid or find one. Returns: ControlStructure: The verified or discovered control structure.
[ "Verify", "that", "a", "control", "structure", "is", "still", "valid", "or", "find", "one", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/jlink/iotile_transport_jlink/jlink_background.py#L249-L260
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/trace.py
SimulationTrace.save
def save(self, out_path): """Save an ascii representation of this simulation trace. Args: out_path (str): The output path to save this simulation trace. """ out = { 'selectors': [str(x) for x in self.selectors], 'trace': [{'stream': str(DataStream.Fr...
python
def save(self, out_path): """Save an ascii representation of this simulation trace. Args: out_path (str): The output path to save this simulation trace. """ out = { 'selectors': [str(x) for x in self.selectors], 'trace': [{'stream': str(DataStream.Fr...
[ "def", "save", "(", "self", ",", "out_path", ")", ":", "out", "=", "{", "'selectors'", ":", "[", "str", "(", "x", ")", "for", "x", "in", "self", ".", "selectors", "]", ",", "'trace'", ":", "[", "{", "'stream'", ":", "str", "(", "DataStream", ".",...
Save an ascii representation of this simulation trace. Args: out_path (str): The output path to save this simulation trace.
[ "Save", "an", "ascii", "representation", "of", "this", "simulation", "trace", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/trace.py#L39-L52
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/trace.py
SimulationTrace.FromFile
def FromFile(cls, in_path): """Load a previously saved ascii representation of this simulation trace. Args: in_path (str): The path of the input file that we should load. Returns: SimulationTrace: The loaded trace object. """ with open(in_path, "rb") as...
python
def FromFile(cls, in_path): """Load a previously saved ascii representation of this simulation trace. Args: in_path (str): The path of the input file that we should load. Returns: SimulationTrace: The loaded trace object. """ with open(in_path, "rb") as...
[ "def", "FromFile", "(", "cls", ",", "in_path", ")", ":", "with", "open", "(", "in_path", ",", "\"rb\"", ")", "as", "infile", ":", "in_data", "=", "json", ".", "load", "(", "infile", ")", "if", "not", "(", "'trace'", ",", "'selectors'", ")", "in", "...
Load a previously saved ascii representation of this simulation trace. Args: in_path (str): The path of the input file that we should load. Returns: SimulationTrace: The loaded trace object.
[ "Load", "a", "previously", "saved", "ascii", "representation", "of", "this", "simulation", "trace", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/trace.py#L55-L74
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
_on_scan
def _on_scan(_loop, adapter, _adapter_id, info, expiration_time): """Callback when a new device is seen.""" info['validity_period'] = expiration_time adapter.notify_event_nowait(info.get('connection_string'), 'device_seen', info)
python
def _on_scan(_loop, adapter, _adapter_id, info, expiration_time): """Callback when a new device is seen.""" info['validity_period'] = expiration_time adapter.notify_event_nowait(info.get('connection_string'), 'device_seen', info)
[ "def", "_on_scan", "(", "_loop", ",", "adapter", ",", "_adapter_id", ",", "info", ",", "expiration_time", ")", ":", "info", "[", "'validity_period'", "]", "=", "expiration_time", "adapter", ".", "notify_event_nowait", "(", "info", ".", "get", "(", "'connection...
Callback when a new device is seen.
[ "Callback", "when", "a", "new", "device", "is", "seen", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L227-L231
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
_on_report
def _on_report(_loop, adapter, conn_id, report): """Callback when a report is received.""" conn_string = None if conn_id is not None: conn_string = adapter._get_property(conn_id, 'connection_string') if isinstance(report, BroadcastReport): adapter.notify_event_nowait(conn_string, 'broa...
python
def _on_report(_loop, adapter, conn_id, report): """Callback when a report is received.""" conn_string = None if conn_id is not None: conn_string = adapter._get_property(conn_id, 'connection_string') if isinstance(report, BroadcastReport): adapter.notify_event_nowait(conn_string, 'broa...
[ "def", "_on_report", "(", "_loop", ",", "adapter", ",", "conn_id", ",", "report", ")", ":", "conn_string", "=", "None", "if", "conn_id", "is", "not", "None", ":", "conn_string", "=", "adapter", ".", "_get_property", "(", "conn_id", ",", "'connection_string'"...
Callback when a report is received.
[ "Callback", "when", "a", "report", "is", "received", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L234-L246
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
_on_trace
def _on_trace(_loop, adapter, conn_id, trace): """Callback when tracing data is received.""" conn_string = adapter._get_property(conn_id, 'connection_string') if conn_string is None: adapter._logger.debug("Dropping trace data with unknown conn_id=%s", conn_id) return adapter.notify_eve...
python
def _on_trace(_loop, adapter, conn_id, trace): """Callback when tracing data is received.""" conn_string = adapter._get_property(conn_id, 'connection_string') if conn_string is None: adapter._logger.debug("Dropping trace data with unknown conn_id=%s", conn_id) return adapter.notify_eve...
[ "def", "_on_trace", "(", "_loop", ",", "adapter", ",", "conn_id", ",", "trace", ")", ":", "conn_string", "=", "adapter", ".", "_get_property", "(", "conn_id", ",", "'connection_string'", ")", "if", "conn_string", "is", "None", ":", "adapter", ".", "_logger",...
Callback when tracing data is received.
[ "Callback", "when", "tracing", "data", "is", "received", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L249-L257
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
_on_disconnect
def _on_disconnect(_loop, adapter, _adapter_id, conn_id): """Callback when a device disconnects unexpectedly.""" conn_string = adapter._get_property(conn_id, 'connection_string') if conn_string is None: adapter._logger.debug("Dropping disconnect notification with unknown conn_id=%s", conn_id) ...
python
def _on_disconnect(_loop, adapter, _adapter_id, conn_id): """Callback when a device disconnects unexpectedly.""" conn_string = adapter._get_property(conn_id, 'connection_string') if conn_string is None: adapter._logger.debug("Dropping disconnect notification with unknown conn_id=%s", conn_id) ...
[ "def", "_on_disconnect", "(", "_loop", ",", "adapter", ",", "_adapter_id", ",", "conn_id", ")", ":", "conn_string", "=", "adapter", ".", "_get_property", "(", "conn_id", ",", "'connection_string'", ")", "if", "conn_string", "is", "None", ":", "adapter", ".", ...
Callback when a device disconnects unexpectedly.
[ "Callback", "when", "a", "device", "disconnects", "unexpectedly", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L260-L270
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
_on_progress
def _on_progress(adapter, operation, conn_id, done, total): """Callback when progress is reported.""" conn_string = adapter._get_property(conn_id, 'connection_string') if conn_string is None: return adapter.notify_progress(conn_string, operation, done, total)
python
def _on_progress(adapter, operation, conn_id, done, total): """Callback when progress is reported.""" conn_string = adapter._get_property(conn_id, 'connection_string') if conn_string is None: return adapter.notify_progress(conn_string, operation, done, total)
[ "def", "_on_progress", "(", "adapter", ",", "operation", ",", "conn_id", ",", "done", ",", "total", ")", ":", "conn_string", "=", "adapter", ".", "_get_property", "(", "conn_id", ",", "'connection_string'", ")", "if", "conn_string", "is", "None", ":", "retur...
Callback when progress is reported.
[ "Callback", "when", "progress", "is", "reported", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L273-L280
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
AsynchronousModernWrapper.start
async def start(self): """Start the device adapter. See :meth:`AbstractDeviceAdapter.start`. """ self._loop.add_task(self._periodic_loop, name="periodic task for %s" % self._adapter.__class__.__name__, parent=self._task) self._adapter.add_callback('...
python
async def start(self): """Start the device adapter. See :meth:`AbstractDeviceAdapter.start`. """ self._loop.add_task(self._periodic_loop, name="periodic task for %s" % self._adapter.__class__.__name__, parent=self._task) self._adapter.add_callback('...
[ "async", "def", "start", "(", "self", ")", ":", "self", ".", "_loop", ".", "add_task", "(", "self", ".", "_periodic_loop", ",", "name", "=", "\"periodic task for %s\"", "%", "self", ".", "_adapter", ".", "__class__", ".", "__name__", ",", "parent", "=", ...
Start the device adapter. See :meth:`AbstractDeviceAdapter.start`.
[ "Start", "the", "device", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L74-L86
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
AsynchronousModernWrapper.stop
async def stop(self, _task=None): """Stop the device adapter. See :meth:`AbstractDeviceAdapter.stop`. """ self._logger.info("Stopping adapter wrapper") if self._task.stopped: return for task in self._task.subtasks: await task.stop() se...
python
async def stop(self, _task=None): """Stop the device adapter. See :meth:`AbstractDeviceAdapter.stop`. """ self._logger.info("Stopping adapter wrapper") if self._task.stopped: return for task in self._task.subtasks: await task.stop() se...
[ "async", "def", "stop", "(", "self", ",", "_task", "=", "None", ")", ":", "self", ".", "_logger", ".", "info", "(", "\"Stopping adapter wrapper\"", ")", "if", "self", ".", "_task", ".", "stopped", ":", "return", "for", "task", "in", "self", ".", "_task...
Stop the device adapter. See :meth:`AbstractDeviceAdapter.stop`.
[ "Stop", "the", "device", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L88-L103
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
AsynchronousModernWrapper.probe
async def probe(self): """Probe for devices connected to this adapter. See :meth:`AbstractDeviceAdapter.probe`. """ resp = await self._execute(self._adapter.probe_sync) _raise_error(None, 'probe', resp)
python
async def probe(self): """Probe for devices connected to this adapter. See :meth:`AbstractDeviceAdapter.probe`. """ resp = await self._execute(self._adapter.probe_sync) _raise_error(None, 'probe', resp)
[ "async", "def", "probe", "(", "self", ")", ":", "resp", "=", "await", "self", ".", "_execute", "(", "self", ".", "_adapter", ".", "probe_sync", ")", "_raise_error", "(", "None", ",", "'probe'", ",", "resp", ")" ]
Probe for devices connected to this adapter. See :meth:`AbstractDeviceAdapter.probe`.
[ "Probe", "for", "devices", "connected", "to", "this", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L173-L180
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py
AsynchronousModernWrapper.send_script
async def send_script(self, conn_id, data): """Send a a script to a device. See :meth:`AbstractDeviceAdapter.send_script`. """ progress_callback = functools.partial(_on_progress, self, 'script', conn_id) resp = await self._execute(self._adapter.send_script_sync, conn_id, data,...
python
async def send_script(self, conn_id, data): """Send a a script to a device. See :meth:`AbstractDeviceAdapter.send_script`. """ progress_callback = functools.partial(_on_progress, self, 'script', conn_id) resp = await self._execute(self._adapter.send_script_sync, conn_id, data,...
[ "async", "def", "send_script", "(", "self", ",", "conn_id", ",", "data", ")", ":", "progress_callback", "=", "functools", ".", "partial", "(", "_on_progress", ",", "self", ",", "'script'", ",", "conn_id", ")", "resp", "=", "await", "self", ".", "_execute",...
Send a a script to a device. See :meth:`AbstractDeviceAdapter.send_script`.
[ "Send", "a", "a", "script", "to", "a", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/async_wrapper.py#L210-L219
train
iotile/coretools
iotileship/iotile/ship/autobuild/ship_file.py
autobuild_shiparchive
def autobuild_shiparchive(src_file): """Create a ship file archive containing a yaml_file and its dependencies. If yaml_file depends on any build products as external files, it must be a jinja2 template that references the file using the find_product filter so that we can figure out where those build p...
python
def autobuild_shiparchive(src_file): """Create a ship file archive containing a yaml_file and its dependencies. If yaml_file depends on any build products as external files, it must be a jinja2 template that references the file using the find_product filter so that we can figure out where those build p...
[ "def", "autobuild_shiparchive", "(", "src_file", ")", ":", "if", "not", "src_file", ".", "endswith", "(", "'.tpl'", ")", ":", "raise", "BuildError", "(", "\"You must pass a .tpl file to autobuild_shiparchive\"", ",", "src_file", "=", "src_file", ")", "env", "=", "...
Create a ship file archive containing a yaml_file and its dependencies. If yaml_file depends on any build products as external files, it must be a jinja2 template that references the file using the find_product filter so that we can figure out where those build products are going and create the right d...
[ "Create", "a", "ship", "file", "archive", "containing", "a", "yaml_file", "and", "its", "dependencies", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/autobuild/ship_file.py#L15-L88
train
iotile/coretools
iotileship/iotile/ship/autobuild/ship_file.py
create_shipfile
def create_shipfile(target, source, env): """Create a .ship file with all dependencies.""" source_dir = os.path.dirname(str(source[0])) recipe_name = os.path.basename(str(source[0]))[:-5] resman = RecipeManager() resman.add_recipe_actions(env['CUSTOM_STEPS']) resman.add_recipe_folder(source_d...
python
def create_shipfile(target, source, env): """Create a .ship file with all dependencies.""" source_dir = os.path.dirname(str(source[0])) recipe_name = os.path.basename(str(source[0]))[:-5] resman = RecipeManager() resman.add_recipe_actions(env['CUSTOM_STEPS']) resman.add_recipe_folder(source_d...
[ "def", "create_shipfile", "(", "target", ",", "source", ",", "env", ")", ":", "source_dir", "=", "os", ".", "path", ".", "dirname", "(", "str", "(", "source", "[", "0", "]", ")", ")", "recipe_name", "=", "os", ".", "path", ".", "basename", "(", "st...
Create a .ship file with all dependencies.
[ "Create", "a", ".", "ship", "file", "with", "all", "dependencies", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/autobuild/ship_file.py#L113-L125
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/simulator.py
SensorGraphSimulator.record_trace
def record_trace(self, selectors=None): """Record a trace of readings produced by this simulator. This causes the property `self.trace` to be populated with a SimulationTrace object that contains all of the readings that are produced during the course of the simulation. Only readings ...
python
def record_trace(self, selectors=None): """Record a trace of readings produced by this simulator. This causes the property `self.trace` to be populated with a SimulationTrace object that contains all of the readings that are produced during the course of the simulation. Only readings ...
[ "def", "record_trace", "(", "self", ",", "selectors", "=", "None", ")", ":", "if", "selectors", "is", "None", ":", "selectors", "=", "[", "x", ".", "selector", "for", "x", "in", "self", ".", "sensor_graph", ".", "streamers", "]", "self", ".", "trace", ...
Record a trace of readings produced by this simulator. This causes the property `self.trace` to be populated with a SimulationTrace object that contains all of the readings that are produced during the course of the simulation. Only readings that respond to specific selectors are given...
[ "Record", "a", "trace", "of", "readings", "produced", "by", "this", "simulator", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/simulator.py#L56-L90
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/simulator.py
SensorGraphSimulator.step
def step(self, input_stream, value): """Step the sensor graph through one since input. The internal tick count is not advanced so this function may be called as many times as desired to input specific conditions without simulation time passing. Args: input_stream (D...
python
def step(self, input_stream, value): """Step the sensor graph through one since input. The internal tick count is not advanced so this function may be called as many times as desired to input specific conditions without simulation time passing. Args: input_stream (D...
[ "def", "step", "(", "self", ",", "input_stream", ",", "value", ")", ":", "reading", "=", "IOTileReading", "(", "input_stream", ".", "encode", "(", ")", ",", "self", ".", "tick_count", ",", "value", ")", "self", ".", "sensor_graph", ".", "process_input", ...
Step the sensor graph through one since input. The internal tick count is not advanced so this function may be called as many times as desired to input specific conditions without simulation time passing. Args: input_stream (DataStream): The input stream to push the ...
[ "Step", "the", "sensor", "graph", "through", "one", "since", "input", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/simulator.py#L95-L109
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/simulator.py
SensorGraphSimulator.run
def run(self, include_reset=True, accelerated=True): """Run this sensor graph until a stop condition is hit. Multiple calls to this function are useful only if there has been some change in the stop conditions that would cause the second call to not exit immediately. Args: ...
python
def run(self, include_reset=True, accelerated=True): """Run this sensor graph until a stop condition is hit. Multiple calls to this function are useful only if there has been some change in the stop conditions that would cause the second call to not exit immediately. Args: ...
[ "def", "run", "(", "self", ",", "include_reset", "=", "True", ",", "accelerated", "=", "True", ")", ":", "self", ".", "_start_tick", "=", "self", ".", "tick_count", "if", "self", ".", "_check_stop_conditions", "(", "self", ".", "sensor_graph", ")", ":", ...
Run this sensor graph until a stop condition is hit. Multiple calls to this function are useful only if there has been some change in the stop conditions that would cause the second call to not exit immediately. Args: include_reset (bool): Start the sensor graph run with ...
[ "Run", "this", "sensor", "graph", "until", "a", "stop", "condition", "is", "hit", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/simulator.py#L111-L183
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/simulator.py
SensorGraphSimulator._check_stop_conditions
def _check_stop_conditions(self, sensor_graph): """Check if any of our stop conditions are met. Args: sensor_graph (SensorGraph): The sensor graph we are currently simulating Returns: bool: True if we should stop the simulation """ for stop in self.stop...
python
def _check_stop_conditions(self, sensor_graph): """Check if any of our stop conditions are met. Args: sensor_graph (SensorGraph): The sensor graph we are currently simulating Returns: bool: True if we should stop the simulation """ for stop in self.stop...
[ "def", "_check_stop_conditions", "(", "self", ",", "sensor_graph", ")", ":", "for", "stop", "in", "self", ".", "stop_conditions", ":", "if", "stop", ".", "should_stop", "(", "self", ".", "tick_count", ",", "self", ".", "tick_count", "-", "self", ".", "_sta...
Check if any of our stop conditions are met. Args: sensor_graph (SensorGraph): The sensor graph we are currently simulating Returns: bool: True if we should stop the simulation
[ "Check", "if", "any", "of", "our", "stop", "conditions", "are", "met", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/simulator.py#L203-L217
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/simulator.py
SensorGraphSimulator.stimulus
def stimulus(self, stimulus): """Add a simulation stimulus at a given time. A stimulus is a specific input given to the graph at a specific time to a specific input stream. The format for specifying a stimulus is: [time: ][system ]input X = Y where X and Y are integers....
python
def stimulus(self, stimulus): """Add a simulation stimulus at a given time. A stimulus is a specific input given to the graph at a specific time to a specific input stream. The format for specifying a stimulus is: [time: ][system ]input X = Y where X and Y are integers....
[ "def", "stimulus", "(", "self", ",", "stimulus", ")", ":", "if", "not", "isinstance", "(", "stimulus", ",", "SimulationStimulus", ")", ":", "stimulus", "=", "SimulationStimulus", ".", "FromString", "(", "stimulus", ")", "self", ".", "stimuli", ".", "append",...
Add a simulation stimulus at a given time. A stimulus is a specific input given to the graph at a specific time to a specific input stream. The format for specifying a stimulus is: [time: ][system ]input X = Y where X and Y are integers. This will cause the simulator t...
[ "Add", "a", "simulation", "stimulus", "at", "a", "given", "time", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/simulator.py#L219-L250
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/simulator.py
SensorGraphSimulator.stop_condition
def stop_condition(self, condition): """Add a stop condition to this simulation. Stop conditions are specified as strings and parsed into the appropriate internal structures. Args: condition (str): a string description of the stop condition """ # Try to par...
python
def stop_condition(self, condition): """Add a stop condition to this simulation. Stop conditions are specified as strings and parsed into the appropriate internal structures. Args: condition (str): a string description of the stop condition """ # Try to par...
[ "def", "stop_condition", "(", "self", ",", "condition", ")", ":", "for", "cond_format", "in", "self", ".", "_known_conditions", ":", "try", ":", "cond", "=", "cond_format", ".", "FromString", "(", "condition", ")", "self", ".", "stop_conditions", ".", "appen...
Add a stop condition to this simulation. Stop conditions are specified as strings and parsed into the appropriate internal structures. Args: condition (str): a string description of the stop condition
[ "Add", "a", "stop", "condition", "to", "this", "simulation", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/simulator.py#L252-L272
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.dump
def dump(self): """Serialize the state of this subsystem into a dict. Returns: dict: The serialized state """ walker = self.dump_walker if walker is not None: walker = walker.dump() state = { 'storage': self.storage.dump(), ...
python
def dump(self): """Serialize the state of this subsystem into a dict. Returns: dict: The serialized state """ walker = self.dump_walker if walker is not None: walker = walker.dump() state = { 'storage': self.storage.dump(), ...
[ "def", "dump", "(", "self", ")", ":", "walker", "=", "self", ".", "dump_walker", "if", "walker", "is", "not", "None", ":", "walker", "=", "walker", ".", "dump", "(", ")", "state", "=", "{", "'storage'", ":", "self", ".", "storage", ".", "dump", "("...
Serialize the state of this subsystem into a dict. Returns: dict: The serialized state
[ "Serialize", "the", "state", "of", "this", "subsystem", "into", "a", "dict", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L36-L53
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.clear
def clear(self, timestamp): """Clear all data from the RSL. This pushes a single reading once we clear everything so that we keep track of the highest ID that we have allocated to date. This needs the current timestamp to be able to properly timestamp the cleared storage readin...
python
def clear(self, timestamp): """Clear all data from the RSL. This pushes a single reading once we clear everything so that we keep track of the highest ID that we have allocated to date. This needs the current timestamp to be able to properly timestamp the cleared storage readin...
[ "def", "clear", "(", "self", ",", "timestamp", ")", ":", "self", ".", "storage", ".", "clear", "(", ")", "self", ".", "push", "(", "streams", ".", "DATA_CLEARED", ",", "timestamp", ",", "1", ")" ]
Clear all data from the RSL. This pushes a single reading once we clear everything so that we keep track of the highest ID that we have allocated to date. This needs the current timestamp to be able to properly timestamp the cleared storage reading that it pushes. Args: ...
[ "Clear", "all", "data", "from", "the", "RSL", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L86-L102
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.push
def push(self, stream_id, timestamp, value): """Push a value to a stream. Args: stream_id (int): The stream we want to push to. timestamp (int): The raw timestamp of the value we want to store. value (int): The 32-bit integer value we want to push. ...
python
def push(self, stream_id, timestamp, value): """Push a value to a stream. Args: stream_id (int): The stream we want to push to. timestamp (int): The raw timestamp of the value we want to store. value (int): The 32-bit integer value we want to push. ...
[ "def", "push", "(", "self", ",", "stream_id", ",", "timestamp", ",", "value", ")", ":", "stream", "=", "DataStream", ".", "FromEncoded", "(", "stream_id", ")", "reading", "=", "IOTileReading", "(", "stream_id", ",", "timestamp", ",", "value", ")", "try", ...
Push a value to a stream. Args: stream_id (int): The stream we want to push to. timestamp (int): The raw timestamp of the value we want to store. value (int): The 32-bit integer value we want to push. Returns: int: Packed 32-bit error code...
[ "Push", "a", "value", "to", "a", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L142-L162
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.inspect_virtual
def inspect_virtual(self, stream_id): """Inspect the last value written into a virtual stream. Args: stream_id (int): The virtual stream was want to inspect. Returns: (int, int): An error code and the stream value. """ stream = DataStream.FromEncoded(st...
python
def inspect_virtual(self, stream_id): """Inspect the last value written into a virtual stream. Args: stream_id (int): The virtual stream was want to inspect. Returns: (int, int): An error code and the stream value. """ stream = DataStream.FromEncoded(st...
[ "def", "inspect_virtual", "(", "self", ",", "stream_id", ")", ":", "stream", "=", "DataStream", ".", "FromEncoded", "(", "stream_id", ")", "if", "stream", ".", "buffered", ":", "return", "[", "pack_error", "(", "ControllerSubsystem", ".", "SENSOR_LOG", ",", ...
Inspect the last value written into a virtual stream. Args: stream_id (int): The virtual stream was want to inspect. Returns: (int, int): An error code and the stream value.
[ "Inspect", "the", "last", "value", "written", "into", "a", "virtual", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L164-L185
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.dump_begin
def dump_begin(self, selector_id): """Start dumping a stream. Args: selector_id (int): The buffered stream we want to dump. Returns: (int, int, int): Error code, second error code, number of available readings """ if self.dump_walker is not None: ...
python
def dump_begin(self, selector_id): """Start dumping a stream. Args: selector_id (int): The buffered stream we want to dump. Returns: (int, int, int): Error code, second error code, number of available readings """ if self.dump_walker is not None: ...
[ "def", "dump_begin", "(", "self", ",", "selector_id", ")", ":", "if", "self", ".", "dump_walker", "is", "not", "None", ":", "self", ".", "storage", ".", "destroy_walker", "(", "self", ".", "dump_walker", ")", "selector", "=", "DataStreamSelector", ".", "Fr...
Start dumping a stream. Args: selector_id (int): The buffered stream we want to dump. Returns: (int, int, int): Error code, second error code, number of available readings
[ "Start", "dumping", "a", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L187-L203
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.dump_seek
def dump_seek(self, reading_id): """Seek the dump streamer to a given ID. Returns: (int, int, int): Two error codes and the count of remaining readings. The first error code covers the seeking process. The second error code covers the stream counting process (cannot...
python
def dump_seek(self, reading_id): """Seek the dump streamer to a given ID. Returns: (int, int, int): Two error codes and the count of remaining readings. The first error code covers the seeking process. The second error code covers the stream counting process (cannot...
[ "def", "dump_seek", "(", "self", ",", "reading_id", ")", ":", "if", "self", ".", "dump_walker", "is", "None", ":", "return", "(", "pack_error", "(", "ControllerSubsystem", ".", "SENSOR_LOG", ",", "SensorLogError", ".", "STREAM_WALKER_NOT_INITIALIZED", ")", ",", ...
Seek the dump streamer to a given ID. Returns: (int, int, int): Two error codes and the count of remaining readings. The first error code covers the seeking process. The second error code covers the stream counting process (cannot fail) The third item in the tup...
[ "Seek", "the", "dump", "streamer", "to", "a", "given", "ID", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L205-L230
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.dump_next
def dump_next(self): """Dump the next reading from the stream. Returns: IOTileReading: The next reading or None if there isn't one """ if self.dump_walker is None: return pack_error(ControllerSubsystem.SENSOR_LOG, SensorLogError.STREAM_WALKER_NOT_INITIALIZED) ...
python
def dump_next(self): """Dump the next reading from the stream. Returns: IOTileReading: The next reading or None if there isn't one """ if self.dump_walker is None: return pack_error(ControllerSubsystem.SENSOR_LOG, SensorLogError.STREAM_WALKER_NOT_INITIALIZED) ...
[ "def", "dump_next", "(", "self", ")", ":", "if", "self", ".", "dump_walker", "is", "None", ":", "return", "pack_error", "(", "ControllerSubsystem", ".", "SENSOR_LOG", ",", "SensorLogError", ".", "STREAM_WALKER_NOT_INITIALIZED", ")", "try", ":", "return", "self",...
Dump the next reading from the stream. Returns: IOTileReading: The next reading or None if there isn't one
[ "Dump", "the", "next", "reading", "from", "the", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L232-L245
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
SensorLogSubsystem.highest_stored_id
def highest_stored_id(self): """Scan through the stored readings and report the highest stored id. Returns: int: The highest stored id. """ shared = [0] def _keep_max(_i, reading): if reading.reading_id > shared[0]: shared[0] = reading.re...
python
def highest_stored_id(self): """Scan through the stored readings and report the highest stored id. Returns: int: The highest stored id. """ shared = [0] def _keep_max(_i, reading): if reading.reading_id > shared[0]: shared[0] = reading.re...
[ "def", "highest_stored_id", "(", "self", ")", ":", "shared", "=", "[", "0", "]", "def", "_keep_max", "(", "_i", ",", "reading", ")", ":", "if", "reading", ".", "reading_id", ">", "shared", "[", "0", "]", ":", "shared", "[", "0", "]", "=", "reading"...
Scan through the stored readings and report the highest stored id. Returns: int: The highest stored id.
[ "Scan", "through", "the", "stored", "readings", "and", "report", "the", "highest", "stored", "id", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L247-L262
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
RawSensorLogMixin.rsl_push_reading
def rsl_push_reading(self, value, stream_id): """Push a reading to the RSL directly.""" #FIXME: Fix this with timestamp from clock manager task err = self.sensor_log.push(stream_id, 0, value) return [err]
python
def rsl_push_reading(self, value, stream_id): """Push a reading to the RSL directly.""" #FIXME: Fix this with timestamp from clock manager task err = self.sensor_log.push(stream_id, 0, value) return [err]
[ "def", "rsl_push_reading", "(", "self", ",", "value", ",", "stream_id", ")", ":", "err", "=", "self", ".", "sensor_log", ".", "push", "(", "stream_id", ",", "0", ",", "value", ")", "return", "[", "err", "]" ]
Push a reading to the RSL directly.
[ "Push", "a", "reading", "to", "the", "RSL", "directly", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L286-L291
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
RawSensorLogMixin.rsl_push_many_readings
def rsl_push_many_readings(self, value, count, stream_id): """Push many copies of a reading to the RSL.""" #FIXME: Fix this with timestamp from clock manager task for i in range(1, count+1): err = self.sensor_log.push(stream_id, 0, value) if err != Error.NO_ERROR: ...
python
def rsl_push_many_readings(self, value, count, stream_id): """Push many copies of a reading to the RSL.""" #FIXME: Fix this with timestamp from clock manager task for i in range(1, count+1): err = self.sensor_log.push(stream_id, 0, value) if err != Error.NO_ERROR: ...
[ "def", "rsl_push_many_readings", "(", "self", ",", "value", ",", "count", ",", "stream_id", ")", ":", "for", "i", "in", "range", "(", "1", ",", "count", "+", "1", ")", ":", "err", "=", "self", ".", "sensor_log", ".", "push", "(", "stream_id", ",", ...
Push many copies of a reading to the RSL.
[ "Push", "many", "copies", "of", "a", "reading", "to", "the", "RSL", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L294-L304
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
RawSensorLogMixin.rsl_count_readings
def rsl_count_readings(self): """Count how many readings are stored in the RSL.""" storage, output = self.sensor_log.count() return [Error.NO_ERROR, storage, output]
python
def rsl_count_readings(self): """Count how many readings are stored in the RSL.""" storage, output = self.sensor_log.count() return [Error.NO_ERROR, storage, output]
[ "def", "rsl_count_readings", "(", "self", ")", ":", "storage", ",", "output", "=", "self", ".", "sensor_log", ".", "count", "(", ")", "return", "[", "Error", ".", "NO_ERROR", ",", "storage", ",", "output", "]" ]
Count how many readings are stored in the RSL.
[ "Count", "how", "many", "readings", "are", "stored", "in", "the", "RSL", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L307-L311
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
RawSensorLogMixin.rsl_dump_stream_begin
def rsl_dump_stream_begin(self, stream_id): """Begin dumping the contents of a stream.""" err, err2, count = self.sensor_log.dump_begin(stream_id) #FIXME: Fix this with the uptime of the clock manager task return [err, err2, count, 0]
python
def rsl_dump_stream_begin(self, stream_id): """Begin dumping the contents of a stream.""" err, err2, count = self.sensor_log.dump_begin(stream_id) #FIXME: Fix this with the uptime of the clock manager task return [err, err2, count, 0]
[ "def", "rsl_dump_stream_begin", "(", "self", ",", "stream_id", ")", ":", "err", ",", "err2", ",", "count", "=", "self", ".", "sensor_log", ".", "dump_begin", "(", "stream_id", ")", "return", "[", "err", ",", "err2", ",", "count", ",", "0", "]" ]
Begin dumping the contents of a stream.
[ "Begin", "dumping", "the", "contents", "of", "a", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L328-L334
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py
RawSensorLogMixin.rsl_dump_stream_next
def rsl_dump_stream_next(self, output_format): """Dump the next reading from the output stream.""" timestamp = 0 stream_id = 0 value = 0 reading_id = 0 error = Error.NO_ERROR reading = self.sensor_log.dump_next() if reading is not None: times...
python
def rsl_dump_stream_next(self, output_format): """Dump the next reading from the output stream.""" timestamp = 0 stream_id = 0 value = 0 reading_id = 0 error = Error.NO_ERROR reading = self.sensor_log.dump_next() if reading is not None: times...
[ "def", "rsl_dump_stream_next", "(", "self", ",", "output_format", ")", ":", "timestamp", "=", "0", "stream_id", "=", "0", "value", "=", "0", "reading_id", "=", "0", "error", "=", "Error", ".", "NO_ERROR", "reading", "=", "self", ".", "sensor_log", ".", "...
Dump the next reading from the output stream.
[ "Dump", "the", "next", "reading", "from", "the", "output", "stream", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_log.py#L343-L366
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
parse_size_name
def parse_size_name(type_name): """Calculate size and encoding from a type name. This method takes a C-style type string like uint8_t[10] and returns - the total size in bytes - the unit size of each member (if it's an array) - the scruct.{pack,unpack} format code for decoding the base type - w...
python
def parse_size_name(type_name): """Calculate size and encoding from a type name. This method takes a C-style type string like uint8_t[10] and returns - the total size in bytes - the unit size of each member (if it's an array) - the scruct.{pack,unpack} format code for decoding the base type - w...
[ "def", "parse_size_name", "(", "type_name", ")", ":", "if", "' '", "in", "type_name", ":", "raise", "ArgumentError", "(", "\"There should not be a space in config variable type specifier\"", ",", "specifier", "=", "type_name", ")", "variable", "=", "False", "count", "...
Calculate size and encoding from a type name. This method takes a C-style type string like uint8_t[10] and returns - the total size in bytes - the unit size of each member (if it's an array) - the scruct.{pack,unpack} format code for decoding the base type - whether it is an array.
[ "Calculate", "size", "and", "encoding", "from", "a", "type", "name", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L446-L479
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
ConfigDescriptor._validate_python_type
def _validate_python_type(self, python_type): """Validate the possible combinations of python_type and type_name.""" if python_type == 'bool': if self.variable: raise ArgumentError("You can only specify a bool python type on a scalar (non-array) type_name", type_name=self.ty...
python
def _validate_python_type(self, python_type): """Validate the possible combinations of python_type and type_name.""" if python_type == 'bool': if self.variable: raise ArgumentError("You can only specify a bool python type on a scalar (non-array) type_name", type_name=self.ty...
[ "def", "_validate_python_type", "(", "self", ",", "python_type", ")", ":", "if", "python_type", "==", "'bool'", ":", "if", "self", ".", "variable", ":", "raise", "ArgumentError", "(", "\"You can only specify a bool python type on a scalar (non-array) type_name\"", ",", ...
Validate the possible combinations of python_type and type_name.
[ "Validate", "the", "possible", "combinations", "of", "python_type", "and", "type_name", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L34-L50
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
ConfigDescriptor._convert_default_value
def _convert_default_value(self, default): """Convert the passed default value to binary. The default value (if passed) may be specified as either a `bytes` object or a python int or list of ints. If an int or list of ints is passed, it is converted to binary. Otherwise, the raw binar...
python
def _convert_default_value(self, default): """Convert the passed default value to binary. The default value (if passed) may be specified as either a `bytes` object or a python int or list of ints. If an int or list of ints is passed, it is converted to binary. Otherwise, the raw binar...
[ "def", "_convert_default_value", "(", "self", ",", "default", ")", ":", "if", "default", "is", "None", ":", "return", "None", "if", "isinstance", "(", "default", ",", "str", ")", ":", "if", "self", ".", "special_type", "==", "'string'", ":", "return", "d...
Convert the passed default value to binary. The default value (if passed) may be specified as either a `bytes` object or a python int or list of ints. If an int or list of ints is passed, it is converted to binary. Otherwise, the raw binary data is used. If you pass a bytes o...
[ "Convert", "the", "passed", "default", "value", "to", "binary", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L52-L86
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
ConfigDescriptor.clear
def clear(self): """Clear this config variable to its reset value.""" if self.default_value is None: self.current_value = bytearray() else: self.current_value = bytearray(self.default_value)
python
def clear(self): """Clear this config variable to its reset value.""" if self.default_value is None: self.current_value = bytearray() else: self.current_value = bytearray(self.default_value)
[ "def", "clear", "(", "self", ")", ":", "if", "self", ".", "default_value", "is", "None", ":", "self", ".", "current_value", "=", "bytearray", "(", ")", "else", ":", "self", ".", "current_value", "=", "bytearray", "(", "self", ".", "default_value", ")" ]
Clear this config variable to its reset value.
[ "Clear", "this", "config", "variable", "to", "its", "reset", "value", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L88-L94
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
ConfigDescriptor.update_value
def update_value(self, offset, value): """Update the binary value currently stored for this config value. Returns: int: An opaque error code that can be returned from a set_config rpc """ if offset + len(value) > self.total_size: return Error.INPUT_BUFFER_TOO_LO...
python
def update_value(self, offset, value): """Update the binary value currently stored for this config value. Returns: int: An opaque error code that can be returned from a set_config rpc """ if offset + len(value) > self.total_size: return Error.INPUT_BUFFER_TOO_LO...
[ "def", "update_value", "(", "self", ",", "offset", ",", "value", ")", ":", "if", "offset", "+", "len", "(", "value", ")", ">", "self", ".", "total_size", ":", "return", "Error", ".", "INPUT_BUFFER_TOO_LONG", "if", "len", "(", "self", ".", "current_value"...
Update the binary value currently stored for this config value. Returns: int: An opaque error code that can be returned from a set_config rpc
[ "Update", "the", "binary", "value", "currently", "stored", "for", "this", "config", "value", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L96-L112
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
ConfigDescriptor.latch
def latch(self): """Convert the current value inside this config descriptor to a python object. The conversion proceeds by mapping the given type name to a native python class and performing the conversion. You can override what python object is used as the destination class by passing...
python
def latch(self): """Convert the current value inside this config descriptor to a python object. The conversion proceeds by mapping the given type name to a native python class and performing the conversion. You can override what python object is used as the destination class by passing...
[ "def", "latch", "(", "self", ")", ":", "if", "len", "(", "self", ".", "current_value", ")", "==", "0", ":", "raise", "DataError", "(", "\"There was no data in a config variable during latching\"", ",", "name", "=", "self", ".", "name", ")", "remaining", "=", ...
Convert the current value inside this config descriptor to a python object. The conversion proceeds by mapping the given type name to a native python class and performing the conversion. You can override what python object is used as the destination class by passing a python_type param...
[ "Convert", "the", "current", "value", "inside", "this", "config", "descriptor", "to", "a", "python", "object", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L114-L172
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.declare_config_variable
def declare_config_variable(self, name, config_id, type_name, default=None, convert=None): #pylint:disable=too-many-arguments;These are all necessary with sane defaults. """Declare a config variable that this emulated tile accepts. The default value (if passed) may be specified as either a `bytes` ...
python
def declare_config_variable(self, name, config_id, type_name, default=None, convert=None): #pylint:disable=too-many-arguments;These are all necessary with sane defaults. """Declare a config variable that this emulated tile accepts. The default value (if passed) may be specified as either a `bytes` ...
[ "def", "declare_config_variable", "(", "self", ",", "name", ",", "config_id", ",", "type_name", ",", "default", "=", "None", ",", "convert", "=", "None", ")", ":", "config", "=", "ConfigDescriptor", "(", "config_id", ",", "type_name", ",", "default", ",", ...
Declare a config variable that this emulated tile accepts. The default value (if passed) may be specified as either a `bytes` object or a python int or list of ints. If an int or list of ints is passed, it is converted to binary. Otherwise, the raw binary data is used. Passin...
[ "Declare", "a", "config", "variable", "that", "this", "emulated", "tile", "accepts", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L230-L255
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.latch_config_variables
def latch_config_variables(self): """Latch the current value of all config variables as python objects. This function will capture the current value of all config variables at the time that this method is called. It must be called after start() has been called so that any default value...
python
def latch_config_variables(self): """Latch the current value of all config variables as python objects. This function will capture the current value of all config variables at the time that this method is called. It must be called after start() has been called so that any default value...
[ "def", "latch_config_variables", "(", "self", ")", ":", "return", "{", "desc", ".", "name", ":", "desc", ".", "latch", "(", ")", "for", "desc", "in", "self", ".", "_config_variables", ".", "values", "(", ")", "}" ]
Latch the current value of all config variables as python objects. This function will capture the current value of all config variables at the time that this method is called. It must be called after start() has been called so that any default values in the config variables have been p...
[ "Latch", "the", "current", "value", "of", "all", "config", "variables", "as", "python", "objects", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L268-L295
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.reset
async def reset(self): """Synchronously reset a tile. This method must be called from the emulation loop and will synchronously shut down all background tasks running this tile, clear it to reset state and then restart the initialization background task. """ await self....
python
async def reset(self): """Synchronously reset a tile. This method must be called from the emulation loop and will synchronously shut down all background tasks running this tile, clear it to reset state and then restart the initialization background task. """ await self....
[ "async", "def", "reset", "(", "self", ")", ":", "await", "self", ".", "_device", ".", "emulator", ".", "stop_tasks", "(", "self", ".", "address", ")", "self", ".", "_handle_reset", "(", ")", "self", ".", "_logger", ".", "info", "(", "\"Tile at address %d...
Synchronously reset a tile. This method must be called from the emulation loop and will synchronously shut down all background tasks running this tile, clear it to reset state and then restart the initialization background task.
[ "Synchronously", "reset", "a", "tile", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L359-L374
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.list_config_variables
def list_config_variables(self, offset): """List defined config variables up to 9 at a time.""" names = sorted(self._config_variables) names = names[offset:offset + 9] count = len(names) if len(names) < 9: names += [0]*(9 - count) return [count] + names
python
def list_config_variables(self, offset): """List defined config variables up to 9 at a time.""" names = sorted(self._config_variables) names = names[offset:offset + 9] count = len(names) if len(names) < 9: names += [0]*(9 - count) return [count] + names
[ "def", "list_config_variables", "(", "self", ",", "offset", ")", ":", "names", "=", "sorted", "(", "self", ".", "_config_variables", ")", "names", "=", "names", "[", "offset", ":", "offset", "+", "9", "]", "count", "=", "len", "(", "names", ")", "if", ...
List defined config variables up to 9 at a time.
[ "List", "defined", "config", "variables", "up", "to", "9", "at", "a", "time", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L383-L393
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.describe_config_variable
def describe_config_variable(self, config_id): """Describe the config variable by its id.""" config = self._config_variables.get(config_id) if config is None: return [Error.INVALID_ARRAY_KEY, 0, 0, 0, 0] packed_size = config.total_size packed_size |= int(config.vari...
python
def describe_config_variable(self, config_id): """Describe the config variable by its id.""" config = self._config_variables.get(config_id) if config is None: return [Error.INVALID_ARRAY_KEY, 0, 0, 0, 0] packed_size = config.total_size packed_size |= int(config.vari...
[ "def", "describe_config_variable", "(", "self", ",", "config_id", ")", ":", "config", "=", "self", ".", "_config_variables", ".", "get", "(", "config_id", ")", "if", "config", "is", "None", ":", "return", "[", "Error", ".", "INVALID_ARRAY_KEY", ",", "0", "...
Describe the config variable by its id.
[ "Describe", "the", "config", "variable", "by", "its", "id", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L396-L406
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.set_config_variable
def set_config_variable(self, config_id, offset, value): """Set a chunk of the current config value's value.""" if self.initialized.is_set(): return [Error.STATE_CHANGE_AT_INVALID_TIME] config = self._config_variables.get(config_id) if config is None: return [Er...
python
def set_config_variable(self, config_id, offset, value): """Set a chunk of the current config value's value.""" if self.initialized.is_set(): return [Error.STATE_CHANGE_AT_INVALID_TIME] config = self._config_variables.get(config_id) if config is None: return [Er...
[ "def", "set_config_variable", "(", "self", ",", "config_id", ",", "offset", ",", "value", ")", ":", "if", "self", ".", "initialized", ".", "is_set", "(", ")", ":", "return", "[", "Error", ".", "STATE_CHANGE_AT_INVALID_TIME", "]", "config", "=", "self", "."...
Set a chunk of the current config value's value.
[ "Set", "a", "chunk", "of", "the", "current", "config", "value", "s", "value", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L409-L420
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
EmulatedTile.get_config_variable
def get_config_variable(self, config_id, offset): """Get a chunk of a config variable's value.""" config = self._config_variables.get(config_id) if config is None: return [b""] return [bytes(config.current_value[offset:offset + 20])]
python
def get_config_variable(self, config_id, offset): """Get a chunk of a config variable's value.""" config = self._config_variables.get(config_id) if config is None: return [b""] return [bytes(config.current_value[offset:offset + 20])]
[ "def", "get_config_variable", "(", "self", ",", "config_id", ",", "offset", ")", ":", "config", "=", "self", ".", "_config_variables", ".", "get", "(", "config_id", ")", "if", "config", "is", "None", ":", "return", "[", "b\"\"", "]", "return", "[", "byte...
Get a chunk of a config variable's value.
[ "Get", "a", "chunk", "of", "a", "config", "variable", "s", "value", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L423-L430
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/legacy.py
DeviceAdapter.add_callback
def add_callback(self, name, func): """Add a callback when Device events happen Args: name (str): currently support 'on_scan' and 'on_disconnect' func (callable): the function that should be called """ if name not in self.callbacks: raise ValueError(...
python
def add_callback(self, name, func): """Add a callback when Device events happen Args: name (str): currently support 'on_scan' and 'on_disconnect' func (callable): the function that should be called """ if name not in self.callbacks: raise ValueError(...
[ "def", "add_callback", "(", "self", ",", "name", ",", "func", ")", ":", "if", "name", "not", "in", "self", ".", "callbacks", ":", "raise", "ValueError", "(", "\"Unknown callback name: %s\"", "%", "name", ")", "self", ".", "callbacks", "[", "name", "]", "...
Add a callback when Device events happen Args: name (str): currently support 'on_scan' and 'on_disconnect' func (callable): the function that should be called
[ "Add", "a", "callback", "when", "Device", "events", "happen" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/legacy.py#L120-L131
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/legacy.py
DeviceAdapter.connect_sync
def connect_sync(self, connection_id, connection_string): """Synchronously connect to a device Args: connection_id (int): A unique identifier that will refer to this connection connection_string (string): A DeviceAdapter specific string that can be used to connect to ...
python
def connect_sync(self, connection_id, connection_string): """Synchronously connect to a device Args: connection_id (int): A unique identifier that will refer to this connection connection_string (string): A DeviceAdapter specific string that can be used to connect to ...
[ "def", "connect_sync", "(", "self", ",", "connection_id", ",", "connection_string", ")", ":", "calldone", "=", "threading", ".", "Event", "(", ")", "results", "=", "{", "}", "def", "connect_done", "(", "callback_connid", ",", "callback_adapterid", ",", "callba...
Synchronously connect to a device Args: connection_id (int): A unique identifier that will refer to this connection connection_string (string): A DeviceAdapter specific string that can be used to connect to a device using this DeviceAdapter. Returns: ...
[ "Synchronously", "connect", "to", "a", "device" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/legacy.py#L151-L176
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/legacy.py
DeviceAdapter.disconnect_sync
def disconnect_sync(self, conn_id): """Synchronously disconnect from a connected device Args: conn_id (int): A unique identifier that will refer to this connection Returns: dict: A dictionary with two elements 'success': a bool with the result of the con...
python
def disconnect_sync(self, conn_id): """Synchronously disconnect from a connected device Args: conn_id (int): A unique identifier that will refer to this connection Returns: dict: A dictionary with two elements 'success': a bool with the result of the con...
[ "def", "disconnect_sync", "(", "self", ",", "conn_id", ")", ":", "done", "=", "threading", ".", "Event", "(", ")", "result", "=", "{", "}", "def", "disconnect_done", "(", "conn_id", ",", "adapter_id", ",", "status", ",", "reason", ")", ":", "result", "...
Synchronously disconnect from a connected device Args: conn_id (int): A unique identifier that will refer to this connection Returns: dict: A dictionary with two elements 'success': a bool with the result of the connection attempt 'failure_reason...
[ "Synchronously", "disconnect", "from", "a", "connected", "device" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/legacy.py#L189-L212
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/legacy.py
DeviceAdapter.probe_sync
def probe_sync(self): """Synchronously probe for devices on this adapter.""" done = threading.Event() result = {} def probe_done(adapter_id, status, reason): result['success'] = status result['failure_reason'] = reason done.set() self.probe_...
python
def probe_sync(self): """Synchronously probe for devices on this adapter.""" done = threading.Event() result = {} def probe_done(adapter_id, status, reason): result['success'] = status result['failure_reason'] = reason done.set() self.probe_...
[ "def", "probe_sync", "(", "self", ")", ":", "done", "=", "threading", ".", "Event", "(", ")", "result", "=", "{", "}", "def", "probe_done", "(", "adapter_id", ",", "status", ",", "reason", ")", ":", "result", "[", "'success'", "]", "=", "status", "re...
Synchronously probe for devices on this adapter.
[ "Synchronously", "probe", "for", "devices", "on", "this", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/legacy.py#L288-L302
train
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/legacy.py
DeviceAdapter.send_rpc_sync
def send_rpc_sync(self, conn_id, address, rpc_id, payload, timeout): """Synchronously send an RPC to this IOTile device Args: conn_id (int): A unique identifier that will refer to this connection address (int): the address of the tile that we wish to send the RPC to ...
python
def send_rpc_sync(self, conn_id, address, rpc_id, payload, timeout): """Synchronously send an RPC to this IOTile device Args: conn_id (int): A unique identifier that will refer to this connection address (int): the address of the tile that we wish to send the RPC to ...
[ "def", "send_rpc_sync", "(", "self", ",", "conn_id", ",", "address", ",", "rpc_id", ",", "payload", ",", "timeout", ")", ":", "done", "=", "threading", ".", "Event", "(", ")", "result", "=", "{", "}", "def", "send_rpc_done", "(", "conn_id", ",", "adapt...
Synchronously send an RPC to this IOTile device Args: conn_id (int): A unique identifier that will refer to this connection address (int): the address of the tile that we wish to send the RPC to rpc_id (int): the 16-bit id of the RPC we want to call payload (byte...
[ "Synchronously", "send", "an", "RPC", "to", "this", "IOTile", "device" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/legacy.py#L325-L357
train
iotile/coretools
iotilecore/iotile/core/hw/auth/auth_provider.py
AuthProvider.FindByName
def FindByName(cls, name): """Find a specific installed auth provider by name.""" reg = ComponentRegistry() for _, entry in reg.load_extensions('iotile.auth_provider', name_filter=name): return entry
python
def FindByName(cls, name): """Find a specific installed auth provider by name.""" reg = ComponentRegistry() for _, entry in reg.load_extensions('iotile.auth_provider', name_filter=name): return entry
[ "def", "FindByName", "(", "cls", ",", "name", ")", ":", "reg", "=", "ComponentRegistry", "(", ")", "for", "_", ",", "entry", "in", "reg", ".", "load_extensions", "(", "'iotile.auth_provider'", ",", "name_filter", "=", "name", ")", ":", "return", "entry" ]
Find a specific installed auth provider by name.
[ "Find", "a", "specific", "installed", "auth", "provider", "by", "name", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/auth/auth_provider.py#L51-L56
train