Пример #1
0
void CaenVmeRead(int32_t BHandle, man_par_t *man)
{
    uint32_t            i,old_data=0 ;
    CVErrorCodes        ret,old_ret=cvSuccess;


    if(man->dtsize == cvD64)
    {
        con_printf(" Can't execute a D64 Read Cycle");
        return ;
    }

    if(man->ncyc == 0)                          // Infinite Loop
        con_printf_xy(X_COMM,Y_COMM+2," Running ...    Press any key to stop.");

    for (i=0; ((man->ncyc==0) || (i<man->ncyc)) && !con_kbhit(); i++)
    {

        ret = CAENVME_ReadCycle(BHandle,man->addr,&man->data,man->am,man->dtsize);

        if((i==0) || (ret != old_ret))
        {
            gotoxy(X_COMM,Y_COMM) ;

            switch (ret)
            {
            case cvSuccess   : con_printf(" Cycle(s) completed normally\n");
                if((i==0) || (old_data != man->data))  
                {                    
                    if( man->dtsize == cvD32 )
                        con_printf(" Data Read : %08X",man->data);
                    if( man->dtsize == cvD16 )
                        con_printf(" Data Read : %04X",man->data & 0xffff);
                    if( man->dtsize == cvD8 )
                        con_printf(" Data Read : %02X",man->data & 0xff);
                }
                break ;
            case cvBusError      : con_printf(" Bus Error !!!");
                break ;                            
            case cvCommError : con_printf(" Communication Error !!!");
                break ;
            default          : con_printf(" Unknown Error !!!");
                break ;
            }
        }

        old_data = man->data;
        old_ret = ret;

        if(man->autoinc)
        {
            man->addr += man->dtsize;                       // Increment address (+1 or +2 or +4)       
            con_printf_xy(X_ADDR,Y_ADDR,"%08X]",man->addr);     // Update the screen
        }
    }
    
    if(man->ncyc == 0)
        clear_line(Y_COMM+2);
}
Пример #2
0
 int con_getch()
 {
   int i;
   i=wgetch(conio_scr);
   if (i==-1) i=0;
   if (i == 27)
     if (con_kbhit())
       i = KEY_PREFIX + wgetch(conio_scr);
   #ifndef _NO_ALT_ESCAPE_SAME_
   if (i == KEY_PREFIX + 27) i = 27;
   #endif
   return(i);
 }
Пример #3
0
void CaenVmeIrqCheck(int32_t BHandle, man_par_t *man)
{
    CVErrorCodes        ret ;

    con_printf(" CHECK IRQ\n");

    CAENVME_IRQCheck(BHandle,&man->irqstat);            // Check IRQ Status

    con_printf(" IRQ status: %02X\n",man->irqstat);
    con_printf(" Interrupt Level to Acknowledge (0 to exit) : ");  // Get the int level   
    con_scanf("%x",&man->level); 

    if (man->level == 0)
    {
        clear_line(Y_COMM);
        clear_line(Y_COMM+1);
        clear_line(Y_COMM+2);
        return ;
    }

    con_printf_xy(X_COMM,Y_COMM+2," Waiting for interrupt ... Press any key to stop.");

    while (!(man->irqstat & (1<<(man->level-1))) && !con_kbhit())   // Check Int loop
        CAENVME_IRQCheck(BHandle,&man->irqstat);

    gotoxy(X_COMM,Y_COMM) ;

    if(man->irqstat & (1<<(man->level-1)))
    {

        ret = CAENVME_IACKCycle(BHandle,man->level,&man->data,man->dtsize);
 
        switch (ret)
        {
        case cvSuccess   : con_printf(" Cycle completed normally\n");                                                       
            con_printf(" Int. Ack. on IRQ%d: StatusID = %0X",man->level,man->data);
            break ;
        case cvBusError  : con_printf(" Bus Error !!!");
            break ;                                
        case cvCommError : con_printf(" Communication Error !!!");
            break ;
        default          : con_printf(" Unknown Error !!!");
            break ;


        }
    }
    else
        con_printf(" Interrupt request IRQ%d not active",man->level);
     
}
Пример #4
0
int con_scanf(char *fmt, void *app)
{
#ifdef LINUX

  int i;

  echo();
  i = scanw(fmt,app);    
  refresh();
  noecho();
  return i;

#else

  int res;
      
  res = _cscanf(fmt, app) ;

  con_kbhit() ;                 /* Due to input reading problem */

  return res;

#endif
}
Пример #5
0
int main(int argc, char **argv)
{		
	
	printf("input$ ");
	con_flush();
	CHAR* r = con_input(NULL,NULL,FALSE,NULL,0);
	
	printf("\n[%s]\n",r);
	
	free(r);
	return 0;
	
	
	/*
	CONMSG cm;
	con_msg(&cm,"init",0);
		con_printfk_reg('a',pk_sum);
	con_msg(&cm,NULL,100);
	
	con_printfk("5 + 5 = %5.5a\n");
	
	INT32 a = 13;
	INT32 b = 37;
	con_printfk("%d + %d = %*.*a\n%@",a,b,a,b);
	
	
	con_msg(&cm,"press any key to continue...",0);
		con_async(1,NULL);
			while(!con_kbhit());
			CHAR c = con_getchex();
		con_async(0,NULL);
		if ( c == 27 ) 
		{
			con_msg(&cm,NULL,-1);
			return 0;
		}
	con_msg(&cm,NULL,100);
	
	con_cls();
	UINT32 sw,sh;
	con_getmaxrc(&sh,&sw);
	
	
	con_rect(1,1,sh,sw);
	con_circle(sh/2+1,sw/2,sh/2 - 1,'.');
	
	con_line(sh/2 + 1, sw/2 - sw/4, sh/2 + 1, sw/2 + sw/4, '-');
	con_line(sh/2 - sh/3 + 1, sw/2 - sw/4, sh/2 + sh/3 + 1, sw/2 + sw/4, '\\');
	con_line(sh/2 + sh/3 + 1, sw/2 - sw/4, sh/2 - sh/3 + 1, sw/2 + sw/4, '/');
	
	con_gotorc(2,2);
	con_printfk("press any key to continue...%@");
	con_async(1,NULL);
		while(!con_kbhit());
		c = con_getchex();
	con_async(0,NULL);
	
	con_cls();
	
	return 0;
	*/
	
	
    con_async(1);
    
    INT32 c;
    while (1)
    {
		printf("wait kb\n");
		con_flush();
		while(!con_kbhit()) thr_sleep(0.001);
		printf("get kb\n");	
		con_flush();
		c = con_getchex();
		printf("[%d(%c)]",c,c);
			
		con_flush();
		
		if ( c == 'q' ) break;
	}
    
    con_async(0);
    
    return 0;
}
Пример #6
0
void CaenVmeReadBlt(int32_t BHandle, man_par_t *man)
{
    int                                 nb;
    uint32_t                            i,j ;
    CVAddressModifier   am;
    CVErrorCodes                ret,old_ret=cvSuccess;


    if(man->am == cvA16_U)
    {
        con_printf(" Can't execute a A16 BLT Read Cycle");
        return ;
    }
    if(man->am == cvCR_CSR)
    {
        con_printf(" Can't execute a CR/CSR BLT Read Cycle");
        return ;
    }

    if (man->dtsize == cvD64)
    {
        if (man->am == cvA24_U_DATA)
            am = cvA24_U_MBLT;
        else 
            am = cvA32_U_MBLT;
    }
    else
    {
        if (man->am == cvA24_U_DATA)
            am = cvA24_U_BLT;
        else 
            am = cvA32_U_BLT;
    }

    if(man->ncyc == 0)                          // Infinite Loop
        con_printf_xy(X_COMM,Y_COMM+2," Running ...    Press any key to stop.");

    for (i=0; ((man->ncyc==0) || (i<man->ncyc)) && !con_kbhit(); i++)
    {
        for (j=0;j<(man->blts/4);j++)
            man->buff[j]=0;

        ret = CAENVME_BLTReadCycle(BHandle,man->addr,(char *)man->buff,man->blts,am,man->dtsize,&nb);
        
        if((i==0) || (ret != old_ret))
        {
            gotoxy(X_COMM,Y_COMM) ;

            switch (ret)
            {
            case cvSuccess   : con_printf(" Cycle(s) completed normally\n");
                con_printf(" Read %u bytes",nb);
                break ;
            case cvBusError      : con_printf(" Bus Error !!!\n");
                con_printf(" Read %u bytes",nb);
                break ;                            
            case cvCommError : con_printf(" Communication Error !!!");
                break ;
            default          : con_printf(" Unknown Error !!!");
                break ;
            }
        }
       
        old_ret = ret;

    } 

    if(man->ncyc == 0)
        clear_line(Y_COMM+2);        
}
Пример #7
0
void CaenVmeWriteBlt(int32_t BHandle, man_par_t *man)
{
    int                                 nb;
    uint32_t                    i,incr ;
    CVAddressModifier   am;
    CVErrorCodes                ret,old_ret=cvSuccess;


    if(man->am == cvA16_U)
    {
        con_printf(" Can't execute a A16 BLT Write Cycle");
        return ;
    }
    if(man->am == cvCR_CSR)
    {
        con_printf(" Can't execute a CR/CSR BLT Write Cycle");
        return ;
    }

    con_printf_xy(X_COMM,Y_COMM+2," First Data [hex] : ") ;
    con_scanf("%x",&man->data);                                 // Get data to write 
    clear_line(Y_COMM+2) ;
    con_printf_xy(X_COMM,Y_COMM+2," Data Increment [hex] : ") ; // Get increment for data
    con_scanf("%x",&incr);  
    for(i=0; i<(man->blts/4); i++)                              // Fill the data buffer
        man->buff[i] = man->data+incr*i;

    if (man->dtsize == cvD64)
    {
        if (man->am == cvA24_U_DATA)
            am = cvA24_U_MBLT;
        else 
            am = cvA32_U_MBLT;
    }
    else
    {
        if (man->am == cvA24_U_DATA)
            am = cvA24_U_BLT;
        else 
            am = cvA32_U_BLT;
    }

    if(man->ncyc == 0)                          // Infinite Loop
        con_printf_xy(X_COMM,Y_COMM+2," Running ...    Press any key to stop.");

    for (i=0; ((man->ncyc==0) || (i<man->ncyc)) && !con_kbhit(); i++)
    {

        ret = CAENVME_BLTWriteCycle(BHandle,man->addr,(char *)man->buff,man->blts,am,man->dtsize,&nb);
                        
        if((i==0) || (ret != old_ret))
        {
            gotoxy(X_COMM,Y_COMM) ;

            switch (ret)
            {
            case cvSuccess   : con_printf(" Cycle(s) completed normally\n");
                con_printf(" Written %u bytes",nb);
                break ;
            case cvBusError      : con_printf(" Bus Error !!!\n");
                con_printf(" Written %u bytes",nb);
                break ;                            
            case cvCommError : con_printf(" Communication Error !!!");
                break ;
            default          : con_printf(" Unknown Error !!!");
                break ;
            }
        }
       
        old_ret = ret;

    } 
    
    if(man->ncyc == 0)
        clear_line(Y_COMM+2);
}