1

我在 Contiki 上的 Cooja 模拟器中运行代码,我收到以下错误消息:

执行 MSP430X 指令但 MCU 不是 MSP430X

我想广播一个名为ReqMsg. 该structure.h文件已定义如下:

   typedef struct {

    int id ;

    int t1 ;

    int t2 ;

    char op[4];

    char E[2][2][4];

    char S[2][2][4];

    char type[20];

}EventPattern; 

typedef struct {

    int id;

    EventPattern epin;

    EventPattern epout;

    EventPattern epresolved;

    int remainEnergy;

}ReqMsg;

我给的值ReqMsg r如下:

    EventPattern ep1 = {1, 1, 20,{{"a"} , {"b"}} ,{"seq"},{{"seq","a"},{"seq", "b"}}, "re"};
    EventPattern ep2 = {2, 1, 20,{{"a"} , {"b"}} ,{"seq"},{{"seq","a"},{"seq", "b"}}, "re"};
    EventPattern ep3 = {3, 1, 20,{{"a"} , {"b"}} ,{"seq"},{{"seq","a"},{"seq", "b"}}, "re"};
    ReqMsg r = {1, ep1, ep2, ep3, 5};

为了广播 ReqMsg,我使用了 packetbuffer,如下所示:

    const ReqMsg *req = &r;
    const void *reqAdd = &req;
    packetbuf_copyfrom(reqAdd, 6);
    broadcast_send(&broadcast);

我将宏中的buflen参数更改为packetbuf_copyfrom8、10、255 和 3512。所有值都相同的错误消息。模拟中的 Contiki 错误日志为:

    Executing MSP430X instruction but MCU is not a MSP430X
    Stack Trace: number of calls: 2 PC: $00002
    InterruptVectors (memset.c) called from PC: $062ca (elapsed: 5)
    rtimer_run_next (memset.c) called from PC: $05b38 (elapsed: 24)
    *** Interrupt 6 from PC: $042b8

java错误日志是:

    org.contikios.cooja.ContikiError
at org.contikios.cooja.mspmote.MspMote.execute(MspMote.java:341)
at org.contikios.cooja.mspmote.MspMote.execute(MspMote.java:298)
at org.contikios.cooja.motes.AbstractWakeupMote$1.execute(AbstractWakeupMote.java:47)
at org.contikios.cooja.Simulation.run(Simulation.java:280)
at java.lang.Thread.run(Thread.java:745)
Caused by: se.sics.mspsim.core.EmulationException: Executing MSP430X 
instruction but MCU is not a MSP430X
at se.sics.mspsim.core.MSP430Core.emulateOP(MSP430Core.java:1079)
at se.sics.mspsim.core.MSP430.stepMicros(MSP430.java:253)
at org.contikios.cooja.mspmote.MspMote.execute(MspMote.java:337)
... 4 more

请帮我解决这个问题。

4

1 回答 1

0

“执行 MSP430X 指令”错误通常出现在内存损坏时,因此 MCU 开始尝试将某些不包含实际指令的内存地址作为指令执行。

在您的代码中:

const ReqMsg *req = &r;
const void *reqAdd = &req;
packetbuf_copyfrom(reqAdd, 6);

变量reqAdd包含变量的地址req。相反,您希望设置为变量的地址,该地址r等于的req

const void *reqAdd = req;

更好的主意是简单地做

packetbuf_copyfrom(req, 6);

或者

packetbuf_copyfrom(&r, 6);

因为没有真正需要额外的变量。

于 2018-12-15T16:50:06.360 回答