Beispiel #1
0
void main(void)
{
    static FILE_DATA far *config;
    int i;
    char sItem1[20];
    char sItem2[20];
    char sItem3[20];
    char sItem4[20];
    char sTemp[40];
      
    unsigned long lPointer=0;
    int iTh;    // iThe: to find information from ?th * in the text file
    
    InitLib();
    
    config=GetFileInfoByName("config_1.ini");   // Opens one file by name
    
    while(lPointer<config->size) 
    {
        lPointer=FSeek(config, '*', lPointer, 1);
        if(lPointer)    // cannot find '*'
        {
            sscanf(config->addr+lPointer, "%s %s %s %s", &sItem1, &sItem2, &sItem3, &sItem4); 
            sprintf(sTemp, "Item1=%s Item2=%s Item3=%s Item4=%s", sItem1, sItem2, sItem3, sItem4);
            Print("%s\n\r", sTemp);
        }   
        else
            break;
    }
}
Beispiel #2
0
void main(void)
{
    int seg, data;
    char c;
    unsigned e=0x9000,i=0;
    
    InitLib();
    
    Print("\r\nPlease Input a value writting to segment 0x9000 of Flash Member: ");
    Scanf("%d", &seg);
    
    FlashErase(e);
    while(i<65535)
    {
        FlashWrite(e, i, seg);
        Print("\r\nThe value %d is writting to offset %d of Flash Memory", seg, i);
        i++;
        seg++;
        if(i%100==0)
        {
            Print("\r\nPress q to quit or any key to continue...");
            c=Getch();
            if ((c=='q') || (c=='Q'))
                return;
        }
    }
}
Beispiel #3
0
void main(void)
{
    unsigned char InBuf[20];   
    
    InitLib();
    
    //Step 1:
    InstallCom_2(115200L, 8, 0, 0); //(Baudrate, Data bit, Parity bit, Stop bit)
    
    //Step 2:
    SendCmdTo7000(2, "$01M", 0); 
        /*
        COM2, Command="$AAM" which AA=01, Checksum=disabled
        
        For example: command="$01M" ===> Gets module name at address 01.
        For detailed command sets, refer to 
            CD:Napdos\DCON\IO_Module\87k_modules.htm or 
            CD:Napdos\7000\Manual\ 
        */
        
    //Step 3:
    ReceiveResponseFrom7000_ms(2, InBuf, 100, 0); 
        /*
        COM2, 
        Put received data to InBuf
        Timeout=100 ms
        Checksum=disabled
        */ 
    
    //Step 4:
    Print("InBuf=%s", InBuf);
        
    //Step 5:
    RestoreCom2();
}
Beispiel #4
0
bool Engine::Initialize(cas::Settings* new_settings)
{
	if(initialized)
		return false;

	cas::Settings settings;
	settings.input = &std::cin;
	settings.output = &std::cout;
	if(new_settings)
		settings = *new_settings;
	if(settings.use_assert_handler)
		set_assert_handler(AssertEventHandler);
	if(settings.use_logger_handler)
		logger = new EventLogger;
	else
		logger = new NullLogger;

	core_module = new Module(0, "Core");
	all_modules.push_back(core_module);

	have_errors = false;
	InitLib(*core_module, settings);
	if(have_errors)
	{
		delete core_module;
		return false;
	}

	Decompiler::Get().Init(settings);

	initialized = true;
	return true;
}
Beispiel #5
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();
}
//----------------------------
   virtual void Pause(){
      if(inited){
#ifdef USE_OPTIONAL_POSITIONING
         InitLib();
         if(mca_Pause){
#ifdef _DEBUG
            (plr->*mca_Pause)();
#else
            mca_Pause(plr);
#endif
         }
#else
         plr->Pause();
#endif
      }
   }
Beispiel #7
0
void main(void)
{ 
    int iType, iVer;
    
    InitLib();
    
    iType=Is7186e();
    
    if(iType)
    {
        iVer=GetLibVersion();
        Print("Hello uPAC-7186EX! (Flash memory is %d K)\r\n", iType);
        Print("Library version is %d.%02d\r\n", iVer>>8, iVer&0xff);
    }
    else
    {
   virtual void SetPlayPos(dword pos){
      if(inited){
         TTimeIntervalMicroSeconds p(TUint(pos*1000));
#ifdef USE_OPTIONAL_POSITIONING
         InitLib();
         if(mca_SetPosition){
#ifdef _DEBUG
            (plr->*mca_SetPosition)(p);
#else
            mca_SetPosition(plr, p);
#endif
         }
#else
         plr->SetPosition(p);
#endif
      }
   }
Beispiel #9
0
//find and initialize the movie libraries
void CMovieManager::InitLibs (void)
{
	int bRobotMovie;

m_nLibs = 0;

int j = (m_bHaveExtras = !gameStates.app.bNostalgia) 
		  ? N_BUILTIN_MOVIE_LIBS 
		  : FIRST_EXTRA_MOVIE_LIB;

for (int i = 0; i < j; i++) {
	bRobotMovie = !strnicmp (pszMovieLibs [i], "robot", 5);
	InitLib (pszMovieLibs [i], m_nLibs, bRobotMovie, 1);
	if (m_libs [m_nLibs].m_nMovies) {
		m_nLibs++;
		PrintLog ("   found movie lib '%s'\n", pszMovieLibs [i]);
		}
	else if ((i >= FIRST_EXTRA_MOVIE_LIB) && (i < FIRST_EXTRA_MOVIE_LIB + N_EXTRA_MOVIE_LIBS))
		m_bHaveExtras = 0;
	}

m_libs [EXTRA_ROBOT_LIB].m_nMovies = 0;
}
Beispiel #10
0
int main(int argc, char* argv[])
{
    if(argc < 4)
    {
        printf("Usage:%s etc_fn server_id log_fn\n", argv[0]);
        return -1;
    }

    //命令行参数,依次为: 配置文件路径,server_id,日志文件路径名
    const char* pszEtcFn = argv[1];
    uint16_t nServerId = SERVER_LOG;
    const char* pszLogPath = argv[3];

    signal(SIGPIPE, SIG_IGN);
	//curl_global_init(CURL_GLOBAL_ALL);
    CDebug::Init();
    InitLib();

    //printf("%d\n", mysql_thread_safe() );
    {
        MYSQL* dummy = mysql_init(NULL);
        mysql_close(dummy);
    }

    g_logger_mutex = new pthread_mutex_t;

    if(!g_pluto_recvlist.InitMutex() || !g_pluto_sendlist.InitMutex() || !g_worldOther.InitMutex()
        || pthread_mutex_init(g_logger_mutex, NULL) != 0 )
    {
        printf("pthead_mutext_t init error:%d,%s\n", errno, strerror(errno));
        return -1;
    }

    g_logger.SetLogPath(pszLogPath);
    CWorldOther& world = g_worldOther;
    int nRet = world.init(pszEtcFn);
    if(nRet != 0)
    {
        printf("CWorldLog init error:%d\n", nRet);
        return nRet;
    }

    COtherServer s;
    s.SetMailboxId(nServerId);
    s.SetWorld(&world);
    world.SetServer(&s);

    vector<pthread_t> pid_list;

	int ret = create_threads(pid_list);
	if ( 0 != ret)
	{
		return ret;
	}
	
    signal(SIGALRM, SigHandler);

    uint16_t unPort = world.GetServerPort(nServerId);
	////初始化线程池以及相关的多线程的检查
	//InitThreadPool();
    
	s.Service("", unPort);

	//处理完了所有的包后再关闭线程池
	//DestroyThreadPool();

	for(size_t i = 0; i < pid_list.size(); ++i)
    {
        if(pthread_join(pid_list[i], NULL) != 0)
        {           
            return -3;
        }
    }

}
Beispiel #11
0
void main(void)
{
    int iRet, iAddress, iChannel, iComPort, iTimeout, iCheckSum;
    unsigned long lBaudrate;
    unsigned char cTemp[10];
    int iDataFormat, iDataFormat_Original;
    int iFilter, iFilter_Original;
    int iRangeCode, iRangeCode_Original;
    
    float fValue;
             
    InitLib();    
    
    Print("********************************\r\n");
    Print("*  7K87K_AI demo for Com Port  *\r\n");
    Print("*                              *\r\n");
    Print("*        [Oct 30, 2008]        *\r\n");
    Print("********************************\r\n");
    Print("\r\n");
    
    Print("Please Input ComPort Number:");
    LineInput(cTemp, 10);               
    sscanf(cTemp, "%d", &iComPort);  
        
    Print("Please Input ComPort's Baudrate:");
    LineInput(cTemp, 10);
    sscanf(cTemp, "%ld", &lBaudrate);
    
    Print("Please Select Checksum(0:Disable or 1:Enable):");
    LineInput(cTemp, 10);
    sscanf(cTemp, "%d", &iCheckSum);

    Print("Please Input module's address(0~255) =");
    LineInput(cTemp, 10);
    sscanf(cTemp, "%d", &iAddress);
    
    Print("Please Input Timeout:");
    LineInput(cTemp, 10);
    sscanf(cTemp, "%d", &iTimeout);
    
    InstallCom(iComPort, lBaudrate, 8, 0, 1); 
    iFilter=0;      // 0: 60Hz    
        
    iDataFormat=0;  //0: Engineering units
    
    iRangeCode=0x08;    //7017/87017:Range code 08(-10V to +10V)
     
    //To prevent reading EEPROM again.
    iRet=Read7K87KAI_Config(iComPort,
                            iAddress,
                            iCheckSum,
                            iTimeout,
                            &iRangeCode_Original,
                            &iFilter_Original,
                            &iDataFormat_Original);
    
    if(iRet==NoError)
    {
        if((iRangeCode_Original==iRangeCode) 
           && (iFilter_Original==iFilter) 
           && (iDataFormat_Original==iDataFormat))
        {
            // The original configuration is the same as the input configuration.
            // So there is no need to write into the EEPROM.
        }  
        else
        {
            Set7K87KAI_Config(iComPort, iAddress, iCheckSum, iTimeout, iRangeCode, iFilter, iDataFormat);  
        }
    }
    else
        Print("Read Configuration Error\r\n");

    for(;;)
    {    
        for(iChannel=0; iChannel<=7; iChannel++)
        {
            iRet=Read7K87K_AI(iComPort, iAddress, iChannel, iCheckSum, iTimeout, &fValue);
            if(iRet==NoError)
            {
                Print("Ch%d=%6.3f\n\r", iChannel, fValue);
            }
            else
            {
                Print("Read AI_%d error!!! Error Code =%d\r\n", iChannel, iRet);
            }
        }
        Print("\r\n");
    }
}
Beispiel #12
0
void CMovieManager::InitExtraRobotLib (char* filename)
{
m_libs [EXTRA_ROBOT_LIB].Destroy ();
InitLib (filename, EXTRA_ROBOT_LIB, 1, 0);
}