我正在尝试在 python 中编写代码来自动化我通常手动执行的工作。这项工作只是修改 C 代码的某些部分,然后将以下命令插入终端,为每个 Z1 Zolertia motes 构建、编译和引导加载 C 代码。
sudo scons board=z1 toolchain=mspgcc bootload=/dev/ttyUSB0 oos_openwsn
该命令在终端或 bash 脚本中运行良好,但是当我从 python 脚本运行它时,它无法正常运行。
我认为问题是:构建和编译阶段成功完成,但是引导加载阶段(Mass Erase)运行了两次,因此端口关闭并且再也看不到了。
这部分代码很麻烦:
subprocess.call('(cd /home/ilkin/git/Yadhunandana-testbed/openwsn-fw ; sudo scons board=z1 toolchain=mspgcc bootload=/dev/ttyUSB0 oos_openwsn)', shell=True)
这是构建、编译和引导加载阶段的输出。如您所见,“批量擦除”同时运行,因此它失败了。
sudo python automate.py
scons: Reading SConscript files ...
___ _ _ _ ___ _ _
| . | ___ ___ ._ _ | | | |/ __>| \ |
| | || . \/ ._>| ' || | | |\__ \| |
`___'| _/\___.|_|_||__/_/ <___/|_\_|
|_| openwsn.org
none
scons: done reading SConscript files.
scons: Building targets ...
Dynifying build/z1_mspgcc/openapps/openapps_dyn.c
msp430-size build/z1_mspgcc/projects/common/03oos_openwsn_prog
text data bss dec hex filename
51442 532 6598 58572 e4cc build/z1_mspgcc/projects/common/03oos_openwsn_prog
z1_bootload(["build/z1_mspgcc/projects/common/03oos_openwsn_prog.phonyupload"], ["build/z1_mspgcc/projects/common/03oos_openwsn_prog.ihex"])
starting bootloading on /dev/ttyUSB0
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Mass Erase...
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Mass Erase...
Traceback (most recent call last):
File "bootloader/z1/z1-bsl-nopic", line 1925, in <module>
main(0);
File "bootloader/z1/z1-bsl-nopic", line 1840, in main
for f in toinit: f()
File "bootloader/z1/z1-bsl-nopic", line 1102, in actionMassErase
0xa506) #Required setting for mass erase!
File "bootloader/z1/z1-bsl-nopic", line 761, in bslTxRx
self.bslSync(wait) #synchronize BSL
File "bootloader/z1/z1-bsl-nopic", line 720, in bslSync
raise BSLException(self.ERR_BSL_SYNC) #Sync. failed
__main__.BSLException: Bootstrap loader synchronization error
done bootloading on /dev/ttyUSB0
scons: done building targets.
当我从终端手动运行命令时,情况并非如此,“批量擦除”部分只运行一次并且引导加载成功完成。我期望这样的输出:
(cd /home/ilkin/git/Yadhunandana-testbed/openwsn-fw ; sudo scons board=z1 toolchain=mspgcc bootload=/dev/ttyUSB0 oos_openwsn)
scons: Reading SConscript files ...
___ _ _ _ ___ _ _
| . | ___ ___ ._ _ | | | |/ __>| \ |
| | || . \/ ._>| ' || | | |\__ \| |
`___'| _/\___.|_|_||__/_/ <___/|_\_|
|_| openwsn.org
none
scons: done reading SConscript files.
scons: Building targets ...
Dynifying build/z1_mspgcc/openapps/openapps_dyn.c
msp430-size build/z1_mspgcc/projects/common/03oos_openwsn_prog
text data bss dec hex filename
51442 532 6598 58572 e4cc build/z1_mspgcc/projects/common/03oos_openwsn_prog
z1_bootload(["build/z1_mspgcc/projects/common/03oos_openwsn_prog.phonyupload"], ["build/z1_mspgcc/projects/common/03oos_openwsn_prog.ihex"])
starting bootloading on /dev/ttyUSB0
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Mass Erase...
Transmit default password ...
Invoking BSL...
Transmit default password ...
Current bootstrap loader version: 2.13 (Device ID: f26f)
Changing baudrate to 38400 ...
Program ...
51974 bytes programmed.
Reset device ...
done bootloading on /dev/ttyUSB0
scons: done building targets.
先感谢您!