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

C++ PT_WAIT_UNTIL函数代码示例

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

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



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

示例1: write_chunk_pt

/*---------------------------------------------------------------------------*/
static int
write_chunk_pt(struct rudolph0_conn *c, int offset, int flag,
	    uint8_t *data, int datalen)
{
  PT_BEGIN(&recvnetfilept);

  PT_WAIT_UNTIL(&recvnetfilept, receiving_file);
  leds_on(LEDS_YELLOW);
  leds_on(LEDS_RED);
  PT_WAIT_UNTIL(&recvnetfilept, flag == RUDOLPH0_FLAG_NEWFILE);
  leds_off(LEDS_RED);

  do {
    if(datalen > 0) {
      shell_output(&recvnetfile_command, data, datalen, "", 0);
      /*      printf("write_chunk wrote %d bytes at %d\n", datalen, offset);*/
    }
    PT_YIELD(&recvnetfilept);
  } while(flag != RUDOLPH0_FLAG_LASTCHUNK);

  shell_output(&recvnetfile_command, data, datalen, "", 0);
  /*  printf("write_chunk wrote %d bytes at %d\n", datalen, offset);*/
  shell_output(&recvnetfile_command, "", 0, "", 0);
  leds_off(LEDS_YELLOW);
  receiving_file = 0;
  process_post(&shell_recvnetfile_process, PROCESS_EVENT_CONTINUE, NULL);

  PT_END(&recvnetfilept);
}
开发者ID:AWRyder,项目名称:contiki,代码行数:30,代码来源:shell-netfile.c


示例2: PT_THREAD

static PT_THREAD(handle_connection(void))
{
	PT_BEGIN(&s.pt);

	s.state = STATE_LISTENING;

	do {
		PT_WAIT_UNTIL(&s.pt, uip_newdata());

		if(uip_newdata() && parse_msg()) {
			s.state = STATE_HELLO_RECEIVED;
			uip_flags &= (~UIP_NEWDATA);
			break;
		}
	} while(s.state != STATE_HELLO_RECEIVED);

	do {
		send_request();
		PT_WAIT_UNTIL(&s.pt, uip_newdata());

		if(uip_newdata()) {
			s.state = STATE_NAME_RECEIVED;
			uip_flags &= (~UIP_NEWDATA);
			break;
		}
	} while(s.state != STATE_NAME_RECEIVED);

	send_response();

	s.state = STATE_INIT;

	PT_END(&s.pt);
}
开发者ID:SoundGuyAndy,项目名称:MissingLinkFirmware,代码行数:33,代码来源:udpapp.c


示例3: PT_BEGIN

bool
Human::run()
{
	PT_BEGIN();
	
	while (1)
	{
		timer.restart(3000);
		PT_WAIT_UNTIL(timer.isExpired());
		
		for (i = 0; i < 2; i++)
		{
			state = WAVE0;
			timer.restart(500);
			PT_WAIT_UNTIL(timer.isExpired());
			
			state = WAVE1;
			timer.restart(500);
			PT_WAIT_UNTIL(timer.isExpired());
		}
		state = STAND;
	}
	
	PT_END();
}
开发者ID:Alex0704t,项目名称:xpcc,代码行数:25,代码来源:human.cpp


示例4: PT_BEGIN

int DLGSM::PT_restart(struct pt *pt, char *ret) {
	static struct pt child_pt;
	static uint32_t timestamp;
	static char u;
	char iret;
	PT_BEGIN(pt);
        u = 0;                
	while (u < 3) {
		_gsmserial.flush();
        	PT_WAIT_THREAD(pt, PT_send_recv_confirm(&child_pt, &iret, "AT\r\n", "OK", 1000));
                if (iret > 0) {
        		PT_WAIT_THREAD(pt, PT_pwr_off(&child_pt, 1));
                        u = 3;
                } else {
                	PT_WAIT_UNTIL(pt, (millis() - timestamp > 1000));
                        timestamp = millis();
                        u++;
			if (_DEBUG) Serial.println(u, DEC);
        	}
	}
	timestamp = millis();
	if (iret == 1)
		PT_WAIT_THREAD(pt, PT_pwr_off(&child_pt, 0));
	PT_WAIT_UNTIL(pt, (millis() - timestamp) > 6000);
	PT_WAIT_THREAD(pt, PT_pwr_on(&child_pt));
	PT_WAIT_THREAD(pt, PT_GSM_init(&child_pt, ret));
	
	_error_cnt = 0;
	_tout_cnt = 0;
	u = 0;
	*ret = 1;
	PT_END(pt);
}
开发者ID:atiti,项目名称:datalogger,代码行数:33,代码来源:DLGSM.cpp


示例5: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_dhcp(void))
{
  PT_BEGIN(&s.pt);
  
  /* try_again:*/
  s.state = STATE_SENDING;
  s.ticks = CLOCK_SECOND;

  do {
    send_discover();
    s.timer_init = platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_START, 0 );
    PT_WAIT_UNTIL(&s.pt, uip_newdata() || platform_timer_get_diff_us( ELUA_DHCP_TIMER_ID, s.timer_init, platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_READ, 0 ) ) >= s.ticks );
    if(uip_newdata() && parse_msg() == DHCPOFFER) {
	  uip_flags &= ~UIP_NEWDATA;
      s.state = STATE_OFFER_RECEIVED;
      break;
    }
	uip_flags &= ~UIP_NEWDATA;
    if(s.ticks < CLOCK_SECOND * 60) {
      s.ticks *= 2;
    } else {
	  s.ipaddr[0] = 0;
	  goto dhcp_failed;
	  }
  } while(s.state != STATE_OFFER_RECEIVED);
  
  s.ticks = CLOCK_SECOND;

  do {
    send_request();
    s.timer_init = platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_START, 0 );    
    PT_WAIT_UNTIL(&s.pt, uip_newdata() || platform_timer_get_diff_us( ELUA_DHCP_TIMER_ID, s.timer_init, platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_READ, 0 ) ) >= s.ticks );
    
    if(uip_newdata() && parse_msg() == DHCPACK) {
	  uip_flags &= ~UIP_NEWDATA;
      s.state = STATE_CONFIG_RECEIVED;
      break;
    }
    uip_flags &= ~UIP_NEWDATA;
    if(s.ticks <= CLOCK_SECOND * 10) {
      s.ticks += CLOCK_SECOND;
    } else {
      PT_RESTART(&s.pt);
    }
  } while(s.state != STATE_CONFIG_RECEIVED);
  
dhcp_failed:
  dhcpc_configured(&s);
  
  /*
   * PT_END restarts the thread so we do this instead. Eventually we
   * should reacquire expired leases here.
   */
  while(1) {
    PT_YIELD(&s.pt);
  }

  PT_END(&s.pt);
}
开发者ID:BackupTheBerlios,项目名称:elua-svn,代码行数:61,代码来源:dhcpc.c


示例6: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(temperature_thread(struct pt *pt))
{
    PT_BEGIN(pt);

    init_adc(5);
    disable_digital_buffer(5);

    while(1)
    {
        cli();
        
        temperature_counter = 0;
        
        sei();

        PT_WAIT_UNTIL(pt,temperature_counter > 750);

        temp_result = 0;
        temp_sampl_cnt = 0;
     
        for(temp_sampl_cnt = 0; temp_sampl_cnt < 64; temp_sampl_cnt++)
        {    
            start_conversion();
        
            PT_WAIT_UNTIL(pt,!is_adc_busy());

            temp_result += read_adc();
        }        

        dbg(PSTR("> ADC result: %u\r\n"),temp_result >> 6);
    }

    PT_END(pt);
}
开发者ID:hebron,项目名称:enc28j60_experiments,代码行数:36,代码来源:main.c


示例7: PT_THREAD

static PT_THREAD( MNT_check_commands(pt_t* pt) )
{
	mnt_event_t ev;
	u8 swap;

	PT_BEGIN(pt);

	// as long as there are no command
	PT_WAIT_UNTIL(pt, OK == FIFO_get(&MNT.cmds_fifo, &MNT.cmd_fr));

	// silently ignore incoming response
	if ( MNT.cmd_fr.resp == 1 ) {
		DPT_unlock(&MNT.interf);
		PT_RESTART(pt);
	}

	switch (MNT.cmd_fr.cmde) {
		case FR_TAKE_OFF:
			// generate take-off event
			PT_WAIT_UNTIL(pt, (ev = MNT_EV_TAKE_OFF) && OK == FIFO_put(&MNT.ev_fifo, &ev) );
			break;

		case FR_MINUT_TIME_OUT:
			MNT_open_time(&MNT.cmd_fr);
			break;

		case FR_STATE:
			if ( (MNT.cmd_fr.argv[0] == 0x7a) || (MNT.cmd_fr.argv[0] == 0x8b) ) {
				//MNT.state = MNT.cmd_fr.argv[1];
			}

			// don't respond, response will be done by CMN
			PT_RESTART(pt);
			break;

		case FR_APPLI_START:
			MNT.started = 1;

			// don't respond
			PT_RESTART(pt);
			break;

		default:
			// shall never happen
			break;
	}

	// build the response to the current command
	swap = MNT.cmd_fr.orig;
	MNT.cmd_fr.orig = MNT.cmd_fr.dest;
	MNT.cmd_fr.dest = swap;
	MNT.cmd_fr.resp = 1;

	// enqueue it
	PT_WAIT_UNTIL(pt, OK == FIFO_put(&MNT.out_fifo, &MNT.cmd_fr));

	PT_RESTART(pt);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:60,代码来源:minut.c


示例8: init_action

static u8 init_action(pt_t* pt, void* args)
{
	frame_t fr;

	PT_BEGIN(pt);

	// signal init state
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_STATE, 0, FR_STATE_SET, FR_STATE_INIT)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde cone stop
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_CONE, FR_SERVO_OFF)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde aero stop
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_AERO, FR_SERVO_OFF)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// led alive 0.25s
	PT_WAIT_UNTIL(pt, frame_set_3(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_LED_CMD, 0, FR_LED_ALIVE, FR_LED_SET, 25)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	PT_YIELD_WHILE(pt, OK);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:30,代码来源:minut.c


示例9: braking_action

static u8 braking_action(pt_t* pt, void* args)
{
	frame_t fr;

	PT_BEGIN(pt);

	// signal braking state
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_STATE, 0, FR_STATE_SET, FR_STATE_BRAKING)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde cone stop
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_CONE, FR_SERVO_OFF)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde aero open
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_AERO, FR_SERVO_OPEN)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// time-out 0.1s
	MNT.time_out = TIME_get() + 100 * TIME_1_MSEC;

	PT_YIELD_WHILE(pt, OK);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:28,代码来源:minut.c


示例10: parachute_action

static u8 parachute_action(pt_t* pt, void* args)
{
	frame_t fr;

	PT_BEGIN(pt);

	// signal parachute state
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_STATE, 0, FR_STATE_SET, FR_STATE_PARACHUTE)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde cone stop
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_CONE, FR_SERVO_OFF)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde aero stop
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_AERO, FR_SERVO_OFF)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// led open 1s
	PT_WAIT_UNTIL(pt, frame_set_3(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_LED_CMD, 0, FR_LED_OPEN, FR_LED_SET, 100)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	PT_YIELD_WHILE(pt, OK);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:30,代码来源:minut.c


示例11: flight_action

static u8 flight_action(pt_t* pt, void* args)
{
	frame_t fr;

	PT_BEGIN(pt);

	// signal flight state
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_STATE, 0, FR_STATE_SET, FR_STATE_FLIGHT)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde cone close
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_CONE, FR_SERVO_CLOSE)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde aero close
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_AERO, FR_SERVO_CLOSE)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// time-out = flight time
	MNT.time_out = MNT.open_time * TIME_1_SEC / 10 + TIME_get();

	// led alive 0.1s
	PT_WAIT_UNTIL(pt, frame_set_3(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_LED_CMD, 0, FR_LED_ALIVE, FR_LED_SET, 10)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	PT_YIELD_WHILE(pt, OK);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:33,代码来源:minut.c


示例12: waiting_action

static u8 waiting_action(pt_t* pt, void* args)
{
	frame_t fr;

	PT_BEGIN(pt);

	// signal waiting state
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_STATE, 0, FR_STATE_SET, FR_STATE_WAITING)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde cone stop
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_CONE, FR_SERVO_OFF)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// led alive 1s
	PT_WAIT_UNTIL(pt, frame_set_3(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_LED_CMD, 0, FR_LED_ALIVE, FR_LED_SET, 100)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	PT_YIELD_WHILE(pt, OK);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:25,代码来源:minut.c


示例13: cone_closed_action

static u8 cone_closed_action(pt_t* pt, void* args)
{
	frame_t fr;

	PT_BEGIN(pt);

	// signal cone closed state
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_STATE, 0, FR_STATE_SET, FR_STATE_CONE_CLOSED)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// cmde cone close
	PT_WAIT_UNTIL(pt, frame_set_2(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_MINUT_SERVO_CMD, 0, FR_SERVO_CONE, FR_SERVO_CLOSE)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// time-out 1s
	MNT.time_out = TIME_get() + 1 * TIME_1_SEC;

	// led alive 0.1s
	PT_WAIT_UNTIL(pt, frame_set_3(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_LED_CMD, 0, FR_LED_ALIVE, FR_LED_SET, 10)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	// led open off 0.0s
	PT_WAIT_UNTIL(pt, frame_set_3(&fr, DPT_SELF_ADDR, DPT_SELF_ADDR, FR_LED_CMD, 0, FR_LED_OPEN, FR_LED_SET, 0)
			&& OK == FIFO_put(&MNT.out_fifo, &fr)
	);

	PT_YIELD_WHILE(pt, OK);

	PT_END(pt);
}
开发者ID:nnayo,项目名称:egere,代码行数:33,代码来源:minut.c


示例14: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(pingreq_pt(struct pt* pt, struct mqtt_connection* conn))
{
  PT_BEGIN(pt);

  DBG("MQTT - Sending PINGREQ\r\n");

  /* Write Fixed Header */
  PT_MQTT_WRITE_BYTE(conn, MQTT_FHDR_MSG_TYPE_PINGREQ);
  PT_MQTT_WRITE_BYTE(conn, 0);

  send_out_buffer(conn);

  PT_WAIT_UNTIL(pt, conn->out_buffer_sent);

  /* Start timeout for reply. */
  conn->waiting_for_pingresp = 1;

  /* Wait for PINGRESP
   *
   * Note that the timeout disconnect is handle in the timer callback. */
  reset_packet(&conn->in_packet);
  do {
   PT_WAIT_UNTIL(pt, conn->in_packet.packet_received);
  } while((conn->in_packet.fhdr & 0xF0) != MQTT_FHDR_MSG_TYPE_PINGRESP);
  reset_packet(&conn->in_packet);

  conn->waiting_for_pingresp = 0;

  PT_END(pt);
}
开发者ID:jackyz,项目名称:Thingsquare-Mist,代码行数:32,代码来源:mqtt.c


示例15: PT_THREAD

/*---------------------------------------------------------------------*/
static
PT_THREAD(recv_tcpthread(struct pt *pt))
{
  PT_BEGIN(pt);

  /* Read the header. */
  PT_WAIT_UNTIL(pt, uip_newdata() && uip_datalen() > 0);

  if(uip_datalen() < sizeof(struct codeprop_tcphdr)) {
    PRINTF(("codeprop: header not found in first tcp segment\n"));
    uip_abort();
    goto thread_done;
  }

  s.len = uip_htons(((struct codeprop_tcphdr *)uip_appdata)->len);
  s.addr = 0;
  uip_appdata += sizeof(struct codeprop_tcphdr);
  uip_len -= sizeof(struct codeprop_tcphdr);

  xmem_erase(XMEM_ERASE_UNIT_SIZE, EEPROMFS_ADDR_CODEPROP);

  /* Read the rest of the data. */
  do {      
    if(uip_len > 0) {
      xmem_pwrite(uip_appdata, uip_len, EEPROMFS_ADDR_CODEPROP + s.addr);
      s.addr += uip_len;
    }
    if(s.addr < s.len) {
      PT_YIELD_UNTIL(pt, uip_newdata());
    }	
  } while(s.addr < s.len);

  /* Kill old program. */
  elfloader_unload();

  /* Link, load, and start new program. */
  int s;
  static char msg[30 + 10];
  s = elfloader_load(EEPROMFS_ADDR_CODEPROP);
  if (s == ELFLOADER_OK)
    sprintf(msg, "ok\n");
  else
    sprintf(msg, "err %d %s\n", s, elfloader_unknown);
    
  /* Return "ok" message. */
  do {
    s = strlen(msg);
    uip_send(msg, s);
    PT_WAIT_UNTIL(pt, uip_acked() || uip_rexmit() || uip_closed());
  } while(uip_rexmit());

  /* Close the connection. */
  uip_close();
    
 thread_done:;
  PT_END(pt);
}
开发者ID:1uk3,项目名称:contiki,代码行数:58,代码来源:tcp_loader.c


示例16: PT_THREAD

/**
 * @brief Button Task
 *
 * @note Called every 1 ms
 */
static
PT_THREAD(ButtonProc(struct pt *pt)) {
static uint32_t tstart;
uint32_t b;

    PT_BEGIN(pt);
    while(1) {
        PT_WAIT_UNTIL(pt,JoyStick_Read()&JOY_CENTER);
        blinking = ! blinking;
        tstart = msTick;
        PT_WAIT_UNTIL(pt,((msTick-tstart)>=DEBOUNCE_TIME));
        PT_WAIT_UNTIL(pt,!(JoyStick_Read()&JOY_CENTER));
    }
    PT_END(pt);
}
开发者ID:hans-jorg,项目名称:stm32l476gdiscovery,代码行数:20,代码来源:main.c


示例17: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(pingreq_pt(struct pt *pt, struct mqtt_connection *conn))
{
  PT_BEGIN(pt);

  DBG("MQTT - Sending PINGREQ\n");

  /* Write Fixed Header */
  PT_MQTT_WRITE_BYTE(conn, MQTT_FHDR_MSG_TYPE_PINGREQ);
  PT_MQTT_WRITE_BYTE(conn, 0);

  send_out_buffer(conn);

  /* Start timeout for reply. */
  conn->waiting_for_pingresp = 1;

  /* Wait for PINGRESP or timeout */
  reset_packet(&conn->in_packet);
  timer_set(&conn->t, RESPONSE_WAIT_TIMEOUT);

  PT_WAIT_UNTIL(pt, conn->in_packet.packet_received || timer_expired(&conn->t));

  reset_packet(&conn->in_packet);

  conn->waiting_for_pingresp = 0;

  PT_END(pt);
}
开发者ID:Anagalcala,项目名称:contiki-upstream-unstable,代码行数:29,代码来源:mqtt.c


示例18: protothread1

/**
 * The first protothread function. A protothread function must always
 * return an integer, but must never explicitly return - returning is
 * performed inside the protothread statements.
 *
 * The protothread function is driven by the main loop further down in
 * the code.
 */
static int
protothread1(struct pt *pt)
{
  /* A protothread function must begin with PT_BEGIN() which takes a
     pointer to a struct pt. */
  PT_BEGIN(pt);

  /* We loop forever here. */
  while(1) {
    /* Wait until the other protothread has set its flag. */
    PT_WAIT_UNTIL(pt, protothread2_flag != 0);
    printf("Protothread 1 running\n");

    /* We then reset the other protothread's flag, and set our own
       flag so that the other protothread can run. */
    protothread2_flag = 0;
    protothread1_flag = 1;

    /* And we loop. */
  }

  /* All protothread functions must end with PT_END() which takes a
     pointer to a struct pt. */
  PT_END(pt);
}
开发者ID:GiedriusM,项目名称:wpantund,代码行数:33,代码来源:example-small.c


示例19: PT_THREAD

// === Launching balls =================================================
static PT_THREAD (protothread_launch_balls(struct pt *pt))
{
  PT_BEGIN(pt);
  while(1){
	 //make sure we don't put in too many balls
	PT_WAIT_UNTIL(pt, current_balls < MAX_BALLS);
    while(current_balls < MAX_BALLS)    {
        PT_YIELD_TIME_msec(200); //5 balls per second
		current_balls++; //increase ball count in field				
		ball *new_ball = (ball*) malloc (sizeof(ball));	
		new_ball->xc   = int2fix16(315);
		new_ball->yc   = int2fix16(120);
        new_ball->vxc  = int2fix16(-8 + (rand()>>28)); 
        new_ball->vyc  = int2fix16(-8 + (rand()>>27));  
		new_ball->next = NULL;
        new_ball->hit_counter = 0;
        
		if (initial_ball == NULL) { //if chain is empty, this ball is first ball
			initial_ball = new_ball;
            new_ball->prev = NULL;
        }
        else {//otherwise, put it at end
			end_ball->next = new_ball;
            new_ball->prev = end_ball;
        }
        end_ball = new_ball;
    }
  }
  PT_END(pt);
} // end launch ball thread
开发者ID:erichuangr,项目名称:ece4760,代码行数:31,代码来源:lab3.c


示例20: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_input(void))
{
  unsigned short i;
  char *ptr;
  char next;
  
  next = 1; 
  PT_BEGIN(&s.inpt);
  
  while(1) {
    /* Wait until data arrives. */
    next = 0;
    PT_WAIT_UNTIL(&s.inpt, next && uip_newdata());

    CURSOR_OFF();
    /* Print it out on the screen. */
    ptr = (char *)uip_appdata;
    for(i = 0; i < uip_len; ++i) {
      cbm_k_bsout(*ptr);
      ++ptr;
    }
    CURSOR_ON();
  }  
  PT_END(&s.inpt);
}
开发者ID:kincki,项目名称:contiki,代码行数:27,代码来源:cgterm.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PT_YIELD函数代码示例发布时间:2022-05-30
下一篇:
C++ PT_WAIT_THREAD函数代码示例发布时间: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