Contiki-ng Stack 错误中的多包连接

问题描述

我正在尝试在 Contiki-ng 中实现我的集群版本。我从这段代码中得到了一些灵​​感:Clustring example

我所做的基本上是创建了两个连接:

static struct simple_udp_connection broad_conn;  
static struct simple_udp_connection uni_conn;

然而,尽管代码在 cooja 中编译并开始运行,但它停止向我显示堆栈中的错误。我跟踪了错误消息,看起来它来自stack-check.c中的这部分代码

  if(p >= (uint8_t*)GET_STACK_ORIGIN()) {
    /* This means the stack is screwed. */
    return -1;
  }
 actual = stack_check_get_usage();
allowed = stack_check_get_reserved_size();
if(actual < 0 || allowed < 0) {
LOG_ERR("Check in inconsistent state: %" PRId32 " vs. %" PRId32 "\n",actual,allowed);

没有内存溢出,代码中除了回调函数什么都没有。我唯一想到的是这是因为联系,但我只是不明白为什么。 这是nodes.c的代码

    #include "contiki.h"              
    #include "simple-udp.h"          
    #include "sys/log.h"              
    #define LOG_MODULE "SensorNode"   
    #define LOG_LEVEL LOG_LEVEL_INFO 
    #define UDP_PORT_broADCAST 1234   
    #define UDP_PORT_UNICAST 4321     
    static struct simple_udp_connection broadcast_conn;  
    static struct simple_udp_connection unicast_conn;    
    static uip_ipaddr_t CH_address; 

PROCESS(nodes_process,"Nodes");
AUTOSTART_PROCESSES(&nodes_process);
/*---------------------------------Not Me------------------------------------------*/
static void
broadcast_receiver(struct simple_udp_connection *c,const uip_ipaddr_t *sender_addr,uint16_t sender_port,const uip_ipaddr_t *receiver_addr,uint16_t receiver_port,const uint8_t *data,uint16_t datalen)
{
    LOG_INFO("Received broadcast '%.*s' from ",datalen,(char *) data);
    LOG_INFO_6ADDR(sender_addr);
    LOG_INFO_("\n");
    uip_ipaddr_copy(&CH_address,sender_addr); 
}
/*---------------------------------------------------------------------------*/
static void
unicast_receiver(struct simple_udp_connection *c,uint16_t datalen)
{
    LOG_INFO("Received reply '%.*s' from ",(char *) data);
    LOG_INFO_6ADDR(sender_addr);
    LOG_INFO_("\n");
}

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(nodes_process,ev,data)
{

    static struct etimer periodic_timer; 
    static unsigned count;
    static char str[32];

    PROCESS_BEGIN();
     /* Not me also */
    /* Initialize UDP broadcast connection */
    simple_udp_register(&broadcast_conn,UDP_PORT_broADCAST,NULL,broadcast_receiver);

    /* Initialize UDP unicast connection */
    simple_udp_register(&unicast_conn,UDP_PORT_UNICAST,unicast_receiver);

    /* Send messages to the clusterhead every 60 seconds */
    etimer_set(&periodic_timer,60*CLOCK_SECOND);

    while(1) {
        PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));


        LOG_INFO("Sending message %u to ",count);
        LOG_INFO_6ADDR(&CH_address);
        LOG_INFO_("\n");

        snprintf(str,sizeof(str),"hello %d",count);
        simple_udp_sendto(&unicast_conn,str,strlen(str),&CH_address);
        count++;
        etimer_reset(&periodic_timer);

    }

    PROCESS_END();
}

对解释这一点的任何帮助都会很棒。

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)