def build(name, ask=True, **kwargs):
"""
Build the malicious mote to its target hardware.
:param name: experiment name (or absolute path to experiment)
:param ask: ask confirmation
:param path: expanded path of the experiment (dynamically filled in through 'command' decorator with 'expand')
:param kwargs: simulation keyword arguments (see the documentation for more information)
"""
def is_device_present():
with settings(hide(*HIDDEN_ALL), warn_only=True):
return local("if [ -c /dev/ttyUSB0 ]; then echo 'ok'; else echo 'nok'; fi", capture=True) == 'ok'
console = kwargs.get('console')
counter, interval = 0.0, 0.5
while not is_device_present():
sleep(interval)
counter += interval
if counter % 5 == 0:
logger.warning("Waiting for mote to be detected...")
elif counter >= 120:
logger.error("Something failed with the mote ; check that it mounts to /dev/ttyUSB0")
return
remake(name, build=True, **kwargs) if console is None else console.do_remake(name, build=True, **kwargs)
return "Mote built on /dev/ttyUSB0"
评论列表
文章目录