• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ packetbuf_clear函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: PROCESS_THREAD

PROCESS_THREAD(rime_udp_process, ev, data)
{
  static uip_ipaddr_t ipaddr;

  PROCESS_BEGIN();

  broadcast_conn = udp_broadcast_new(UIP_HTONS(RIME_UDP_PORT), NULL);
  if(broadcast_conn == NULL) {
    PRINTF("rime-udp: Failed to allocate a broadcast connection!\n");
  }

  uip_create_unspecified(&ipaddr);
  unicast_conn = udp_new(&ipaddr, UIP_HTONS(RIME_UDP_PORT), NULL);
  if(unicast_conn == NULL) {
    PRINTF("rime-udp: Failed to allocate a unicast connection!\n");
  }

  udp_bind(unicast_conn, UIP_HTONS(RIME_UDP_PORT));

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
    if(uip_newdata()) {
      packetbuf_clear();
      memmove(packetbuf_hdrptr(), uip_appdata, uip_datalen());
      PRINTF("rime-udp: received %d bytes\n", uip_datalen());
      receiver_callback(&rime_udp_driver);
    }
  }

  PROCESS_END();
}
开发者ID:1uk3,项目名称:contiki,代码行数:31,代码来源:rime-udp.c


示例17: send_rrep

/*---------------------------------------------------------------------------*/
static void
send_rrep(struct route_discovery_conn *c, const rimeaddr_t *dest)
{
    struct rrep_hdr *rrepmsg;
    struct route_entry *rt;
    rimeaddr_t saved_dest;

    rimeaddr_copy(&saved_dest, dest);

    packetbuf_clear();
    dest = &saved_dest;
    rrepmsg = packetbuf_dataptr();
    packetbuf_set_datalen(sizeof(struct rrep_hdr));
    rrepmsg->hops = 0;
    rimeaddr_copy(&rrepmsg->dest, dest);
    rimeaddr_copy(&rrepmsg->originator, &rimeaddr_node_addr);
    rt = route_lookup(dest);
    if(rt != NULL)
    {
        PRINTF("%d.%d: send_rrep to %d.%d via %d.%d\n",
               rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
               dest->u8[0],dest->u8[1],
               rt->nexthop.u8[0],rt->nexthop.u8[1]);
        unicast_send(&c->rrepconn, &rt->nexthop);
    }
    else
    {
        PRINTF("%d.%d: no route for rrep to %d.%d\n",
               rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
               dest->u8[0],dest->u8[1]);
    }
}
开发者ID:aiss83,项目名称:nucbit,代码行数:33,代码来源:route-discovery.c


示例18: send_announcement

static void
send_announcement(void *ptr)
{
  struct cxmac_hdr *hdr;
  int announcement_len;

  /* Set up the probe header. */
  packetbuf_clear();
  hdr = packetbuf_dataptr();

  announcement_len = format_announcement((char *)hdr +
					 sizeof(struct cxmac_hdr));

  if(announcement_len > 0) {
    packetbuf_set_datalen(sizeof(struct cxmac_hdr) + announcement_len);
    hdr->dispatch = DISPATCH;
    hdr->type = TYPE_ANNOUNCEMENT;

    packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr);
    packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &rimeaddr_null);
    packetbuf_set_attr(PACKETBUF_ATTR_RADIO_TXPOWER, announcement_radio_txpower);
    if(NETSTACK_FRAMER.create()) {
      NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
    }
  }
}
开发者ID:EDAyele,项目名称:wsn430,代码行数:26,代码来源:cxmac.c


示例19: PROCESS_THREAD

PROCESS_THREAD(uwb_process, ev, data)
{
  int len;
  PROCESS_BEGIN();
  UWBPROCESSFLAG(01);

  while(1) {
    PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
    UWBPROCESSFLAG(02);

    if (uwb_fsm != UWB_STATE_RX_PROCESS_POLLED)
      PRINTF("uwb: wrong state in process: %u\n",uwb_fsm);			

    packetbuf_clear();

    len = ram_rx_buffer[2];
    if ((len > 0) && (len < PACKETBUF_SIZE))
    {
      memcpy(packetbuf_dataptr(),&ram_rx_buffer[3],len); 
      packetbuf_set_datalen(len);
      UWBPROCESSFLAG(03);
      NETSTACK_RDC.input();
    }

    /* switch back to listen-state */
    PRINTF("uwb: enabling rx-mode\r\n");
    enable_rx_mode();

    PRINTF("uwb: read: %u bytes\n",len);

    UWBPROCESSFLAG(04);
  }

  PROCESS_END();
}
开发者ID:bearxiong99,项目名称:tdma_demo,代码行数:35,代码来源:uwb.c


示例20: format_data

/*---------------------------------------------------------------------------*/
static int
format_data(struct rudolph1mh_conn *c, int chunk)
{
  struct rudolph1mh_datapacket *p;
  
  packetbuf_clear();
  p = packetbuf_dataptr();
  p->h.type = TYPE_DATA;
  p->h.s_id = c->s_id;
  p->h.chunk = chunk;
  p->datalen = 0; //read_data(c, p->data, chunk);
  if(c->cb->read_chunk) {
    p->datalen = c->cb->read_chunk(c, chunk * RUDOLPH1MH_DATASIZE, p->data,
        RUDOLPH1MH_DATASIZE);
  }

  if(p->datalen != RUDOLPH1MH_DATASIZE){
    p->h.type = TYPE_FIN;
  }

  packetbuf_set_datalen(sizeof(struct rudolph1mh_datapacket) - (RUDOLPH1MH_DATASIZE
      - p->datalen));

  return p->datalen;
}
开发者ID:kincki,项目名称:contiki,代码行数:26,代码来源:rudolph1mh.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ packetbuf_datalen函数代码示例发布时间:2022-05-30
下一篇:
C++ packetbuf_attr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap