⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serverutlexam.cpp

📁 一个在Linux下开发的IP摄像头的驱动程序及控制软件
💻 CPP
字号:
// ServerUtlEXAM.cpp : Defines the entry point for the console application.
//

#ifdef _WIN32
#include <windows.h>
#endif //_WIN32
#include <stdio.h>


int PTZTest(char *);
int PTTest(char *);

int main(int argc, char* argv[])
{
	char szInputBuf[256];

	if (argc < 5)
	{
		printf("invalid arguments\n");
		printf("Usage: ServerUtlTest.exe -I<host ip> -U<user name> -R<file to be upgraded> ");
		printf("-T<model name> -P<password>\n");
		return -1;
	}

	printf("\ntest Get Firmware Version\n");
	sprintf(szInputBuf, "..\\..\\GetFirmVersion\\Debug\\GetFirmVersion.exe %s", argv[3]);
	if (system(szInputBuf) == 0)
	{
		printf("\n\n\ntest success\n\n\n");
	}
	else
	{
		printf("\n\n\ntest error!\n\n\n");
		return -1;
	}
	
	printf("\nset system info\n");
	sprintf(szInputBuf, "..\\..\\SystemInfo\\Debug\\SystemInfo.exe %s %s %s %s <SystemInfo_Set_In", argv[1], argv[2], argv[4], argv[5]);
 	if (system(szInputBuf) == 0)
	{
		printf("\n\n\ntest success\n\n\n");
	}
	else
	{
		printf("\n\n\ntest error!\n\n\n");
		return -1;
	}

#ifdef _WIN32
	Sleep(3000);
#else
	sleep(3);
#endif


	printf("\ntest Upgrade Firmware\n");
	sprintf(szInputBuf, "..\\..\\Upgrade\\Debug\\Upgrade.exe %s %s %s %s %s", argv[1], argv[2], argv[3], argv[4], argv[5]);
	if (system(szInputBuf) == 0)
	{
		printf("\n\n\ntest success\n\n\n");
	}
	else
	{
		printf("\n\n\ntest error!\n\n\n");
		return -1;
	}
#ifdef _WIN32
	Sleep(5000);
#else
	sleep(5);
#endif

	if (strncmp(argv[4], "-TVS", 4) != 0)
	{
		printf("\ntest Get and Set Motion Detection\n");
		sprintf(szInputBuf, "..\\..\\MotionDetection\\Debug\\MotionDetection.exe %s %s %s <Motiondetection_In", argv[1], argv[2], argv[5]);
		if (system(szInputBuf) == 0)
		{
			printf("\n\n\ntest success\n\n\n");
		}
		else
		{
			printf("\n\n\ntest error!\n\n\n");
			return -1;
		}
	}

	printf("\ntest DIDO\n");
	sprintf(szInputBuf, "..\\..\\DIDO\\Debug\\DIDO.exe %s %s %s %s <DIDO_In", argv[1], argv[2], argv[4], argv[5]);
	if (system(szInputBuf) == 0)
	{
		printf("\n\n\ntest success\n\n\n");
	}
	else
	{
		printf("\n\n\ntest error!\n\n\n");
		return -1;
	}

	printf("\ntest HTTP Operation POST\n");
	if (strncmp(argv[4], "-TIP", 4) == 0)
		sprintf(szInputBuf, "..\\..\\HttpOperation\\Debug\\HttpOperation.exe %s %s %s %s -C/setup/system.cgi?zone=3 -O", argv[1], argv[2], argv[4], argv[5]);
	else 
		sprintf(szInputBuf, "..\\..\\HttpOperation\\Debug\\HttpOperation.exe %s %s %s %s -C/cgi-bin/setdo.cgi?do1=C", argv[1], argv[2], argv[4], argv[5]);

	if (system(szInputBuf) == 0)
	{
		printf("\n\n\ntest success\n\n\n");
	}
	else
	{
		printf("\n\n\ntest error!\n\n\n");
		return -1;
	}

	printf("\ntest HTTP Operation GET\n");
	sprintf(szInputBuf, "..\\..\\HttpOperation\\Debug\\HttpOperation.exe %s %s %s %s -C/cgi-bin/getdi.cgi -R", argv[1], argv[2], argv[4], argv[5]);
	if (system(szInputBuf) == 0)
	{
		printf("\n\n\ntest success\n\n\n");
	}
	else
	{
		printf("\n\n\ntest error!\n\n\n");
		return -1;
	}

	if (strncmp(argv[4], "-TVS", 4) == 0)
	{
		printf("\ntest UART for write\n");
		sprintf(szInputBuf, "..\\..\\UART\\Debug\\UART.exe %s %s %s %s %s", argv[1], argv[2], argv[3], argv[4], argv[5]);
		if (system(szInputBuf) == 0)
		{
			printf("\n\n\ntest success\n\n\n");
		}
		else
		{
			printf("test error!\n\n\n");
			return -1;
		}
	}
	
	if (strncmp(argv[4], "-TPT", 4) == 0)
	{
		printf("\ntest PTCommands\n");
		sprintf(szInputBuf, "%s %s %s %s %s <PTCommand_In", argv[1], argv[2], argv[3], argv[4], argv[5]);
		
		if (PTTest(szInputBuf) == 0)
		{
			printf("\n\n\ntest success\n\n\n");
		}
		else
		{
			printf("\n\n\ntest error!\n\n\n");
			return -1;
		}
	}

	if (strncmp(argv[4], "-TPZ", 4) == 0)
	{
		printf("\ntest PTZCommands\n");
		sprintf(szInputBuf, "%s %s %s %s %s ", argv[1], argv[2], argv[3], argv[4], argv[5]);
		if (PTZTest(szInputBuf) == 0)
		{
			printf("\n\n\ntest success\n\n\n");
		}
		else
		{
			printf("\n\n\ntest error!\n\n\n");
			return -1;
		}
	}
	
	return 0;
}

int PTZTest(char *szBuf)
{
	FILE *pFile;
	char szTempBuf[256];
	int i;
	pFile = fopen("PTZ", "w+t");
	
	if (pFile == NULL)
	{
		printf("file open error!\n");
		return -1;
	}
	
	for (i = 0; i < 16; i++)
	{
		rewind(pFile);
		if (i >= 10)
			putc(i+55, pFile);
		else
			putc(i+49, pFile);
		fflush(pFile);
		sprintf(szTempBuf, "..\\..\\PTZCommand\\Debug\\PTZCommand.exe %s <PTZ", szBuf);
 		if (system(szTempBuf) != 0)
		{
			fclose(pFile);
			return -1;
		};
#ifdef _WIN32
		Sleep(1000);
#else
		sleep(1);
#endif
	}

	fclose(pFile);
	remove("PTZ");

	return 0;
}
	 
int PTTest(char *szBuf)
{
	FILE *pFile;
	char szTempBuf[256];
	int i;
	pFile = fopen("PT", "w+t");

	if (pFile == NULL)
	{
		printf("file open error!\n");
		return -1;
	}

	for (i = 0; i < 16; i++)
	{
		if (i == 6)
		{
			i = 11;
			continue;
		}
		rewind(pFile);
		if (i >= 10)
			putc(i+55, pFile);
		else
			putc(i+49, pFile);
		fflush(pFile);
		sprintf(szTempBuf, "..\\..\\PTZCommand\\Debug\\PTZCommand.exe %s <PT", szBuf);
 		if (system(szTempBuf) != 0)
		{
			fclose(pFile);
			return -1;
		};
#ifdef _WIN32
		Sleep(1000);
#else
		sleep(1);
#endif
	}

	fclose(pFile);
	remove("PT");

	return 0;
}
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -