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


C++ PT_WAIT_UNTIL函数代码示例

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


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


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