示例#1
0
文件: utils.cpp 项目: Lenskiy/ICUIM
VideoCommunication::VideoCommunication(unsigned short port_send, unsigned short port_recv, const std::string ip_address):roi(this),compress(this),block_length(0),contBlock(0){
    socket_to_send = 0;
    socket_to_recv = 0;
    curBeginning = 0;
    numOfPackRecv = 0;
    numOfBlocksPerFrame = 0;
    nextFrameBlock = 0;
    
    if(ip_address.length() > 0)
        networkInit(port_recv, port_send, ip_address);
    else
        networkInit(port_recv, port_send, "127.0.0.1");//10.72.51.86 //10.72.51.103 maxim
}
示例#2
0
int configRead(const char *path, unsigned int what) {
	FILE *fp;
	char command[64], arg1[128], arg2[128], buff[512];

	*config->parse_buf = 0;
	if (what == CONFIG_ALL)
		networkInit();

	if ((fp = fopen(path, "r")) == NULL) {
		fprintf(stderr, "[CONFIG] Unable to open configuration file %s. We're doomed\n", path);
		return -1;
	}

	while (!feof(fp)) {
		*buff = 0;
		*command = 0;
		*arg1 = 0;
		*arg2 = 0;

		fgets(buff, 512, fp);
		sscanf(buff, "%s %s %s\n", command, arg1, arg2);
		configProcess(command, arg1, arg2, what);
	}

	return 0;
}
示例#3
0
int main()
{
	int i,result;
	fd_set readfds;
	struct timeval tv;
	printf("Initializing OSIP\n");
	TRACE_INITIALIZE(END_TRACE_LEVEL,NULL);
	if(networkInit() < 0){
		printf("ERROR Initializing NETWORK\n");
		return -1;
	}
	i=osip_init(&osip);
	if (i!=0)
		return -1;
	printf("Setting Callbacks\n");
	setCallbacks(osip);
	printf("Entering Main loop 1\n");
	OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"Check OSIP_TRACE init\n"));
	bSipRegister("This is Test Cookie");
	while(1){
		FD_ZERO(&readfds);
		FD_SET(sipSock,&readfds);
		tv.tv_sec = 0;
		tv.tv_usec = 100000;
		result = select(FD_SETSIZE,&readfds,0,0,&tv);
		if(result < 0){
			perror("main: select error");
			exit(1);
		}
		if(FD_ISSET(sipSock,&readfds)){
			printf("main: Received SIP message\n");
			processSipMsg();
		}
		osip_ict_execute(osip);
		osip_ist_execute(osip);
		osip_nict_execute(osip);
		osip_nist_execute(osip);
		osip_timers_ict_execute(osip);
		osip_timers_ist_execute(osip);
		osip_timers_nict_execute(osip);
		osip_timers_nist_execute(osip);
	}
	return 0;
}
示例#4
0
/*****************************************************************************
 * c_entry: this is our main() function, called from boot_prot.S
 *
 * RETURNS: None
 */
__attribute__((regparm(0))) void c_entry (void)
{
	xTaskHandle xHandle;
	UINT8   	i=0,bFlag = 0;
    UINT16		port, baud = 0;
    NV_RW_Data	nvdata;
#ifdef INCLUDE_DEBUG_VGA
    char achBuffer[80];
#endif
    

#if 0 /* Not used, HAL no longer present */

	/*
	 * Register the local service provider now, as code will be using BIT
	 * services for PCI accesses.
	 */

	cctRegisterServiceProvider (cctServiceProvider);
#endif

	/*
	 * Key sub-system initialisation
	 */

	sysMmuInitialize ();				/* Initialise the local page table management */
	sysInitMalloc (K_HEAP, U_HEAP);		/* Initialise the heap management */

#ifdef INCLUDE_EXCEPTION_DEBUG
	dbgInstallExceptionHandlers();
#endif

#ifdef INCLUDE_DBGLOG	
	dbgLogInit();
#endif

	/*Initialise the mutexes so that we can start using the public functions*/
	for(i=0; i < MAX_CUTEBIT_MUTEX; i++)
	{
		globalMutexPool[i]=xSemaphoreCreateMutex();

		if( globalMutexPool[i] == NULL )
		{
			/*We should not get here, die...*/
			while(1);
		}
	}

	/*
	 * Search and parse BIOS_INFO and  EXTENDED_INFO structures
	 */
	board_service(SERVICE__BRD_GET_BIOS_INFO,     NULL, &dBiosInfo_addr);
	board_service(SERVICE__BRD_GET_EXTENDED_INFO, NULL, NULL);


	/*
	 * Open/close the debug channel and sign-on - we can't use vDebugWrite() this
	 * early, so make direct calls to sysDebug...
	 */
	if(bStartupDebugMode())
	{
		sysDebugWriteString ("\n[Debugging Enabled]\n");
		
		if(sysIsDebugopen())
		{
			if(board_service(SERVICE__BRD_GET_FORCE_DEBUG_OFF, NULL, NULL) == E__OK)
			{	
				sysDebugWriteString ("[Debugging Forced Off]\n");
				sysDebugClose();
			}
		}
	}
	else if( board_service(SERVICE__BRD_GET_FORCE_DEBUG_ON, NULL, NULL) == E__OK )
	{
		sysDebugWriteString ("[Debugging Forced On]\n");
		bForceStartupDebugMode();
		sysDebugOpen();
	}
	
	sysDebugFlush ();
	
#ifdef INCLUDE_DEBUG_VGA
	vgaDisplayInit();
	vgaSetCursor( CURSOR_OFF );
#endif

	sysDebugWriteString ("Starting HW Initialization\n");
	board_service(SERVICE__BRD_HARDWARE_INIT, NULL, NULL); /* board-specific H/W initialisation */

	if(board_service(SERVICE__BRD_GET_CONSOLE_PORT, NULL, &port) == E__OK)
	{
		baud = bGetBaudRate();
		//baud = 0; //hard coded by Rajan. Need to remove after debug
		sysSccInit (port, baud);
		
#ifdef INCLUDE_DEBUG_VGA
		sprintf( achBuffer, "Console open, port: 0x%x baud: %u\n", port, baud );
		vgaPutsXY( 0, startLine++, achBuffer );
		
#endif
	}

	if(board_service(SERVICE__BRD_GET_DEBUG_PORT, NULL, &port) == E__OK)
	{

//#ifdef commented by Rajan. Need to uncomment after debug
//#ifdef INCLUDE_DEBUG_PORT_INIT
			baud = bGetBaudRate();
            baud = 0; //hard coded by Rajan. Need to remove after debug
			sysSccInit (port, baud);
//#endif

#ifdef INCLUDE_DEBUG_VGA			
			sprintf( achBuffer, "Debug %s,   port: 0x%x baud: %u\n", 
						(sysIsDebugopen()? "open":"closed"), port, baud );
			vgaPutsXY( 0, startLine++, achBuffer );
#endif		
	}


#ifdef INCLUDE_MAIN_DEBUG
	{	
		UINT32 temp = 0;
		
		board_service(SERVICE__BRD_GET_MAX_DRAM_BELOW_4GB, NULL, &temp);
		DBLOG( "Max DRAM below 4GB: 0x%08x\n", temp );
	}
#endif

#if	defined(MAKE_CUTE) || defined (MAKE_BIT_CUTE)
	#if defined(VPX)
		vpxPreInit();
	#endif

	#if defined(CPCI)
		board_service(SERVICE__BRD_CHECK_CPCI_IS_SYSCON,NULL,&bFlag);
		cpciPreInit(bFlag);
	#endif

	board_service(SERVICE__BRD_CONFIGURE_VXS_NT_PORTS, NULL, NULL);
#endif

#if defined (SRIO)

	sysDebugWriteString ("Initializing: SRIO\n");
	
	for (i = 1 ; i < MAX_TSI721_DEVS; i++)
	{
	   srioPreInit (i);
	}

#endif

#ifndef CPCI
	if (!bFlag)
		vDelay(2000);// delay added, so pmc160 will show up!
#endif

	sysDebugWriteString ("Initializing: PCI\n");
	sysPciInitialize ();		/* (re)scan PCI and allocate resources */

	sysDebugWriteString ("Rajan--> Step1\n");


#if	defined(MAKE_CUTE) || defined (MAKE_BIT_CUTE)
	#if defined (VME) && defined (INCLUDE_LWIP_SMC)
		// pci bus enumeration must have been run
		InitialiseVMEDevice();
	#endif
#endif

	sysDebugWriteString ("Rajan--> Step2\n");


#ifdef INCLUDE_DEBUG_VGA
	vgaPutsXY( 0, startLine, "FreeRTOS starting....\n\n" );
	startLine += 2;
#endif

	board_service(SERVICE__BRD_POST_SCAN_INIT, NULL, NULL); // post scan H/W initialisations
	board_service(SERVICE__BRD_ENABLE_SMIC_LPC_IOWINDOW, NULL, NULL); /* board-specific smic Initialization */
	/*
	 * Having got this far, clear the load error that we've been holding in CMOS
	 */
	nvdata.dNvToken = NV__TEST_NUMBER;
	nvdata.dData    = 0;
	board_service(SERVICE__BRD_NV_WRITE, NULL, &nvdata);

	nvdata.dNvToken = NV__ERROR_CODE;
	nvdata.dData    = E__BOARD_HANG;
	board_service(SERVICE__BRD_NV_WRITE, NULL, &nvdata);

	
#ifdef INCLUDE_MAIN_DEBUG
	DBLOG( "CUTE/BIT Kernel heap: 0x%08x-0x%08x\n", (UINT32)K_HEAP, ((UINT32)K_HEAP + HEAP_SIZE - 1) );
	DBLOG( "CUTE/BIT User heap  : 0x%08x-0x%08x\n", (UINT32)U_HEAP, ((UINT32)U_HEAP + HEAP_SIZE - 1) );
	
	xPortGetFreeHeapSize();
#endif

	
	/* Initialise task data */
	vTaskDataInit( bCpuCount );
	
	/* Initialise PCI shared interrupt handling */
	pciIntInit();

#ifdef INCLUDE_MAIN_DEBUG	
	pciListDevs( 0 );
#endif
	
	/* Create and start the network */
	sysDebugWriteString ("Initializing: Network\n");
	networkInit();

#if defined(SRIO)
	sysDebugWriteString ("Initializing: TSI721\n");
	
	for (i = 1 ; i < MAX_TSI721_DEVS; i++)
	{
		tsi721_init(i);
	}

	rio_init_mports();
	
#endif

	// some boards may not reset the RTC cleanly
	board_service(SERVICE__BRD_INIT_RTC, NULL, NULL);

#ifdef INCLUDE_DEMO_TASKS
	
	randMutex = xSemaphoreCreateMutex();
	if (randMutex == NULL)
	{
		sysDebugWriteString ("Error - Failed to create rand mutex\n");
	}
	else
	{
		for (i = 0; i < bCpuConfigured; i++)
		{
			tParam[i].taskNum = i + 1;
			sprintf( tParam[i].taskName, "Demo%u", tParam[i].taskNum );
			xTaskCreate( i, vTaskCodePeriodic, tParam[i].taskName, mainDEMO_STACK_SIZE, 
						&tParam[i],	mainDEMO_TASK_PRIORITY, &xHandle );
		}
		
		tParam[i].taskNum = i + 1;
		sprintf( tParam[i].taskName, "BKGRD" );	
		xTaskCreate( 0, vTaskCodeBackground, tParam[i].taskName, mainDEMO_STACK_SIZE, 
						&tParam[i],	mainDEMO_TASK_PRIORITY+1, &xHandle );
	}						
#endif

	sysDebugWriteString ("Creating CUTE task\n");
	xTaskCreate( 0, startCuteBit, "CuteBitTask", mainCUTEBIT_TASK_STACKSIZE,
			NULL, mainCUTEBIT_TASK_PRIORITY, &xHandle );

#ifdef INCLUDE_MAIN_DEBUG
	sysDebugWriteString ("\n[Starting FreeRtos Scheduler]\n");
	sysDebugFlush ();
#endif


	sysInvalidateTLB();

	/* Start the FreeRTOS Scheduler, does not return */
	vTaskStartScheduler();

} /* c_entry () */