当前位置: 首页>>代码示例>>C++>>正文


C++ packetbuf_clear函数代码示例

本文整理汇总了C++中packetbuf_clear函数的典型用法代码示例。如果您正苦于以下问题:C++ packetbuf_clear函数的具体用法?C++ packetbuf_clear怎么用?C++ packetbuf_clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了packetbuf_clear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc2420_process, ev, data)
{
  int len;
  PROCESS_BEGIN();

  PRINTF("cc2420_process: started\n");

  while(1) {
    PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
#if CC2420_TIMETABLE_PROFILING
    TIMETABLE_TIMESTAMP(cc2420_timetable, "poll");
#endif /* CC2420_TIMETABLE_PROFILING */
    
    PRINTF("cc2420_process: calling receiver callback\n");

    packetbuf_clear();
    packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp);
    len = cc2420_read(packetbuf_dataptr(), PACKETBUF_SIZE);
    
    packetbuf_set_datalen(len);
    
    NETSTACK_RDC.input();
#if CC2420_TIMETABLE_PROFILING
    TIMETABLE_TIMESTAMP(cc2420_timetable, "end");
    timetable_aggregate_compute_detailed(&aggregate_time,
                                         &cc2420_timetable);
      timetable_clear(&cc2420_timetable);
#endif /* CC2420_TIMETABLE_PROFILING */
  }

  PROCESS_END();
}
开发者ID:Cancan79,项目名称:mist,代码行数:33,代码来源:cc2420.c

示例2: pollhandler

/*
 * process rx packet, when process receives poll
 */
static void
pollhandler(void)
{
  int len;

  do {
/*        printf("p(");*/
    packetbuf_clear();
    len = read_packet(packetbuf_dataptr(), PACKETBUF_SIZE);

    if(len > 0) {
      packetbuf_set_datalen(len);
/*            printf("RDC input %d\n", len);*/
      NETSTACK_RDC.input();
    }

    /* If we received a packet (or parts thereof) while processing the
       previous packet, we immediately pull it out from the RX
       FIFO. */
    /*    printf("[");*/
    cc1101_rx_interrupt();
    /*    printf("]");*/
    //    printf(")\n");
  } while(packet_rx_len > 0);
}
开发者ID:ADVANSEE,项目名称:mist,代码行数:28,代码来源:cc1101.c

示例3: packetbuf_reference

/*---------------------------------------------------------------------------*/
void
packetbuf_reference(void *ptr, uint16_t len)
{
  packetbuf_clear();
  packetbufptr = ptr;
  buflen = len;
}
开发者ID:soohyunc,项目名称:contiki-2.x,代码行数:8,代码来源:packetbuf.c

示例4: recv_uc

static void recv_uc(struct unicast_conn *c, const rimeaddr_t * from)
{
    sec_since_start = clock_seconds();
    printf("\n%d - MSG from %d.%d\n", sec_since_start, from->u8[0], from->u8[1]);
    
    msg = (struct unicast_message *)packetbuf_dataptr();  
    packetbuf_clear();  
    //printf("MSG TYPE: %d \tCMD: %s \tVALUE: %d\n", msg->type, get_cmd(msg->cmd), msg->value);
    switch (msg->cmd) {
    case CMD_FAN_ON:
	printf("PG:FAN ON\n");
	break;
    case CMD_FAN_OFF:
	printf("PG:FAN OFF\n");
	break;
    case CMD_HEATER_ON:
	printf("PG:HEAT ON\n");
	break;
    case CMD_HEATER_OFF:
	printf("PG:HEAT OFF\n");
	break;
    case CMD_LIGHT_ON:
	printf("PG:LIGHT ON\n");
	break;
    case CMD_LIGHT_OFF:
	printf("PG:LIGHT OFF\n");
	break;
    default:
	printf("\n%s\n", get_cmd(msg->cmd));
    }

}
开发者ID:manishaluthra,项目名称:Sensor-Network-Playground-Monitoring-System,代码行数:32,代码来源:sync.c

示例5: slip_radio_cmd_handler

/*---------------------------------------------------------------------------*/
static int
slip_radio_cmd_handler(const uint8_t *data, int len)
{
  int i;
  if(data[0] == '!') {
    /* should send out stuff to the radio - ignore it as IP */
    /* --- s e n d --- */
    if(data[1] == 'S') {
      int pos;
      packet_ids[packet_pos] = data[2];

      packetbuf_clear();
      pos = packetutils_deserialize_atts(&data[3], len - 3);
      if(pos < 0) {
        PRINTF("slip-radio: illegal packet attributes\n");
        return 1;
      }
      pos += 3;
      len -= pos;
      if(len > PACKETBUF_SIZE) {
        len = PACKETBUF_SIZE;
      }
      memcpy(packetbuf_dataptr(), &data[pos], len);
      packetbuf_set_datalen(len);

      PRINTF("slip-radio: sending %u (%d bytes)\n",
             data[2], packetbuf_datalen());

      /* parse frame before sending to get addresses, etc. */
      no_framer.parse();
      NETSTACK_MAC.send(packet_sent, &packet_ids[packet_pos]);

      packet_pos++;
      if(packet_pos >= sizeof(packet_ids)) {
	packet_pos = 0;
      }
      return 1;
    } else if(data[1] == 'R' && len == 2) {
#if !CONTIKI_TARGET_CC2538DK
      PRINTF("Rebooting\n");
      watchdog_reboot();
#endif
      return 1;
    }
  } else if(uip_buf[0] == '?') {
    PRINTF("Got request message of type %c\n", uip_buf[1]);
    if(data[1] == 'M' && len == 2) {
      /* this is just a test so far... just to see if it works */
      uip_buf[0] = '!';
      uip_buf[1] = 'M';
      for(i = 0; i < 8; i++) {
        uip_buf[2 + i] = uip_lladdr.addr[i];
      }
      uip_len = 10;
      cmd_send(uip_buf, uip_len);
      return 1;
    }
  }
  return 0;
}
开发者ID:Jakl555,项目名称:6lbr,代码行数:61,代码来源:slip-radio.c

示例6: send_adv

/*---------------------------------------------------------------------------*/
static void
send_adv(clock_time_t interval)
{
  struct announcement_msg *adata;
  struct announcement *a;

  packetbuf_clear();
  adata = packetbuf_dataptr();
  adata->num = 0;
  for(a = announcement_list(); a != NULL; a = a->next) {
    adata->data[adata->num].id = a->id;
    adata->data[adata->num].value = a->value;
    adata->num++;
  }

  packetbuf_set_datalen(ANNOUNCEMENT_MSG_HEADERLEN +
		      sizeof(struct announcement_data) * adata->num);

  PRINTF("%d.%d: sending neighbor advertisement with %d announcements\n",
	 rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], adata->num);

  if(adata->num > 0) {
    /* Send the packet only if it contains more than zero announcements. */
    ipolite_send(&c.c, interval, packetbuf_datalen());
  }
}
开发者ID:kincki,项目名称:contiki,代码行数:27,代码来源:polite-announcement.c

示例7: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(stm32w_radio_process, ev, data)
{
  int len;
  PROCESS_BEGIN();
  PRINTF("stm32w_radio_process: started\r\n");

  while(1) {
    PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
    PRINTF("stm32w_radio_process: calling receiver callback\r\n");

#if DEBUG > 1
    for(uint8_t c = 1; c <= RCVD_PACKET_LEN; c++) {
      PRINTF("%x", stm32w_rxbuf[c]);
    }
    PRINTF("\r\n");
#endif

    packetbuf_clear();
    len = stm32w_radio_read(packetbuf_dataptr(), PACKETBUF_SIZE);
    if(len > 0) {
      packetbuf_set_datalen(len);
      NETSTACK_RDC.input();
    }
    if(!RXBUFS_EMPTY()) {
      /*
       * Some data packet still in rx buffer (this happens because process_poll
       * doesn't queue requests), so stm32w_radio_process needs to be called
       * again.
       */
      process_poll(&stm32w_radio_process);
    }
  }
  PROCESS_END();
}
开发者ID:amc2505,项目名称:contiki,代码行数:35,代码来源:stm32w-radio.c

示例8: PROCESS_THREAD

/**
 * \brief      Radio RF233 process, infinitely awaits a poll, then checks radio
 *             state and handles received data.
 */
PROCESS_THREAD(rf233_radio_process, ev, data)
{
  int len;
  PROCESS_BEGIN();
  PRINTF("RF233: started.\n");

  while(1) {
    PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
    PRINTF("RF233: polled.\n");

    if(interrupt_callback_wants_poll) {
      rf233_interrupt_poll();
    }

    packetbuf_clear();
    // packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp);
    len = rf233_read(packetbuf_dataptr(), PACKETBUF_SIZE);
    if(len > 0) {
      packetbuf_set_datalen(len);
      NETSTACK_RDC.input();
    } else {
      PRINTF("RF233: error while reading: %d\n", len);
    }
  }
  PROCESS_END();
}
开发者ID:thegeek82000,项目名称:asf,代码行数:30,代码来源:rf233.c

示例9: net_buf_get

struct net_buf *l2_buf_get_reserve(uint16_t reserve_head)
#endif
{
	struct net_buf *buf;

	buf = net_buf_get(&free_l2_bufs, reserve_head);
	if (!buf) {
#ifdef DEBUG_L2_BUFS
		NET_ERR("Failed to get free L2 buffer (%s():%d)\n",
			caller, line);
#else
		NET_ERR("Failed to get free L2 buffer\n");
#endif
		return NULL;
	}

	dec_free_l2_bufs(buf);

	NET_BUF_CHECK_IF_NOT_IN_USE(buf);

#ifdef DEBUG_L2_BUFS
	NET_DBG("[%d] buf %p reserve %u ref %d (%s():%d)\n",
		get_free_l2_bufs(), buf, reserve_head, buf->ref,
		caller, line);
#else
	NET_DBG("buf %p reserve %u ref %d\n", buf, reserve_head, buf->ref);
#endif

	packetbuf_clear(buf);

	return buf;
}
开发者ID:coldnew,项目名称:zephyr-project-fork,代码行数:32,代码来源:l2_buf.c

示例10: recv

/*---------------------------------------------------------------------------*/
static void
recv( const struct mac_driver *c)
{
	packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, 34);
	int len = c->read();
	char cleanString [128];
	int cleanLen = 0;
	int i;
	char* in=  (char*)packetbuf_dataptr();
	for ( i = 0; i < len; i++)
	{
		
		if ( ( in[i]  >= ' ' && in[i]  <= 'z' ))
		{
			cleanString[cleanLen] =  in[i];
			printf("%i %i\n",i,in[i]);
			cleanLen++;
		}
	}
	//cleanString[cleanLen] = '\0';
	cleanLen++;
	printf("message received, len = %d, '%s'\n", cleanLen, cleanString);
	//printf("message received, len = %d, '%s'\n", len, (char *)packetbuf_dataptr());
	leds_toggle(LEDS_GREEN);
	packetbuf_clear();
	//packetbuf_attr_clear();


}	
开发者ID:Newton1026,项目名称:HCCP-Code,代码行数:30,代码来源:hetero.c

示例11: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(uz2400_process, ev, data)
{
  int len;
  PROCESS_BEGIN();

  PRINTF("uz2400_process: started\n");

  while(1) {
    PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
//#if UZ2400_TIMETABLE_PROFILING
//    TIMETABLE_TIMESTAMP(uz2400_timetable, "poll");
//#endif /* UZ2400_TIMETABLE_PROFILING */

    PRINTF("uz2400_process: calling receiver callback\n");

    packetbuf_clear();
    packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp);
    
    len = uz2400_read(packetbuf_dataptr(), PACKETBUF_SIZE);
    packetbuf_set_datalen(len);

    NETSTACK_RDC.input();
    /* flushrx(); */
//#if UZ2400_TIMETABLE_PROFILING
//    TIMETABLE_TIMESTAMP(uz2400_timetable, "end");
//    timetable_aggregate_compute_detailed(&aggregate_time,
//                                         &uz2400_timetable);
//    timetable_clear(&uz2400_timetable);
//#endif /* UZ2400_TIMETABLE_PROFILING */
	//EXTI4_ClearBit();
  }

  PROCESS_END();
}
开发者ID:Simonliang0928,项目名称:Contiki-BORDER,代码行数:35,代码来源:uz2400.c

示例12: rime_init

/*---------------------------------------------------------------------------*/
void
rime_init(const struct mac_driver *m)
{
  queuebuf_init();
  route_init();
  packetbuf_clear();
  neighbor_init();
  announcement_init();
  rime_mac = m;
  rime_mac->set_receive_function(input);

  chameleon_init(&chameleon_bitopt);
#if ! RIME_CONF_NO_POLITE_ANNOUCEMENTS
  /* XXX This is initializes the transmission of announcements but it
   * is not currently certain where this initialization is supposed to
   * be. Also, the times are arbitrarily set for now. They should
   * either be configurable, or derived from some MAC layer property
   * (duty cycle, sleep time, or something similar). But this is OK
   * for now, and should at least get us started with experimenting
   * with announcements.
   */
  polite_announcement_init(POLITE_ANNOUNCEMENT_CHANNEL,
			   POLITE_ANNOUNCEMENT_START_TIME,
			   POLITE_ANNOUNCEMENT_MAX_TIME);
#endif /* ! RIME_CONF_NO_POLITE_ANNOUCEMENTS */
}
开发者ID:kincki,项目名称:contiki,代码行数:27,代码来源:rime.c

示例13: send_adv

/*---------------------------------------------------------------------------*/
static void
send_adv(void *ptr)
{
  struct announcement_msg *adata;
  struct announcement *a;

  packetbuf_clear();
  adata = packetbuf_dataptr();
  adata->num = 0;
  for(a = announcement_list(); a != NULL && a->has_value; a = list_item_next(a)) {
    adata->data[adata->num].id = a->id;
    adata->data[adata->num].value = a->value;
    adata->num++;
  }

  packetbuf_set_datalen(ANNOUNCEMENT_MSG_HEADERLEN +
		      sizeof(struct announcement_data) * adata->num);

  PRINTF("%d.%d: sending neighbor advertisement with %d announcements\n",
	 linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1], adata->num);

  if(adata->num > 0) {
    /* Send the packet only if it contains more than zero announcements. */
    broadcast_send(&c.c);
  }
  PRINTF("%d.%d: sending neighbor advertisement with val %d\n",
	 linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1],
	 c.val);
}
开发者ID:200018171,项目名称:contiki,代码行数:30,代码来源:broadcast-announcement.c

示例14: transmit_epidemic

/**
 * @brief transmit_epidemic
 */
static void transmit_epidemic(){

    packetbuf_clear();
    
    data_packet_t *dpkt = (data_packet_t*)packetbuf_dataptr();
    
    if(isAnchorFlag){
        dpkt->type = ANCHOR_PKT;
    }else{
        dpkt->type = PROBE_PKT;
    }
    //add sender offset.
    dpkt->offset   = probe_offset;
    dpkt->period   = get_node_period();
    dpkt->src_id   = rimeaddr_node_addr.u8[0];
    
    uint8_t pldSize = 0;
    if(radio_read_flag == 0){
        if(list_access_flag == 0){
            list_access_flag = 1;
            pldSize = neighs_add2payload(&dpkt->data[0], isAnchorFlag, probe_offset);
            list_access_flag = 0;
        }

        //if(pldSize){

            rtimer_clock_t t0;
            uint8_t i = 0, pkt_seen = 0, ccaCounter= 0;

            //ccaCounter= randomint_between(CCA_COUNT_MAX, CCA_COUNT_MAX_TX);

	    ccaCounter = /*CCA_COUNT_MAX +*/ random_int(CCA_COUNT_MAX_TX);
	    //watchdog
	    watchdog_periodic();
	     
            for( i = 0; i < ccaCounter && beacon_2_flag; i++){

		//watchdog
		watchdog_periodic();	
		
		
                t0 = RTIMER_NOW();

                while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CCA_CHECK_TIME)){
                    //do nothing.. KUNANGA
                }

                if(NETSTACK_RADIO.channel_clear() == 0){
                    pkt_seen = 1;
                    break; // maybe return here .. collision is expected
                }

            }

            if((pkt_seen == 0) && (radio_read_flag == 0)){
                NETSTACK_RADIO.send((void*)packetbuf_dataptr(),DATAPKT_HDR_LEN + pldSize);
            }
        //} //end of pldSize
    }
}
开发者ID:aoboy,项目名称:acc-slight,代码行数:63,代码来源:acc-sl.c

示例15: send_br_list

/**
 * send the broadcast list to the neighbor
 */
void send_br_list(struct broadcast_conn *broadcastConn){
    Br_msg_list *br_msg_list;
    Br_msg_list *remove;
    if(list_length(broadcast_list)>0){
        for(br_msg_list = list_head(broadcast_list);br_msg_list!=NULL;){
            packetbuf_copyfrom(&br_msg_list->broadcast_msg,sizeof(Broadcast_msg));
            printf("[BC] @%d @%u.%u base [email protected]%u.%u\n", clock_seconds(),rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
                   br_msg_list->broadcast_msg.base_station.u8[0],br_msg_list->broadcast_msg.base_station.u8[1]);
            broadcast_send(broadcastConn);
            packetbuf_clear();
            print_br_list();
            remove = br_msg_list;
            br_msg_list = br_msg_list->next;
            if(local_node.sen_type == BASE_STATION && (remove->broadcast_msg.msg_type==SUBSCRIBE||
                                                       remove->broadcast_msg.msg_type==UNSUBSCRIBE)){
            }else if(remove!=NULL&&list_length(broadcast_list)>1){
                list_remove(broadcast_list,remove);
                memb_free(&broadcast_list_memb, remove);
                printf("[DELET-BR-MSG] msg sub_type %u msg_type %u br list length %u\n",remove->broadcast_msg.subscribe_type,
                       remove->broadcast_msg.msg_type,list_length(broadcast_list));
                remove = NULL;
                break;
            }
        }
    }

}
开发者ID:xizhejiang,项目名称:Contiki-Wireless-Sensor-Network,代码行数:30,代码来源:Light.c


注:本文中的packetbuf_clear函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。