示例#1
0
static int autofs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                        off_t offset, struct fuse_file_info *fi)
{
    DBPRINTF("autofs_readdir %s\n", path);

    shared_data *sd = get_sd();

    ReqListdir req_listdir;
    req_listdir.set_dirpath(path);
    send_packet(sd->sock, REQ_LISTDIR, &req_listdir);

    RespListdir rl;
    if (recv_packet(sd->sock, &rl) != ERR_NONE) {
        return -ENOENT;
    }

    filler(buf, ".", NULL, 0);
    filler(buf, "..", NULL, 0);

    for (int i = 0; i < rl.entries_size(); i++) {
        const RespListdir::ListdirEntry &entry = rl.entries(i);
        DBPRINTF("Reading entry %d (%s)\n", i, entry.filename().c_str());
        filler(buf, entry.filename().c_str(), NULL, 0);
    }

    return 0;
}
示例#2
0
int main(int argc, char** argv) {
        //DDPCONbits.JTAGEN = 0; // Disable JTAG
        mPORTGSetPinsDigitalIn(0x00FF);
	mPORTBSetPinsAnalogIn(0x00FF);             //Enable all analog

	SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
	CloseADC10();
	SetChanADC10(INITCH);
	OpenADC10(CONFIG1, CONFIG2, CONFIG3, CFGPORT, CFGSCAN);
	ConfigIntADC10(CFGINT);
	EnableADC10();

   	//Initialize the DB_UTILS IO channel
	DBINIT();

	// Display the introduction
	DBPRINTF("Welcome to the Analog Input Test.\n");
	DBPRINTF("The build date and time is (" __DATE__ "," __TIME__ ")\n");

	while (1){
		 //Get damper value from PIC analog input
		int i = 0;
		for(i;i<1;i++){
			int analog = ReadADC10(i);
			DBPRINTF("Hammer %d = %d", i, analog);
			DBPRINTF("\n");
		}
                int digital = mPORTGReadBits(BIT_0);
                DBPRINTF("digital: %X \n \n", digital );
	}
	return 0;
}
示例#3
0
//because the minmize interval on linux is 10ms, use it when need
//it maybe not exatctly
void CalibrationTimeBaseValue(void)
{
	int i, j, k=0;
    	struct timeval tv;
    	struct timezone tz;
    	unsigned int s_msec, e_msec;
    	int DelayTimes=200*1000;
	
	gettimeofday(&tv, &tz);
    	s_msec = tv.tv_sec*1000*1000 + tv.tv_usec;
    
    	for (i=0; i<DelayTimes; i++)
		for(j=0; j<BASELOOPTESTCNT; j++) k++; 
	
    	gettimeofday(&tv, &tz);
    	e_msec = tv.tv_sec*1000*1000 + tv.tv_usec;
    
    	DBPRINTF("DELAY US=%d BASECNT=%f\n", e_msec-s_msec, ((float)DelayTimes/(e_msec-s_msec))*BASELOOPTESTCNT);    
    	BASELOOPTESTCNT=(int)(((float)DelayTimes/(e_msec-s_msec))*BASELOOPTESTCNT+1);
    
	#if 0
    	gettimeofday(&tv, &tz);
    	s_msec = tv.tv_sec*1000*1000 + tv.tv_usec;
 
    	DelayUS(1000*1000);
    
    	gettimeofday(&tv, &tz);    
    	e_msec = tv.tv_sec*1000*1000 + tv.tv_usec;
    
	DBPRINTF("DELAY US=%d\n", e_msec-s_msec);    
	#endif    
}
示例#4
0
int main(void){
        mPORTASetPinsDigitalIn(0xFFFF);
	mPORTBSetPinsAnalogIn(0xFFFF);             //Enable all analog

	SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
	CloseADC10();
	SetChanADC10(INITCH);
	OpenADC10(CONFIG1, CONFIG2, CONFIG3, CFGPORT, CFGSCAN);
	ConfigIntADC10(CFGINT);
	EnableADC10();

   	//Initialize the DB_UTILS IO channel
	DBINIT();

	// Display the introduction
	DBPRINTF("Welcome to the Analog Input Test.\n");
	DBPRINTF("The build date and time is (" __DATE__ "," __TIME__ ")\n");

	while (1){
		 //Get damper value from PIC analog input
		int i = 0;
		for(i;i<16;i++){
			int damper = ReadADC10(i);
			DBPRINTF("Damper %d = %d", i, damper);
			DBPRINTF("\n");
		}

            //DBPRINTF("%d \n", LATA );
	}
	return 0;
}
示例#5
0
void heapReport(void)
{
#if DEBUG_HEAP

	int Heap;

	OBJ_HEAP *psHeap;

	DBPRINTF(("\nheapReport\n==========\n"));

	for (Heap=0;Heap<MAXDEBUGHEAPS;Heap++)
	{
		if (HeapDebugList[Heap] != NULL)
		{
			psHeap=HeapDebugList[Heap];
			DBPRINTF(("Heap: %s, line %d size=%d mem taken=%d\n",
				psHeap->pFile, psHeap->line, psHeap->objSize, psHeap->objSize*psHeap->initAlloc));
			
			DBPRINTF((" Current Usage=%d ",psHeap->currUsage));
			
			DBPRINTF((" Max usage %d (Init %d Ext %d)\n",
				psHeap->maxUsage,
				psHeap->initAlloc, psHeap->extAlloc));

		}
	}

#else
#endif

}
示例#6
0
文件: rtc.c 项目: lostsnow/C3-jzl
BOOL ReadRTCClockToSyncSys(TTime *tm)
{
    int fd, retval=0;
    time_t newtime;
    struct timeval tv;
    struct timezone tz;	

    DBPRINTF("before GetExternelRTC  weekday = %d,gCurTime=%d-%d-%d,%d:%d:%d\n",tm->tm_wday,tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
	GetExternelRTC(tm);

    DBPRINTF("after GetExternelRTC weekday = %d,gCurTime= %d-%d-%d,%d:%d:%d\n",tm->tm_wday,tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
/*	 tm->tm_year= 110;
	tm->tm_mon = 1;
	tm->tm_mday= 6;
	tm->tm_hour = 13;
	tm->tm_min = 45;
	tm->tm_sec = 20;    
*/

    DBPRINTF("RetVal=%d Year=%d Month=%d Day=%d Hour=%d Min=%d Sec=%d\n", 
	     retval, tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);    
    if(((tm->tm_year<=70)||(tm->tm_year>=137))||
       ((tm->tm_mon>=12)||(tm->tm_mon<0))||
       ((tm->tm_mday<=0)||(tm->tm_mday>=32))||
       ((tm->tm_hour<0)||(tm->tm_hour>=24))||
       ((tm->tm_min<0)||(tm->tm_min>=60))||
       ((tm->tm_sec<0)||(tm->tm_sec>=60)))
	    retval=-1;
    //Fixed RTC time 
    if((tm->tm_year<=70)||(tm->tm_year>=137)) tm->tm_year=100;
    if((tm->tm_mon>=12)||(tm->tm_mon<0)) tm->tm_mon=0;
    if((tm->tm_mday<=0)||(tm->tm_mday>=32)) tm->tm_mday=1;
    if((tm->tm_hour<0)||(tm->tm_hour>=24)) tm->tm_hour=0;
    if((tm->tm_min<0)||(tm->tm_min>=60)) tm->tm_min=0;
    if((tm->tm_sec<0)||(tm->tm_sec>=60)) tm->tm_sec=0;
#ifndef ZEM500
    if(retval==-1)
    {
	retval=ioctl(fd, RTC_SET_TIME, tm);
    }
    close(fd);
#endif

    tm->tm_isdst=-1;          //don't know whether it's dst   夏令时
    //EncodeTime标准函数mktime
    //mktime可以修正tm_wday, tm_yday的值位于正确范围
    newtime=EncodeTime(tm);
    
    gettimeofday(&tv, &tz);
    
    tv.tv_sec = newtime+1;
    tv.tv_usec = 0;
    
    settimeofday(&tv, &tz);
//    settimeofday(&tv, &tz);
  
  return (retval==0);

}
示例#7
0
void _SYS_ERROR_PRINT(SYS_ERROR_LEVEL level, const char* format, ...)
{
    va_list args;
    if( (level) < SYSTEM_CURRENT_ERROR_LEVEL )
    {
        va_start( args, format );
        DBPRINTF("SYS_ERROR_PRINT: Level: %d ",level);
        DBPRINTF(format,args);
        DBPRINTF("\n");
        asm("break");        va_end( args );
    }
}
示例#8
0
static int autofs_stat(const char *path, struct stat *stbuf) {
    memset(stbuf, 0, sizeof(struct stat));
    stbuf->st_uid = geteuid();
    stbuf->st_gid = getegid();

    shared_data *sd = get_sd();

    ReqStat req_stat;
    req_stat.set_filepath(path);

    // Send request
    if (send_packet(sd->sock, REQ_STAT, &req_stat) < 0) {
        return -EIO;
    }

    DBPRINTF("stat %s\n", path);

    // Get response
    RespStat sr;
    ErrorCode afs_err = recv_packet(sd->sock, &sr);
    if (afs_err != ERR_NONE) {
        return -ENOENT;
    }

    time_t mtime_utc = sr.mtime_utc();
    struct tm *tm_loc = localtime(&mtime_utc);
    time_t mtime_local = mktime(tm_loc);
    stbuf->st_ctime = mtime_local;
    stbuf->st_mtime = mtime_local;
    stbuf->st_atime = mtime_local;

    if (sr.ftype() & S_IFDIR) {
        stbuf->st_mode = S_IFDIR | sr.perms();
        stbuf->st_nlink = sr.size();
        stbuf->st_ino = sr.inode();
        DBPRINTF("result dir\n");
        return 0;
    }
    else if (sr.ftype() & S_IFREG) {
        stbuf->st_mode = S_IFREG | sr.perms();
        stbuf->st_nlink = 1;
        stbuf->st_size = sr.size();
        stbuf->st_ino = sr.inode();

        DBPRINTF("result file, size %lu b\n", sr.size());
        //DBPRINTF("ctime_utc %d, ctime %d, %s", ctime_utc, stbuf->st_ctime, ctime(&ctime_utc));
        return 0;
    }

    DBPRINTF("result NOENT\n");
    return -ENOENT;
}
示例#9
0
//	init the playback buffer
static BOOL setupPlayBuffer(VOID)
{ 
    PCMWAVEFORMAT	pcmwf; 
    HRESULT			hr; 
  
    memset(&pcmwf, 0, sizeof(PCMWAVEFORMAT));									// Set up wave format structure. 
    pcmwf.wf.wFormatTag			= WAVE_FORMAT_PCM; 
    pcmwf.wf.nChannels			= AUDIOCHANNELS; 
    pcmwf.wf.nSamplesPerSec		= SAMPLERATE; 
    pcmwf.wf.nBlockAlign		= (AUDIOCHANNELS * BITSPERSAMPLE) / 8;
    pcmwf.wf.nAvgBytesPerSec	= SAMPLERATE * (BITSPERSAMPLE /8) * AUDIOCHANNELS  ;	//pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign; 
	pcmwf.wBitsPerSample		= BITSPERSAMPLE; 
  
    memset(&playbackBuff, 0, sizeof(DSBUFFERDESC));								// Set up DSBUFFERDESC structure. Zero it out. 
    playbackBuff.dwSize			= sizeof(DSBUFFERDESC); 
    playbackBuff.dwFlags		= DSBCAPS_CTRLFREQUENCY| DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME; //DSBCAPS_CTRLDEFAULT;							// Need default controls (pan, volume, frequency). 
    
    playbackBuff.dwBufferBytes	= SAMPLETIME * pcmwf.wf.nAvgBytesPerSec;		// SAMPLETIME-second buffer. 
    playbackBuff.lpwfxFormat= (LPWAVEFORMATEX)&pcmwf; 
    
    hr = lpDirectSound->lpVtbl->CreateSoundBuffer(lpDirectSound,				// Create buffer. 
        &playbackBuff, &lpDirectSoundBuffer, NULL); 
    
	if(hr != DS_OK)
	{
		DBPRINTF(("NETPLAY: Failed to create playback buffer.\n"));	
		lpDirectSoundBuffer = NULL;												// Failed. 
		return FALSE;
	}
	    
	return TRUE; 
}
示例#10
0
文件: Atlas.c 项目: ddeo/sdp
/**********************************************************************
 * Function: doSetOriginSM
 * @return None
 * @remark Steps into the set origin state machine.
 **********************************************************************/
static void doSetOriginSM() {
    // Waiting for origin message from command center 
    if (event.flags.haveSetOriginMessage) {
        GeocentricCoordinate ecefOrigin;
        ecefOrigin.x = Mavlink_newMessage.gpsGeocentricData.x;
        ecefOrigin.y = Mavlink_newMessage.gpsGeocentricData.y;
        ecefOrigin.z = Mavlink_newMessage.gpsGeocentricData.z;
        Navigation_setOrigin(&ecefOrigin);

        handleAcknowledgement();
        haveOrigin = TRUE;
        event.flags.setOriginDone = TRUE;

        DBPRINT("Set new origin: X=%.1f, Y=%.1f, Z=%.1f\n",
            ecefOrigin.x, ecefOrigin.y, ecefOrigin.z);
    }
    else {
        // Resend request if timer expires
        if (Timer_isExpired(TIMER_SETORIGIN)) {
            // Resend request origin if timed out
            if (resendMessageCount >= RESEND_MESSAGE_LIMIT) {
                // Sent too many times
                setError(ERROR_NO_ORIGIN);
                return;
            }
            else {
                DBPRINTF("Resending origin request.\n");
                Mavlink_sendRequestOrigin(NO_ACK); // just want message
                Timer_new(TIMER_SETORIGIN, RESEND_MESSAGE_DELAY);
                resendMessageCount++;
            }
        } // timer expired
    }
}
示例#11
0
void RS_SendDataPack(serial_driver_t *rs, unsigned char *buf, int len)
{
	U32 etime=GetTickCount();
	DBPRINTF("485 send:%d\n",len);
//// 485收发控制	低电平收,高电平发
	RS485_setmode(TRUE);
	DelayUS(1000);//
	DEBUGTRACE(buf,len);
//	rs->write(0x88);//多发送一个字节,修正485网络干扰
	rs->write_buf(buf,len);
	rs->tcdrain();
	while(rs->get_lsr()!=TIOCSER_TEMT);	//wait for the transmit shift register empty
	DBPRINTF("get_lsr() time:%d\n",GetTickCount()-etime);
//	mmsleep(3*115200/gOptions.RS232BaudRate);
	RS485_setmode(FALSE);
}
示例#12
0
文件: msg.c 项目: lostsnow/C3-jzl
int GatherMsgs(PMsg msg)
{
	mmsleep(10);
	if (EnabledMsg & MSG_TYPE_TIMER)
	{
		TTime t;
		BYTE TimerType;
		GetTime(&t);
		if(t.tm_sec!=gCurTime.tm_sec)
		{
			TimerType = (gCurTime.tm_min == t.tm_min ? Timer_Second : Timer_Minute);
			if ((TimerType == Timer_Minute) && (gCurTime.tm_hour != t.tm_hour))
			{
				TimerType = Timer_Hour;
			}

			if (TimerType == Timer_Hour)
			{
				DBPRINTF("t=%d:%d:%d, gCurTime=%d:%d:%d\n", t.tm_hour,
				           t.tm_min, t.tm_sec, gCurTime.tm_hour, gCurTime.tm_min, gCurTime.tm_sec);

			}

			//printf("get_sec = %d,gcur_sec = %d\n",t.tm_sec,gCurTime.tm_sec);
			ConstructMSG(msg, MSG_TYPE_TIMER,  0, 0);

			memcpy(&gCurTime, &t, sizeof(TTime));
			//GetTime(&gCurTime);
			Timer_count();

			return MSG_TYPE_TIMER;
		}

	}
    //232串口
	if ((gOptions.RS232On || gOptions.RS485On) && (!gOptions.IsSupportModem
			|| !gOptions.IsConnectModem) && (gOptions.CT232On != 2))
	{
		RS232Check(&st232);
	}
    //484串口
	if((gOptions.RS232On||gOptions.RS485On) && gOptions.IsSupportModem)
	{
		RS232Check(&ttl232);
	}

	EthBoradcastCheck();

	EthCommTCPCheck();

	if(1 == shared_Comm_stuff->CreateMainCmd)
	{
		ConstructMSG(msg, shared_Comm_stuff->Cmd,  shared_Comm_stuff->NewsType, (int)shared_Comm_stuff);
		shared_Comm_stuff->CreateMainCmd = 0;

		return shared_Comm_stuff->Cmd;
	}

	return 0;
}
示例#13
0
BOOL StartTransfer( BOOL restart )
{
    I2C_STATUS  status;

    // Send the Start (or Restart) signal
    if(restart)
    {
        I2CRepeatStart(I2C2);
    }
    else
    {
        // Wait for the bus to be idle, then start the transfer
        while( !I2CBusIsIdle(I2C2) );

        if(I2CStart(I2C2) != I2C_SUCCESS)
        {
            DBPRINTF("Error: Bus collision during transfer Start\n");
            return FALSE;
        }
    }

    // Wait for the signal to complete
    do
    {
        status = I2CGetStatus(I2C2);

    } while ( !(status & I2C_START) );

    return TRUE;
}
示例#14
0
//==============================================================================
BOOL i2c_Start(UINT8 restart )
{
    I2C_STATUS  status;

    // Send the Start (or Restart) signal
    if(restart)
    {
        //I2CRepeatStart(EEPROM_I2C_BUS);
        I2C1CONbits.RSEN = 1;
    }
    else
    {
        // Wait for the bus to be idle, then start the transfer
        while( !I2CBusIsIdle(EEPROM_I2C_BUS) );

        if(I2CStart(EEPROM_I2C_BUS) != I2C_SUCCESS)
        {
            DBPRINTF("Error: Bus collision during transfer Start\n");
            return FALSE;
        }
    }

    // Wait for the signal to complete
    do
    {
        status = I2CGetStatus(EEPROM_I2C_BUS);
    } while ( !(status & I2C_START) );


    return TRUE;
}
示例#15
0
/*
	Alex - fixed this so it doesn't try to free up the memory if it got the page from resource
	handler - this is because the resource handler will deal with freeing it, and in all probability
	will have already done so by the time this is called, thus avoiding an 'already freed' moan.
*/
void pie_TexShutDown(void)

{
	int i,j;

	i = 0;
	j = 0;

	while (i < _TEX_INDEX) 
	{
		/*	Only free up the ones that were NOT allocated through resource handler cos they'll already
			be free */
		if(_TEX_PAGE[i].bResource == FALSE)
		{
			if(_TEX_PAGE[i].tex.bmp)
			{
				j++;
				iV_HeapFree(_TEX_PAGE[i].tex.bmp,_TEX_PAGE[i].tex.width * _TEX_PAGE[i].tex.height);
			}
		}
		i++;
	}

	if (pie_GetRenderEngine() == ENGINE_GLIDE)
	{
		free3dfxTexMemory();
	}


	DBPRINTF(("pie_TexShutDown successful - freed %d texture pages\n",j));
}
示例#16
0
static int autofs_read(const char *path, char *buf, size_t size, off_t offset,
                     struct fuse_file_info *fi)
{
    DBPRINTF("read %s\n", path);

    shared_data *sd = get_sd();

    // TODO (max size is 1 MB)
    if (size > 1024*1024*512) {
        fprintf(stderr, "Read is too big!\n");
        exit(1);
    }

    ReqRead req_read;
    req_read.set_filepath(path);
    req_read.set_offset(offset);
    req_read.set_length(size);
    send_packet(sd->sock, REQ_READ, &req_read);

    databuf dbuf;
    if (recv_packet(sd->sock, NULL, &dbuf) != ERR_NONE) {
        return -ENOENT;
    }

    // TODO: keep reading until full
    size_t real_size = dbuf.size();
    memcpy(buf, &dbuf[0], real_size);
    return real_size;
}
示例#17
0
/* for SYS_ASSERT */
void DebugAssert ( bool test, char *message )
{
    if(!test)
    {
        DBPRINTF("%s",message);
        while(true);
    }
}
示例#18
0
文件: helper.c 项目: EQ4/vis
void do_assert(BOOL cond, const char* message, const char* file, int line) {
    if (!cond) {
        do_assert_fail(message, file, line);
    }
#if DEBUG > DEBUG_DEBUG
    else {
        DBPRINTF("Assert passes: %s:%d: %s", file, line, message);
    }
#endif
}
示例#19
0
void SetNetworkIP_MASK(BYTE *ipaddress, BYTE *netmask)
{
	char buffer[128];
	
	sprintf(buffer, "ifconfig eth0 %d.%d.%d.%d netmask %d.%d.%d.%d",
		ipaddress[0], ipaddress[1], ipaddress[2], ipaddress[3],
		netmask[0], netmask[1], netmask[2], netmask[3]);
	system(buffer);
	DBPRINTF("Setup network ip&netmask OK: %s\n",buffer);	
}
示例#20
0
void SetNetIP_MASK(const char *netname, BYTE *ipaddress, BYTE *netmask) //ccc
{
	char buffer[128];
	
	sprintf(buffer, "ifconfig %s %d.%d.%d.%d netmask %d.%d.%d.%d",
		netname,ipaddress[0], ipaddress[1], ipaddress[2], ipaddress[3],
		netmask[0], netmask[1], netmask[2], netmask[3]);
	system(buffer);
	DBPRINTF("Setup network %s ip&netmask OK!\n", netname);	
}
示例#21
0
// FUSE functions
static void *autofs_init(struct fuse_conn_info *conn) {
    shared_data *sd = new shared_data();
    sd->sock = connect("localhost:54321");
    if (sd->sock < 0) {
        fprintf(stderr, "Couldn't connect!\n");
        exit(1);
    }

    DBPRINTF("Connected!\n");
    return sd;
}
示例#22
0
static int autofs_open(const char *path, struct fuse_file_info *fi)
{
    DBPRINTF("open %s (%X)\n", path, fi->flags);

    // TODO: can the following be taken out?
    struct stat st;
    int err = autofs_stat(path, &st);
    if (err != 0) return err;

    // NOTE: on OSX, fuse4x takes care of checking user permissions
    // TODO: check behavior on Linux
    if ((fi->flags & O_ACCMODE) == O_RDONLY) {
        DBPRINTF("opened read only\n");
    }
    else {
        DBPRINTF("opened write\n");
    }

    return 0;
}
示例#23
0
文件: emit.c 项目: EQ4/vis
void dbprintf_emit_desc(emit_desc* e) {
    DBPRINTF("struct *emit_desc* { n=%d, x=%g, y=%g, ux=%g, uy=%g, "
             "rad=%g, urad=%g, life=%d, ulife=%d, ds=%g, uds=%g, "
             "theta=%g, utheta=%g, r=%g, g=%g, b=%g, "
             "ur=%g, ug=%g, ub=%g, force=%d, limit=%d, blender=%d };",
             e->n, e->x, e->y, e->ux, e->uy, e->rad, e->urad,
             e->life, e->ulife, e->ds, e->uds, e->theta, e->utheta,
             (double)e->r, (double)e->g, (double)e->b,
             (double)e->ur, (double)e->ug, (double)e->ub,
             e->force, e->limit, e->blender);
}
示例#24
0
/*****************************************************************************
*	SAMPLE()
*
*	This function reads the digitally sampled voltage and current readings
*	from the MCP3909 via the SPI port
*****************************************************************************/
void SAMPLE()
{
	DBPRINTF("sample....\n");
	/*	
	int		txferSize = 5;
	SpiPkt*	pTxPkt;
	SpiPkt*	pRxPkt;

	pTxPkt=(SpiPkt*)malloc(txferSize*sizeof(long)+2);
	pRxPkt=(SpiPkt*)malloc(txferSize*sizeof(long)+2);

	SpiChnChangeMode(1, 1, 1, 1);		// set slave mode
	SpiChnGetS(1, (unsigned int*)pRxPkt, 1);
	*/

	// get data
	int data;
	data = getcSPI1();
	
	// SpiChnGetS(1, (unsigned int*)cycle_sample_data, num_samples);
	DBPRINTF("SUCCESS!!!! \n");
}
示例#25
0
void SetNetworkPara(BYTE *ipaddress, BYTE *netmask, BYTE *gateway)
{
	char buffer[128];
	int pid, rc;

	memset(buffer,0,sizeof(buffer));
	pid=fork(); 
	if (pid==0)
	{	
		sprintf(buffer, "ifconfig eth0 %d.%d.%d.%d netmask %d.%d.%d.%d",
				ipaddress[0], ipaddress[1], ipaddress[2], ipaddress[3],
				netmask[0], netmask[1], netmask[2], netmask[3]);
		systemEx(buffer);
		//DBPRINTF("Setup network ip&netmask OK!\n");	
		if(gateway[0])
		{
			//ping gateway--clear the cached MAC(ROUTER)
			memset(buffer,0,sizeof(buffer));
			sprintf(buffer, "ping -c 1 %d.%d.%d.%d",
					gateway[0], gateway[1], gateway[2], gateway[3]);
			while(TRUE)
			{
				rc=systemEx(buffer);
				if(rc==EXIT_SUCCESS)
					break;
				else
					sleep(10);
			}
			systemEx("route del default gw 0.0.0.0");
			//setup gateway
			memset(buffer,0,sizeof(buffer));
			sprintf(buffer, "route add default gw %d.%d.%d.%d",
					gateway[0], gateway[1], gateway[2], gateway[3]);
			while(TRUE)
			{
				rc=systemEx(buffer);
				if(rc==EXIT_SUCCESS)
				{
					//			DBPRINTF("Setup network Gateway OK!\n");
					break;
				}
				else
				{
					DBPRINTF("Setup network Gateway failed!\n");
					sleep(30);
				}
			}
		}
		exit(EXIT_SUCCESS);	
	}
}
示例#26
0
int write_phy_reg(unsigned char *dname, unsigned int reg_num, unsigned int reg_val)
{
  int handle;
  struct ifreq ifr;
  unsigned short *data;
  void *tmpdata;

  if ((handle=socket(AF_INET, SOCK_DGRAM, 0)) == -1)
  {
    DBPRINTF("init socket error!\n");
    return -1;
  }

  memset(&ifr, 0, sizeof(ifr));
  strcpy(ifr.ifr_name,(char *) dname);

  if (ioctl(handle, SIOCGMIIREG, &ifr)==-1)
  {
    DBPRINTF("ioctl[SIOCGMIIREG] error!\n");
    close(handle);
    return -1;
  }
  tmpdata= &ifr.ifr_data;
  //data = (unsigned short *)(&ifr.ifr_data); 
  data = (unsigned short *)tmpdata;
  *(data+1) = (unsigned short)(reg_num&0x0000ffff);
  *(data+2) = (unsigned short)(reg_val&0x0000ffff);

  if (ioctl(handle, SIOCSMIIREG, &ifr)==-1)
  {
    DBPRINTF("ioctl[SIOCGMIIREG] error!\n");
    close(handle);
    return -1;
  }

  close(handle);
  return 0;
}
示例#27
0
static int autofs_unlink(const char *path)
{
    DBPRINTF("unlink %s\n", path);

    shared_data *sd = get_sd();
    ReqUnlink req_unlink;
    req_unlink.set_filepath(path);
    send_packet(sd->sock, REQ_UNLINK, &req_unlink);

    if (recv_packet(sd->sock, NULL, NULL) != ERR_NONE) {
        return -EIO;
    }
    return 0;
}
示例#28
0
static int autofs_getattr(const char *path, struct stat *stbuf)
{
    DBPRINTF("autofs_getattr %s\n", path);

    if (strcmp(path, "/") == 0) {
        stbuf->st_uid = geteuid();
        stbuf->st_gid = getegid();
        stbuf->st_mode = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
        return 0;
    }

    return autofs_stat(path, stbuf);
}
示例#29
0
// Adjust st7565 resistor ratio and "volume"
void contrastSetup()
{
    char s[256];
    uint8_t tmp8;

    DBPUTS("Enter resistor ratio (0..7)...");
    DBGETS(s, sizeof(s));
    
    tmp8 = s[0] - '0';   //
    if(tmp8 < 8)
    {
        lcdCmd(cRESISTOR_RATIO | tmp8);
        DBPRINTF("Set to %d.\n", tmp8);
    }
    else
    {
        DBPUTS("Invalid range.\n");
    }

    DBPUTS("Enter volume (0..63)...");
    DBGETS(s, sizeof(s));
    
    tmp8 = atoi(s);   //
    if(tmp8 < 64)
    {
        lcdCmd(cVOLUME);
        lcdCmd(tmp8);
        DBPRINTF("Set to %d.\n", tmp8);
    }
    else
    {
        DBPUTS("Invalid range.\n");
    }

    // Clear the do-user-input flag
    //DoUserUserInputSemaphore = 0;
}
示例#30
0
//open the dsound interface.
static BOOL setupSoundPlay(VOID)
{
	HWND		hwnd;
	HRESULT     hr;

	hwnd = frameGetWinHandle();

	hr =DirectSoundCreate(NULL, &lpDirectSound, NULL);							// create dsound object
	if (hr != DS_OK)
	{
		DBPRINTF(("NETPLAY Failed to create dsound interface.\n"));	
		return (FALSE);
	}

	hr =IDirectSound_SetCooperativeLevel(lpDirectSound, hwnd, DSSCL_PRIORITY);	// Set coop level
	if (hr != DS_OK)
	{
		DBPRINTF(("NETPLAY Failed to create playback buffer..\n"));	
		return (FALSE);
	}

	IDirectSound_Compact(lpDirectSound);										// compact things 
	return (TRUE);
}