コード例 #1
0
ファイル: do_client.c プロジェクト: tolsac/zappy
int		do_client(int socket_client, t_player_lst **tmp, t_init *data)
{
  char		buff[MAX_MSG + 1];
  int		ret;

  if ((*tmp)->player.buf.c > 9)
    return (1);
  if ((ret = received(&((*tmp)->player), buff)) == -1)
    return (merror("recv"));
  else if (!ret)
    {
      *tmp = del_player(socket_client, data);
      return (0);
    }
  else if ((*tmp)->player.ghost == 1)
    {
      (*tmp)->player.ghost = 0;
      (*tmp)->player.timer = 0;
      ret = add_player(data, *tmp,
		       (*tmp)->player.buf.read_buffer(&((*tmp)->player.buf)));
      ((ret == 1) ? (*tmp = del_player(socket_client, data)) : 0);
      if (ret == 1)
	return (0);
    }
  else if (istimeout(&(*tmp)->player) == -1)
    setup_timer(&(*tmp)->player, data);
  return (1);
}
コード例 #2
0
ファイル: main.c プロジェクト: chengengsen/mcu-standy
void main()
{
	init();
	while(1)
	{
		EA = 0;
#ifdef NEC_SUPPORT
		if(g_wakesleep_recv_flag)
		{
			pin_standby = ~pin_standby;
			pin_vcc = ~pin_vcc;
			P3_2 = ~P3_2;
			g_issleep = ~g_issleep;
			if(g_issleep)
			{
				pt6302_sendcmd(CMD_SHOW | 0x1, NULL, NULL);
			}
			else
			{
				pt6302_cleardcram();
				pt6302_clearadram();
				pt6302_sendcmd(CMD_SHOW, NULL, NULL);
			}
			g_wakesleep_recv_flag = FALSE;
			EA = 1;
			continue;
		}
#endif
		g_uarttimeout = istimeout(g_startrecvtime, UARTTIMEOUT);
		if(SERIAL_STAT_RECVOK == g_stat_recv)
		{
			if(g_checksum == (uint8)(g_prefixbuf[LEN_OF_PREFIX] + checksum(g_payloadbuf, g_payloadbuf[0])))
			{
				switch(g_payloadbuf[1] & 0xf0)
				{
					case CMD_DCRAM:
						pt6302_cleardcram();
						pt6302_sendcmd( g_payloadbuf[1], g_payloadbuf + 2, g_payloadbuf[0] - 1);
						break;
					case CMD_CGRAM:
						pt6302_sendcmd( g_payloadbuf[1], g_payloadbuf + 2, g_payloadbuf[0] - 1);
						break;
					case CMD_ADRAM:
						pt6302_sendcmd( g_payloadbuf[1], g_payloadbuf + 2, 1);
						break;
					case CMD_GOUTSET:
						pt6302_sendcmd( g_payloadbuf[1], NULL, NULL);
						break;
					case CMD_BRIGHTNESS:
						pt6302_sendcmd( g_payloadbuf[1], NULL, NULL);
						break;
					case CMD_NUM:
						pt6302_sendcmd( g_payloadbuf[1], NULL, NULL);
						break;
					case CMD_SHOW:
						pt6302_sendcmd( g_payloadbuf[1], NULL, NULL);
						break;
					case CMD_TEST:
						break;
					case CMD_MISC:
						switch(g_payloadbuf[1] & 0xf)
						{
#ifdef MCU_POWER_UART
							case 0:		  //STANDBY
								pin_standby = 1;
								pin_vcc = 0;
								P3_2 = 0;
								g_issleep = 1;
								pt6302_sendcmd(CMD_SHOW | 0x1, NULL, NULL);
								break;
							case 1:			//BOOTUP
								pin_standby = 0;
								pin_vcc = 1;
								P3_2 = 1;
								g_issleep = 0;
								pt6302_cleardcram();
								pt6302_clearadram();
								pt6302_sendcmd(CMD_SHOW, NULL, NULL);
								break;
#endif								
							case 2:		//init
								pt6302_init(g_payloadbuf[2], g_payloadbuf[3]);
#ifdef NEC_SUPPORT
								g_rc_t.usrid = g_payloadbuf[4];
								g_rc_t.keycode_power = g_payloadbuf[5];
#endif								
								break;
							case 3:		//clear
								pt6302_cleardcram();
								pt6302_clearadram();
								break;
							case 4:		//clear & show
								pt6302_cleardcram();
								pt6302_clearadram();
								pt6302_sendcmd(CMD_SHOW, NULL, NULL);
							default:
								break;
						}
						break;
					default:
						break;
				}
			}
			g_checksum = 0;
			g_uarttimeout = FALSE;
			g_stat_recv = SERIAL_STAT_PREFIX0;
		}
		EA = 1;
	}


}