You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromiotile.core.hw.virtualimportSimpleVirtualDevice, rpcclassDemoVirtualDevice(SimpleVirtualDevice):
def__init__(self, args):
super(DemoVirtualDevice, self).__init__(1, 'Demo01')
self.temp=273@rpc(8, 0x8002, "L")defset_temperature(self, new_temp):
"""Set the current temperature of the device in degrees kelvin"""self.temp=new_tempreturn []
When "resp_format" keyword argument for "rpc" is not specified it returns not changed value returned by decorated method or "[]" if returned value is None. But should return bytes according to its docstring description
....
Similarly, the function being decorated should return an iterable of results that
will be encoded into a 20 byte response buffer by struct.pack using resp_format as
the format string.
It causes an error.
Here is traceback I got when executed the example code from the tutorial
(coretools) dvk@sirin-dvk:~/test/test_component$ iotile hw --port=virtual:./demo_device.py connect 1 controller set_temperature 10
Traceback (most recent call last):
File "/home/dvk/projects/coretools/iotilecore/iotile/core/scripts/iotile_script.py", line 206, in main
finished = shell.invoke(line)
File "/home/dvk/.virtualenvs/coretools/lib/python3.6/site-packages/typedargs/shell.py", line 489, in invoke
val, line, finished = self.invoke_one(line)
File "/home/dvk/.virtualenvs/coretools/lib/python3.6/site-packages/typedargs/shell.py", line 452, in invoke_one
val = func(*posargs, **kwargs)
File "</home/dvk/.virtualenvs/coretools/lib/python3.6/site-packages/decorator.py:decorator-gen-41>", line 2, in set_temperature
File "/home/dvk/.virtualenvs/coretools/lib/python3.6/site-packages/typedargs/utils.py", line 32, in _check_and_execute
retval = func(*convargs, **convkw)
File "/home/dvk/test/test_component/python/demo_proxy.py", line 31, in set_temperature
self.rpc_v2(0x8002, "L", "", new_temp)
File "/home/dvk/projects/coretools/iotilecore/iotile/core/hw/proxy/proxy.py", line 99, in rpc_v2
return unpack_rpc_payload(result_format, payload)
File "/home/dvk/projects/coretools/iotilecore/iotile/core/hw/virtual/common_types.py", line 140, in unpack_rpc_payload
return struct.unpack(code, payload)
TypeError: a bytes-like object is required, not 'list'
The text was updated successfully, but these errors were encountered:
It's possible to write a quick test here by directly invoking the wrapped rpc on a virtual device class using simple_rpc (which didn't exist at the time of the original tutorial):
Here is truncated example from tutorial:
When "resp_format" keyword argument for "rpc" is not specified it returns not changed value returned by decorated method or "[]" if returned value is None. But should return bytes according to its docstring description
It causes an error.
Here is traceback I got when executed the example code from the tutorial
The text was updated successfully, but these errors were encountered: