Example #1
0
int Login(int sock,int type)
{
	char login_buff[8];
	FrameInit(login_buff, 8, 0x00);
	login_buff[4] = 0x00;
	login_buff[5] = 0x00;
	login_buff[6] = 0x01;
	if(send(sock, login_buff, 8, 0) != 8)
    {
		printf("login failed\n");
        return -1;
    }
    return 0;
}
Example #2
0
void SendDataSepecificLen(int sock, int len)
{
	if(len > 1000)
		return;
    char send_buff[1024];
    for(int i = 4; i < len - 1; ++i)
	{
        send_buff[i] = (char) i%256;
	}
	FrameInit(send_buff, len + 5, 0x10);
	int ret = 0,send_count = 0,  total = len + 5, send_total = 0;
	timeval last_time, current_time;
	gettimeofday(&last_time, NULL);
	while(true)
	{
        ret = send(sock, send_buff + send_count, total - send_count, 0);
		if(ret < 0)
		{
        	timespec spec;
			spec.tv_sec = 0;
			spec.tv_nsec = 1000*10;
			nanosleep(&spec, NULL);
			continue;
		}
		else if(ret > 0 && ret == total - send_count)
			send_count = 0;
		else
		{
			send_count += ret;
			timespec spec;
			spec.tv_sec = 0;
			spec.tv_nsec = 1000*10;
			nanosleep(&spec, NULL);
			//printf("send count is %d\n", ret);
			continue;
		}

		send_total++;
		gettimeofday(&current_time, NULL);
		if(current_time.tv_sec - last_time.tv_sec > 1)
		{
			float qps = send_total / (current_time.tv_sec - last_time.tv_sec);
			printf("qps=%f\n", qps);
			send_total = 0;
			last_time = current_time;
		}
	}

}
Example #3
0
//---------------------------------------------------------------------------
void SysInit(void)
{
	power_timer2_disable();
	power_adc_disable();
	power_twi_disable();
	power_usart0_disable();
	power_usart1_disable();

	OledInit();
	FrameInit();
	SndInit();
	EepInit();
	KeyInit();
	MathInit();
	RndInit();
	DebugInit();
}