Beispiel #1
0
int main(void)
{
   
    smart_car_set(30, 0);
    
    return 0;
}
Beispiel #2
0
int main(void)
{
   
    smart_car_set(30, 0); //speed=30 Angel=0
    
    return 0;
}
int main(void)
{
    //int fd;
	char *buf="front!";
    //fd = open("test.txt",O_CREAT,0);
//	write(fd,buf,7);
    //printf("front!\n"); 
    smart_car_set(0, 50); //speed=30 Angel=0
  //  close(fd);
    return 0;
}
Beispiel #4
0
int hrobot_tcp_receive(TCP_CTRL_FRAME *frame, uint8_t *buf)
{
	int n,i;
	int fd;
	int16_t angle,speed;
	char cmdbuf[5]="0000";
	while(1){
		angle=0x0000;
		speed=0x0000;
		memset(frame,0,sizeof(TCP_CTRL_FRAME));
		memset(buf,0,HROBOT_TCP_MAX_DATA_LENGTH);

		if ((n = recv(clfd,frame, HROBOT_TCP_CTRL_FRAME_SIZE, 0)) > 0)
		{
			frame->cmd = ntohs(frame->cmd);
			frame->length = ntohs(frame->length);
			syslog(LOG_ERR,"frame_CTR:recv %d data",n);
			syslog(LOG_ERR,"cmd:%d, length:%d",frame->cmd, frame->length);
		/*	cmdbuf[0]='0'+frame->cmd/10;
			cmdbuf[1]='0'+frame->cmd%10;
			cmdbuf[2]='0'+frame->length/10;
			cmdbuf[3]='0'+frame->length%10;
			cmdbuf[4]='Z';
			if ((fd=open("/home/boat/state_tcp.txt",O_WRONLY|O_CREAT|O_APPEND,S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))<0)
					syslog(LOG_ERR,"fd=%d open error \n",fd);
			if (write(fd,&cmdbuf,5)<0)
					syslog(LOG_ERR,"write error \n");
			close(fd);
			*/
		}
		else{
			return 0;
		}
		if ((n = recv(clfd, buf, frame->length, 0)) > 0)
		{
			syslog(LOG_ERR,"frame_DATA:recv %d data",n);
			for(i=0;i<n;++i)
				syslog(LOG_DEBUG,"recv data:%x",buf[i]);
			angle=(buf[1]<<8)|buf[0];
			speed=(buf[3]<<8)|buf[2];
			
			syslog(LOG_DEBUG,"angle=%d,speed=%d",angle,speed);
			smart_car_set(speed,angle);
		}
		else{
			return 0;
		}
		

	}

}
Beispiel #5
0
int main(void)
{
    smart_car_set(90, 30);
    
    return 0;
}
Beispiel #6
0
int main(void)
{
    smart_car_set(0, -60);
    
    return 0;
}