对于写好的 .h 格式文件,当用mig时如果显示在java内文件出现错误,未能生成...Msg.java 和...Msg.class文件,那么首先检查nesc和gcc版本问题,用指令ncc --version 来看nesc的版本问题,如果gcc版本时4.6,nesc版本是1.3.3以下,则就有个bug,mig生成器就不好用。
升级nesc版本就可以了,参考 http://hi.baidu.com/dream_go_on/item/b0b65c0f7d7114c42f4c6b61
如果直接安装新的nesc可能会出现冲突问题。我是用新立得可视化软件管理器升级nesc到1.3.4的。如果在新立得软件管理器中搜索未找到nesc,说明nesc有可能是包含在其他包中的,这时如果卸载包含的打包就有可能出现问题,这时候可以换一个源,找到含高版本的nesc,就行标记升级。
当然,还有其他方案解决mig失败的问题,但本人未作尝试。具体可参考以下:
-add option -target=iris (or telos or whatever mote you're using, it doesn't really matter, the generated code is the same) to the mig command to use avr-gcc or msp430-gcc instead of gcc. -update nesc to 1.3.3. (from here: http://tinyos.stanford.edu/tinyos/dists/ubuntu/pool/main/n/nesc/,