Exemplo n.º 1
0
/*******************************************************************************
* Procedure:    rx_task
* Purpose:      Task that processes serial input from Nordic RF chip.
* Passed:
*   
* Returned:     nothing
* Globals:      none
*
* Date:         Author:             Comments:
*   2014-09-19  Neal Shurmantine    initial revision
*******************************************************************************/
void *rx_task(void * param)
{
    int numbytes;
    bool process;
    char ser_rx_buff[1];
    QInit(RECEIVE_SIZE,&RxQueue, RxData);
    URX_WaitTime = NORMAL_RECEIVE_WAIT_TIME;

uint16_t tick_count = 0;
printf("rx_task\n");
    while(1)
    {    
        OS_TaskSleep(URX_WaitTime);
++tick_count;

#ifdef USE_ME
if ((tick_count % 100) == 1) printf(".");
if ((tick_count % 500) == 1) printf("\n");
#endif

        process = false;
        do {
            numbytes = read(nordic_fp, ser_rx_buff, 1);
            if (numbytes != 0) {
printf("%02x ",(uint8_t)ser_rx_buff[0]);
                process = true;
                QInsert(ser_rx_buff[0], &RxQueue);
            }
        } while (numbytes != 0);
        if (process == true) {
            OS_EventSet(ActiveEventHandle,ActiveEventBit);
        }
    }
}
Exemplo n.º 2
0
/*!
 * Called on shutdown, should deallocate memory, etc.
 */
void
shutdown_cell(void)
{
    struct afs_q *cq, *tq;
    struct cell *tc;

#ifdef AFS_CACHE_VNODE_PATH
    if (cacheDiskType != AFS_FCACHE_TYPE_MEM) {
	afs_osi_FreeStr(afs_cellname_inode.ufs);
    }
#endif
    AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");

    for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
	tc = QTOC(cq);
	tq = QNext(cq);
	if (tc->cellName)
	    afs_osi_FreeStr(tc->cellName);
	afs_osi_Free(tc, sizeof(struct cell));
    }
    QInit(&CellLRU);

{
    struct cell_name *cn = afs_cellname_head;

    while (cn) {
	struct cell_name *next = cn->next;

	afs_osi_FreeStr(cn->cellname);
	afs_osi_Free(cn, sizeof(struct cell_name));
	cn = next;
    }
}
}
Exemplo n.º 3
0
void Quaternion_Matrix_Fourier_Transform_ExpLeft_Inv(Quaternion ** QMatrix,Quaternion *** pQMatrixFT,
    Quaternion QMu,int intHeight,int intWidth)
{
	int s,t,S,T;
	Quaternion QExp,QSum;
	double dblFactor,dblQuotient;
	
	dblFactor = 2. * M_PI ;
	dblQuotient = sqrt((double)intHeight*(double)intWidth);
	
	// the frequency image coordinates will be describe
	// by the S and T index.
	// In the spatial image, the pixel will be pointed by the spatial 
	// coordinates s and t.

	for (s=0;s<intHeight;s++)
		for (t=0;t<intWidth;t++)
		{
			QSum = QInit(0.,0.,0.,0.);
			//QDisp(QSum,stdout);  
			for(S=0;S<intHeight;S++)
			{
				for(T=0;T<intWidth;T++)
				{
					QExp = QInitExp(QMu,dblFactor*(S*s/((double)intHeight)+T*t/((double)intWidth)));
					//QDisp(QExp,stdout);
					QSum = QAdd(QSum,QMult(QExp,QMatrix[S][T]));
				}
			}
			(*pQMatrixFT)[s][t].a = QSum.a/dblQuotient;		
			(*pQMatrixFT)[s][t].b = QSum.b/dblQuotient;	//	R(s,t)
			(*pQMatrixFT)[s][t].c = QSum.c/dblQuotient;	//	G(s,t)
			(*pQMatrixFT)[s][t].d = QSum.d/dblQuotient;	//	B(s,t)
		}
}
Exemplo n.º 4
0
STATIC int readTheadr( obj_rec *objr, pobj_state *state ) {

/**/myassert( objr != NULL && objr->command == CMD_THEADR );
/**/myassert( state != NULL && state->pass == POBJ_READ_PASS );
    objr = objr;
    state = state;
    QInit( &libQueue );
    return( 0 );
}
Exemplo n.º 5
0
/*!
 * Perform whatever initialization is necessary.
 */
void
afs_CellInit(void)
{
    AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
    AFS_RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock");
    AFS_RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock");
    QInit(&CellLRU);

    afs_cellindex = 0;
    afs_cellalias_index = 0;
}
Exemplo n.º 6
0
/* afs_InitCBQueue
 *  called to initialize static and global variables associated with
 *  the Callback expiration management mechanism.
 */
void
afs_InitCBQueue(int doLockInit)
{
    register int i;

    memset((char *)cbHashT, 0, CBHTSIZE * sizeof(struct bucket));
    for (i = 0; i < CBHTSIZE; i++) {
	QInit(&(cbHashT[i].head));
	/* Lock_Init(&(cbHashT[i].lock)); only if you want lots of locks, which 
	 * don't seem too useful at present.  */
    }
    base = 0;
    basetime = osi_Time();
    if (doLockInit)
	Lock_Init(&afs_xcbhash);
}
Exemplo n.º 7
0
/*!
 * Perform whatever initialization is necessary.
 */
void
afs_CellInit(void)
{
    static char CellInit_done = 0;

    if (CellInit_done)
	return;

    CellInit_done = 1;

    AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
    AFS_RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock");
    AFS_RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock");
    QInit(&CellLRU);

    afs_cellindex = 0;
    afs_cellalias_index = 0;
}
Exemplo n.º 8
0
int main(int argc, char** argv) {
	char* std;
	QInit();

	consumer[0] = 
		consumer[1] = 
		consumer[2] = 
		consumer[3] = 
			basic_read;

	unsigned it = 0;
	while(consumer[it]) {
		if(fork() == 0) { // consumer number $it
			consumer[it](it);
			exit(0);
		}
		it++;
	}

	// producer from now on
	printf("I am the producer now.\n");
	
	it = 0;
	while(1) {
		usleep(20003);

		char* mesg;
		int shm_key = shmget(IPC_PRIVATE, 100*sizeof(*mesg), IPC_CREAT | 0600);
		mesg = shmat(shm_key, 0, 0);
		snprintf(mesg, 100, "foo %u", it);
		mesg = 0;

		int sent_ok = QSend(it++% MAX_PRIORITY, shm_key);
		printf("sent %s [%d]\n", sent_ok ? "ok" : "failed", shm_key);
		printf("SEND ");
		QPrintQueue();

		shmdt(mesg);
	}
}
Exemplo n.º 9
0
int main_fourier_quaternion(int argc, char *argv[])
{
    double dblQMuRedPart,dblQMuGreenPart,dblQMuBluePart;
    double InvRacine3;
    double seuil;//seuil définissant un masque de module
    int dim[2]={64,64};//dimension de l'image
    
    Quaternion QMu;//Quaternion pur utilisé comme direction de l'analyse de Fourier
    int intNbStripe;//nbre de raies souhaitées apres une IQFT
    //double K=2000.;//cste d'initialisation dans le domaine de Fourier bien pour RGB
    //double K=20.; //K correspondant a la bonne valeur pour Variation couleur Yuv
    
    //Initialisation des paramètres par défaut
    InvRacine3 = 1./sqrt(3.);

    //Différentes valeurs de Mu possibles avec Mu Quaternion unitaire pur
    //QMu = QInit(0.,InvRacine3,InvRacine3,InvRacine3); //Mu luminance
    QMu = QInit(0.,1./1.,0,0); //Mu rouge
    //QMu = QInit(0.,0,1,0); //Mu vert
    //QMu = QInit(0.,0,0,1); //Mu bleu
    //QMu = QInit(0.,1./sqrt(2.),1./sqrt(2.),0); //Mu jaune

    //le seuil pour le masque de module
    seuil = 0.23;

    /*printf("test min max\n");
    printf("test min(30.5,-6,6)=%lf\n",MIN3(30.5,-6,6.));
    printf("test max(30.5,-6,6)=%lf\n",MAX3(30.5,-6,6.));*/


    printf("fichier :%s\t + chaine en argument : %s\n",argv[1],argv[2]);

    Construct_Vues_Frequentielles(argv[1],QMu,seuil);
    //Verifie_Symetries(argv[1],QMu);
    
    //Variation_Couleur_RGB();

}
Exemplo n.º 10
0
void main()
{
 void *npswloc;             /* new psw location address */
 unsigned int psw[2];       /* psw */
 int x;                     /* loop index */
 int wpin, rpin;            /* pin for the wait and root states */
 PCB dummypcb;              /* dummy PCB for running to be set to */
 
                  /* initialize new psw locations */
                       /* program interrupt */
 psw[0] = 0x000A0000;
 psw[1] = 0x00000BAD;
 npswloc = (void *)progint;
 memcpy(npswloc, psw, 16);
                        /* I/O interrupt */
 psw[0] = 0x00080000;
 psw[1] = (int)IOHNDLR;
 npswloc = (void *)ioint;
 memcpy(npswloc, psw, 16);
                       /* External interrupt */
 psw[1] = (int)EXTHNDLR;
 npswloc = (void *)extint;
 memcpy(npswloc, psw, 16);
                         /* SVC interrupt */
 psw[1] = (int)SVCHNDLR;
 npswloc = (void *)svcint;
 memcpy(npswloc, psw, 16);
 
                     /* initialize memory */
 initmem_();
 
                  /* initialize Ready Process Q */
 QInit(&Ready);
 
               /* initialize table to all empty slots */
 for (x=0; x<PTSIZE; x++)
  PTable[x].state = UNUSED;
 
                     /* create WAIT process */
 psw[0] = 0x030A0000;
 psw[1] = 0x0000AAAA;
 wpin = create_("WAIT    ", psw, NULL, 0, NULL);
 deQ(&Ready);
 
                    /* create terminator process */
 psw[0] = 0x3080000;
 psw[1] = (int)terminator;
 tpin = create_("TERMINAT", psw, 0, 0, NULL);
 
                   /* create PTSEM and MEMWAIT */
 PTSEM = getsem_(PTSIZE, &(PTable[0]));
 MEMWAIT = getsem_(0, &PTable[0]);
 
                 /* create 1st user (ROOT) process */
 psw[0] = 0x03080000;
 psw[1] = (int)root;
 rpin = create_("ROOT    ", psw, 0, 0, NULL);
 
                 /* initialize running to dummy PCB */
 running = &dummypcb;
 running->state = BLOCKED;
 
                 /* dispatch to give control to ROOT */
 dispatch();
} /* end main */
Exemplo n.º 11
0
int Variation_Couleur_RGB()
{
    Quaternion QMu;
    int intHeight,intWidth,intNbStripe;
    double InvRacine3;
    double K=2000.;
    int dim[2];
 
    Quaternion **QMatrix,**QMatrixShifted, **QMatOUT;
    
    /*64 64 2 0.3333333 0.3333333 0.3333333*/
    
        intHeight = 8;
        intWidth = 8;
        intNbStripe = 2;
        InvRacine3 = 1./sqrt(3.);
	dim[0]=intHeight;
	dim[1]=intWidth;
	
        
   	//the Analysis will follow the axis given by QMu
   	//QMu = QInit(0.,1./3.,1./3.,1./3.);
    //QMu = QInit(0.,InvRacine3,InvRacine3,InvRacine3); //Nu luminance
    //QMu2 = QInit(0.,5./sqrt(50.),3./sqrt(50.),4./sqrt(50.)); //Nu quelconque imag pur
    //QMu = QInit(0.,1.,0.,0.);//rouge
    //QMu2 = QInit(0.,0.,1.,0.);//vert
    //QMu2 = QInit(0.,0.,0.,1.);//bleu
    //QMu2 = QInit(0.,1./sqrt(2.),0.,1./sqrt(2.));//rouge-bleu
    //QMu = QInit(0.,1./sqrt(2.),1./sqrt(2.),0.);//rouge-vert : jaune
    

	// Allocation for a Quaterniotic matrix
	if(QMatrixAllocate(intHeight,intWidth,&QMatrix)==TRUE)
	{
		//Initialisation of this matrix with zeros
		QInitMatrix(intHeight,intWidth,QInit(0.,0.,0.,0.),&QMatrix);
	            
 		//j'initialise sur la partie réelle
 		QMatrix[intHeight/2 + intNbStripe][intHeight/2 + intNbStripe].a =K; 
 		QMatrix[intHeight/2 - intNbStripe][intHeight/2 - intNbStripe].a =-K;
 		
 		/*QMatrix[intHeight/2 + intNbStripe][intHeight/2 + intNbStripe].b =K; 
 		QMatrix[intHeight/2 - intNbStripe][intHeight/2 - intNbStripe].b =K;
 		
 		QMatrix[intHeight/2 + intNbStripe][intHeight/2 + intNbStripe].c =K; 
 		QMatrix[intHeight/2 - intNbStripe][intHeight/2 - intNbStripe].c =K;
 		
 		QMatrix[intHeight/2 + intNbStripe][intHeight/2 + intNbStripe].d =K; 
 		QMatrix[intHeight/2 - intNbStripe][intHeight/2 - intNbStripe].d =K;*/
		
		//initialization of another quaternionic matrix
		if(QMatrixAllocate(intHeight,intWidth,&QMatrixShifted)==TRUE)
		{
			//we need to shift the matrix before performing te inverse Fourier transform
			
			QMatrixShift(QMatrix,&QMatrixShifted,intHeight,intWidth);
			QMatrixFree(intHeight,&QMatrix);
			
			//initialisation of the matrix that will receive the insverse Fourier image
			if (QMatrixAllocate(intHeight,intWidth,&QMatOUT)==TRUE)
			{
				// perform the inverse fourier transform
				printf("fourier transform is processing ...\n");
               Quaternion_Matrix_Fourier_Transform_ExpLeft_Inv(QMatrixShifted,&QMatOUT,QMu,intHeight,intWidth);
               QMatrixFree(intHeight,&QMatrixShifted);
               QMatrixDisp((const Quaternion **)QMatOUT,dim[0],dim[1],5,stdout);
               printf("element reel (non nul) present ? %d (0 non , 1 oui)\n",IsRealPresent(QMatOUT,dim,0.00001));
            } 
            QMatrixFree(intHeight,&QMatOUT);
        }
    }
}