示例#1
0
/*------------------------------------------------------*/
void	AuxDef (void)
{
	char c;
	while(Kbhit(CHAUX))
	{
		if(!AuxBuff)
			Auxp=AuxBuff=memalloc(LINK_LEN);
		switch(c=Getch(CHAUX))
		{
		case 0x0A:
		case 0x0D:
			puts_aux("\r\n");
			*Auxp=null;
			Auxp=AuxBuff;
			if(!strcmp("?v",Auxp))
				SysMessage(CHAUX);
			puts_aux(">");
			break;
		default:
			if(Auxp != &AuxBuff[LINK_LEN-1])
				*Auxp++=c;
			else
			{
				*Auxp=c;
				Putch('\b',CHAUX);
			}
			Putch(c,CHAUX);
			break;
		}
	}
}
示例#2
0
/*------------------------------------------------------*/
void	AuxRTCM (void)
{
	char c;
	while(Kbhit(CHAUX))
	{
		if(!AuxBuff)
			Auxp=AuxBuff=memalloc(LINK_LEN);
		switch(c=Getch(CHAUX))
		{
		case 0x0A:
		case 0x0D:
			*Auxp=null;
			Auxp=AuxBuff;
			if(RTCMDec(Auxp))
				if(dGPS)
				{
					SendDGPS(0);
					SendDGPS(LinkAddr(OBP));
				}
			break;
		default:
			if(Auxp != &AuxBuff[LINK_LEN-1])
				*Auxp++=c;
			else
				*Auxp=c;
			break;
		}
	}
}
示例#3
0
void main(int argc, char *argv[])
{   
    int skt;
    int err, quit=0;
    int DataBytes;
  
    InitLib();  
    
	err=NetStart();
	if(err<0)
	{
		Print("Init Ethernet error.\n\r");
		return;
	}
	GetIp(MyIp);
    Print("IP=%d.%d.%d.%d\r\n", MyIp[0], MyIp[1], MyIp[2], MyIp[3]);	

    skt=Nopen("*", "UDP/IP", 10000, 0, S_NOCON | S_NOWA);
    if(skt<0)
    {
        Print("Cannot open a connection for UDP/IP!");
        Nterm();
        
        return;
    }  
  
    Print("Socket=%d\r\n", skt);
    SOCKET_NOBLOCK(skt);
  
    while(!quit)
    {
        YIELD();    // must add this line in the while loop
        
        DataBytes=Nread(skt, InBuf, 1500);
        if(DataBytes>0)
        {
			Print("%s\n\r",InBuf);
            memcpy(OutBuf, InBuf, DataBytes);
            Nwrite(skt, OutBuf, DataBytes);
        }

        if(Kbhit())
        {
            switch(Getch())
            {
                case 'q':
                case 'Q':
                    quit=1;
                    break;
            }
        }
    }

    Nclose(skt);
    Nterm();
}
示例#4
0
/*......................................................................*/
void	JwRec(void)
		{
static	ack_flag;
		int	j;

		if(Kbhit(CHAUX))
			if(CheckTask(JwSend,PIT_task))
				switch(j=Getch(CHAUX)) {
					case ACK_COM:  ack_flag = ACK_COM;
									break;
					case NACK_COM:	JwSend();
									break;
					default:		if((ack_flag == ACK_COM) && (j == JwTx[0]))
										DeleteTask(JwSend,PIT_task);
									ack_flag = 0;
									break;
					}
			else
				switch(JwCount)	{
					case	0:	JwCount=JwCheck=Getch(CHAUX);
								if(JwCount > 16)
									JwCount=0;
								else{
									JwCount++;
									Jw=JwRx;
									SetTask(JwDrop,50,PIT_task);
									}
								break;
					case	1:  if(JwExe()) {
									Putch(ACK_COM,CHAUX);
									Putch(JwRx[0],CHAUX);
									}
								else
									Putch(NACK_COM,CHAUX);
								JwCount--;
								DeleteTask(JwDrop,PIT_task);
								break;
					default: 	*Jw = Getch(CHAUX);
								JwCheck += *Jw++;
								JwCount--;
								break;
					}
		}
示例#5
0
/*------------------------------------------------------*/
void	ReadPc (void)
{
	char c;
	while(Kbhit(CHPC))
	{
		if(!LinkBuff)
			Linkp=LinkBuff=memalloc(LINK_LEN);
		switch(c=Getch(CHPC))
		{
		case 0x0A:
		case 0x0D:
			puts_pc("\r\n");
			*Linkp=null;
			Linkp=LinkBuff;
			PcLinkDecode(Linkp);
			puts_pc(">");
			break;
		case 0x7F:
			if(Linkp != LinkBuff)
			{
				--Linkp;
				if(!LPP)
					puts_pc("\b \b");
			}
			break;
		default:
			if(Linkp != &LinkBuff[LINK_LEN-1])
				*Linkp++=c;
			else
			{
				*Linkp=c;
				if(!LPP)
					Putch('\b',CHPC);
			}
			if(!LPP)
				Putch(c,CHPC);
			break;
		}
	}
}
示例#6
0
void *menu_function (void *)
{
    int option;
    static bool flag_play_pause = 0;
    static bool flag_stop = 0;
    static float ff_value = 1;
    static int ff_key_pressed = 0;
    static float sf_value = 1;
    static int sf_key_pressed = 0;
    static int sr_key_pressed = 0;
    static float sr_value = 1;

    while (1)
    {
        option = Kbhit ();

        switch (option)
        {
        case 109:
            show_menu();
            break;

        case 10:
            show_menu();
            break;

        case 112:
            if (flag_play_pause)
            {
                gst_video_object->GSTPause();
                flag_play_pause = 0;
                printf ("\nVideo Paused\n");
            }
            else
            {
                if (flag_stop)
                {
                    gst_video_object->GSTBuildPipeline((char *)"mfw_v4lsink", NULL, BusCall1);
                    flag_stop = 0;
                }
                gst_video_object->GSTPlay();
                flag_play_pause = 1;

                printf ("\nVideo Playing\n");
            }
            break;

        case 115:
            gst_video_object->GSTStop();
            printf ("\nVideo Stopped\n");
            flag_stop = 1;
            flag_play_pause = 0;
            break;

        case 102:
            if (ff_key_pressed == 5)
            {
                ff_key_pressed = 0;
                ff_value = 1.0;
            }
            else if (ff_key_pressed == 0)
            {
                ff_key_pressed++;
                ff_value = 1.5;
            }
            else if (ff_key_pressed == 1)
            {
                ff_key_pressed++;
                ff_value = 2.0;
            }
            else if (ff_key_pressed == 2)
            {
                ff_key_pressed++;
                ff_value = 4.0;
            }
            else if (ff_key_pressed == 3)
            {
                ff_key_pressed++;
                ff_value = 10.0;
            }
            else if (ff_key_pressed == 4)
            {
                ff_key_pressed++;
                ff_value = 20.0;
            }

            gst_video_object->GSTFastForward(ff_value);
            printf ("\nFast forwarding at: %.1f\n", ff_value);
            break;


        case 110:
            if (sf_key_pressed == 4)
            {
                sf_key_pressed = 0;
                sf_value = 1.0;
            }
            else if (sf_key_pressed == 0)
            {
                sf_key_pressed++;
                sf_value = 0.7;
            }
            else if (sf_key_pressed == 1)
            {
                sf_key_pressed++;
                sf_value = 0.5;
            }
            else if (sf_key_pressed == 2)
            {
                sf_key_pressed++;
                sf_value = 0.3;
            }
            else if (sf_key_pressed == 3)
            {
                sf_key_pressed++;
                sf_value = 0.1;
            }

            gst_video_object->GSTFastForward(sf_value);
            printf ("\nSlow Motion forward at: %.1f\n", sf_value);
            break;



        case 106:
            guint64 value;
            printf ("\nDuration: %" GST_TIME_FORMAT ", jump to (in ms): ", GST_TIME_ARGS (gst_video_object->GSTQueryDuration()));
            scanf ("%lu", &value);
            if ((value * 1000 * 1000) >  gst_video_object->GSTQueryDuration())
                printf ("\nValue out of range...\n");

            else
            {
                printf ("\nPlaying from: %"GST_TIME_FORMAT "\n", GST_TIME_ARGS (value*1000*1000));
                gst_video_object->GSTSeekAbsolute(value);
            }
            break;


        case 103:
            printf ("\nVideo Position is: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (gst_video_object->GSTQueryPosition()));
            break;

        case 108:
            printf ("\nVideo duration is: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (gst_video_object->GSTQueryDuration()));
            break;

        case 27:
            exit (0);
            break;

        default :
            break;

        };
    }

}
int main (int argc, char **argv)
{
	fsl_v4l_cap mycamera;
	//fsl_v4l_out mydisplay;
	int ret;
	char *buffer;
	
	int width = 640;
	int height = 480;
	IplImage *image;

	printf ("\n\nInitialzing Camera Device: Video0 (640x480)...");
	
	ret = V4LWrapper_CreateCameraCapture (&mycamera, "/dev/video0", width, height);
	
	if (ret == V4LWrapper_SUCCESS)
	{
		printf ("OK\n");
	}
	
	else
	{
		printf ("\nDevice not found, make sure the driver are properly installed:");
		printf ("\nov5642_camera.ko, ov5640_camera_mipi.ko and mxc_v4l2_capture.ko\n");
		exit (0);
	}

	//printf ("\nInitialzing Display Device: video17, fb0 (640x480)...");
	//ret = V4LWrapper_CreateOutputDisplay (&mydisplay, "/dev/fb0", NULL, width, height);
	//if (ret == V4LWrapper_SUCCESS)
	//	printf ("OK\n");
	//else
	//{
	//	V4LWrapper_CloseCameraCapture (&mycamera);
	//	exit (0);
	//}
	
	printf ("\nAllocating data buffer...");
	buffer = (char *) malloc (mycamera.g_frame_size);
	
	if (buffer)
		printf ("OK\n");

	else
	{
		V4LWrapper_CloseCameraCapture (&mycamera);
		//V4LWrapper_CloseOutputDisplay (&mydisplay);1
		
		exit (0);
	}

	
	image = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
	
	IplImage *gray = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
	
	while (! Kbhit())
	{
		V4LWrapper_QueryFrame (&mycamera, buffer);	
		V4LWrapper_CvtColor (buffer, image->imageData, width, height, YUV422toRGB888);
		cvCvtColor (image, gray, CV_RGB2GRAY);
		cvCanny (gray, gray, 60, 110, 3);
		cvShowImage ("test", gray);
		//V4LWrapper_OutputDisplay (&mydisplay, buffer);
		
		cvWaitKey (10);
	}

	V4LWrapper_CloseCameraCapture (&mycamera);
	//V4LWrapper_CloseOutputDisplay (&mydisplay);
	free (buffer);
	cvReleaseImage (&image);
	
	return 0;
}