int CVICALLBACK EnablePort (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; if (ConfirmPopup ("Enable Port","Do you want to enable SSH and RD port now?")) { memset(cmd,0,100); strcpy(cmd,"enableport.exe -e:all"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Action finished!",1); } else { SetLed("Action failed,please check detail info",0); } DimAction(0); } break; } return 0; }
void DemoLeds() { int d=0; SetLed(ALL|OFF); /* while user button is not pressed */ while (KeyPressCount()==0) { SetLed(L1|TOGGLE); Delay(5); SetLed(L2|TOGGLE); Delay(5); SetLed(L3|TOGGLE); Delay(5); SetLed(L4|TOGGLE); Delay(5); SetLed(L5|TOGGLE); Delay(5); SetLed(L6|TOGGLE); Delay(5); SetLed(L7|TOGGLE); Delay(5); SetLed(L8|TOGGLE); Delay(5); printf("%d\r\n",d++); } SetLed(ALL|OFF); }
int CVICALLBACK GetRruLog (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; if (ConfirmPopup ("Get RRUlog","Do you want to Get RRUlog now?")) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -d:rrulog"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Action finished!",1); } else { SetLed("Action failed,please check detail info",0); } DimAction(0); } break; } return 0; }
int openCPAPDevice( void ) { int uartIndex; int io_descriptor; pthread_t threadTestUART[TEST_UART_NUMBER]; if ( cpap_global.uart_fd != -1 ) { printf_debug("close uart set fd:%d to -1\n" , cpap_global.uart_fd ); close( cpap_global.uart_fd ); } cpap_global.uart_fd=-1; for ( uartIndex=0 ; uartIndex<TEST_UART_NUMBER ; uartIndex++ ) { threadTestUART[uartIndex] = -1; char *deviceName = cpap_global.uart_id[uartIndex].deviceName; bzero( deviceName , sizeof(deviceName) ); sprintf( deviceName , "/dev/ttyUSB%d" , uartIndex ); io_descriptor = rs232_open( deviceName , 9600 ); if ( io_descriptor > 0 ) { printf_debug( "open %s ok\n" , deviceName ); cpap_global.uart_id[uartIndex].descriptor=io_descriptor; pthread_create( &threadTestUART[uartIndex] , 0 , functionTestUART , (void *)uartIndex ); continue; } else { cpap_global.uart_id[uartIndex].descriptor = -1; printf_debug( "open %s error\n" , deviceName ); } } for ( uartIndex=0 ; uartIndex<TEST_UART_NUMBER ; uartIndex++ ) { if ( threadTestUART[uartIndex] != -1 ) pthread_join( threadTestUART[uartIndex] , 0 ); } int use_descriptor=GetCPAPDescriptor(); if ( use_descriptor > 0 ) { printf_debug( "use descriptor:%d\n" , use_descriptor ); SetLed( 1 ); }else{ printf_debug("cant find any cpap device\n" ); SetLed( 0 ); } return use_descriptor; }
void Shutdown(void) { WatchDogOff(); // Turn of watchdog so it won't wake us up again SetLed(0); // Flash the firmware version number on the LEDs before shutdown __delay_ms(300); SetLed(VERSION_MAJ); __delay_ms(100); SetLed(0); __delay_ms(100); SetLed(VERSION_MAJ); __delay_ms(100); SetLed(0); __delay_ms(300); SetLed(VERSION_MIN); __delay_ms(100); SetLed(0); __delay_ms(100); SetLed(VERSION_MIN); __delay_ms(100); SetLed(0); // VREGPM-1; // Low power sleep mode (slow) ANSELA=0; // Set all ports as digital ANSELC=0; TRISA=0; // Set all ports as output TRISC=0; LATA=0; // Set low state on all ports LATC=0; ADON=0; SLEEP(); // Deep sleep until Reset }
/* * Input thread reading from device. * Generates events on incoming data. */ XBMC_Event CLinuxInputDevice::ReadEvent() { int readlen; struct input_event levt; XBMC_Event devt; while (1) { bzero(&levt, sizeof(levt)); bzero(&devt, sizeof(devt)); devt.type = XBMC_NOEVENT; if(m_devicePreferredId == LI_DEVICE_NONE) return devt; readlen = read(m_fd, &levt, sizeof(levt)); if (readlen <= 0) break; //printf("read event readlen = %d device name %s m_fileName %s\n", readlen, m_deviceName, m_fileName.c_str()); // sanity check if we realy read the event if(readlen != sizeof(levt)) { printf("CLinuxInputDevice: read error : %s\n", strerror(errno)); break; } if (!TranslateEvent(levt, devt)) continue; /* Flush previous event with DIEF_FOLLOW? */ if (devt.type != XBMC_NOEVENT) { //printf("new event! type = %d\n", devt.type); //printf("key: %d %d %d %c\n", devt.key.keysym.scancode, devt.key.keysym.sym, devt.key.keysym.mod, devt.key.keysym.unicode); if (m_hasLeds && (m_keyMods != m_lastKeyMods)) { SetLed(LED_NUML, m_keyMods & XBMCKMOD_NUM); SetLed(LED_CAPSL, m_keyMods & XBMCKMOD_CAPS); m_lastKeyMods = m_keyMods; } break; } } return devt; }
int CVICALLBACK SearchFile (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; char *info = ""; char *buffer = ""; char *folder = ""; info = GetItemInfo(3); buffer=(char*)malloc(1000); memset(buffer,0,1000); sprintf(buffer,"Do you want to search files: (%s) now?",info); if (ConfirmPopup ("Search File",buffer)) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -c:search"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Search files is finished!",1); memset(cmd,0,100); strcpy(cmd,"filter.exe -a:search"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Analyze searched files information finished!",1); } else { SetLed("Analyze searched files information failed,please check detail info",0); } DimAction(0); } else { memset(buffer,0,1000); sprintf(buffer,"Search files: (%s) failed,pls check detail info!",info); SetLed(buffer,0); } DimAction(0); } free(buffer); break; } return 0; }
int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelHandle = LoadPanel (0, "Remotely.uir", PANEL)) < 0) return -1; if ((configHandle = LoadPanel (0, "Remotely.uir", CONFIG)) < 0) return -1; if ((itemHandle = LoadPanel (0, "Remotely.uir", FILE_ITEM)) < 0) return -1; menubarHandle = GetPanelMenuBar (panelHandle); GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 0, &bbucommonHandle); GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 1, &rrucommonHandle); GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 2, &customizingHandle); SetActiveTabPage (panelHandle, PANEL_TAB, 0); if(Initial(0, 0)<0 || Initial(1, 0)<0 || Initial(2, 0)<0 || Initial(3, 0)<0) { SetLed("Read file type information from config.ini to UI error,please try again!",0); } WriteLog(); DisplayPanel (panelHandle); RunUserInterface (); return 0; }
// Open DUO camera sensor bool DUOStereoSensorDriver::openCamera() { if (camera_open) return true; if(!OpenDUOCamera(frameSize.width, frameSize.height, 30)) { camera_open = false; return false; } camera_open = true; // Set exposure and LED brightness SetGain(duoProperties->gain); SetExposure(duoProperties->exposure); SetLed(duoProperties->led); // Un-flip frames SetVFlip(true); // Enable retrieval of undistorted (rectified) frames SetUndistort(true); return true; }
void Hardware_::PowerOff() { MCUSR = 0; TCCR3A = 0; SetLed(0); BACKLIGHT0; DDRF |= 1; POWER0; for (;;) ; }
void CLed::OnTimer(UINT_PTR nIDEvent) { if(nIDEvent == TIMER_ID_PING) { SetLed(m_nLedColor,CLed::LED_OFF,m_nLedShape); KillTimer(nIDEvent); m_bPingEnabled = FALSE; } CStatic::OnTimer(nIDEvent); }
/////////////////////////////////////////////////////////////////////////////// // Name: Ping // Description: This method will turn the led on for dwTimeout milliseconds and // then turn it off. // // Entry: DWORD dwTimeout - Time out in milliseconds /////////////////////////////////////////////////////////////////////////////// void CLed::Ping(DWORD dwTimeout) { // Return if pinging if(m_bPingEnabled == TRUE) { KillTimer(TIMER_ID_PING); } m_bPingEnabled = TRUE; SetLed(m_nLedColor,CLed::LED_ON,m_nLedShape); SetTimer(TIMER_ID_PING,dwTimeout,NULL); }
int CVICALLBACK RecordUptime (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; if (ConfirmPopup ("Record uptime","Do you want to record uptime now?")) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -c:uptime"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Get uptime information finished!",1); memset(cmd,0,100); strcpy(cmd,"uptimerecord.exe"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Record uptime information finished!",1); } else { SetLed("Record uptime inforamtion failed,please check detail info",0); } DimAction(0); } else { SetLed("Get uptime inforamtion failed,please check detail info",0); } DimAction(0); } break; } return 0; }
void GravadorControllerDlg::OnPara() { // se clicar em parar inicia a impressão da etiqueta com erro. // conta número de erros // aqui não atualiza número de série para impressão na etiqueta. int fileNum; if (currentPos > 0) fileNum = currentPos - 1; else fileNum = 0; currentPos = 0; if (pGravador[fileNum] == NULL) return; if ( pGravador[fileNum]->IsTestFct() && pGravador[fileNum]->IsUsoFct() && (!pGravador[fileNum]->GetResultTestFct()) ) { SetLed(ledVERMELHO); impressora.ImprimeEtiqueta(FALSE, &dadosImpressora, FALSE, TRUE); } else { SetLed(ledVERDE_PR); impressora.ImprimeEtiqueta(FALSE, &dadosImpressora); } CString cS; nContErros++; cS.Format(_T("%d"), nContErros); m_sFalhas.SetWindowText(cS); nTentativas = 0; bTentandoDeNovo = FALSE; BOOL bFim; adm.AtualizaInfo(nContOk, nContErros, &bFim, 0); ProcessaFimDeProducao(bFim); }
int CVICALLBACK FetchLogs (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; char *buffer=""; char *info = ""; char *folder=""; info = GetItemInfo(2); buffer=(char*)malloc(100); memset(buffer,0,100); sprintf(buffer,"Do you want to fetch filter logs: (%s) now?",info); if (ConfirmPopup ("Fetch Filter Logs",buffer)) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -d:filter"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { memset(buffer,0,100); folder= readfoldername(); sprintf(buffer,"Fetch filter logs: (%s) finished! folder is:%s",info,folder); SetLed(buffer,1); } else { memset(buffer,0,100); sprintf(buffer,"Fetch filter logs: (%s) failed,pls check detail info!",info); SetLed(buffer,0); } DimAction(0); } free(buffer); break; } return 0; }
void CVICALLBACK ConfigItem (int menuBar, int menuItem, void *callbackData, int panel) { if((Initial(1, 0)>=0) && (Initial(2, 0)>=0) && (Initial(3, 0)>=0)) { InstallPopup(itemHandle); } else { SetLed("Read file type or filter information from config.ini to UI error,please try again!",0); } }
int CVICALLBACK UpdateAllPut (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; char *info = ""; char *buffer = ""; info = GetItemInfo(1); // get file item selection buffer=(char*)malloc(100); memset(buffer,0,100); sprintf(buffer,"Do you want to Update-Put files: (%s) now?",info); if (ConfirmPopup ("Update-Put All Files",buffer)) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -u:allupdate"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { memset(buffer,0,100); sprintf(buffer,"Update-Put files: (%s) finished!",info); SetLed(buffer,1); } else { memset(buffer,0,100); sprintf(buffer,"Update-Put files: (%s) failed,pls check detail info!",info); SetLed(buffer,0); } DimAction(0); } free(buffer); break; } return 0; }
int CVICALLBACK CheckSFP (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int status; char cmd[100]; char *buffer=""; char *info = ""; info = GetItemInfo(1); buffer=(char*)malloc(100); memset(buffer,0,100); sprintf(buffer,"Do you want to analyze logs: (%s) now?",info); if (ConfirmPopup ("Analyze Logs",buffer)) { memset(cmd,0,100); strcpy(cmd,"filter.exe -a:sysinfo"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { memset(buffer,0,100); sprintf(buffer,"Analyze logs: (%s) finished!",info); SetLed(buffer,1); } else { memset(buffer,0,100); sprintf(buffer,"Analyze logs: (%s) failed,pls check detail info!",info); SetLed(buffer,0); } DimAction(0); } free(buffer); break; } return 0; }
void DemoAccelerometer() { float roll, pitch; /* while user button is not pressed */ while (KeyPressCount()==0) { ReadAccelerometer(AccBuffer); ComputePitchAndRollFromAcc( AccBuffer[0], AccBuffer[1], AccBuffer[2], &pitch, &roll ); printf("A: %7.2f %7.2f %7.2f PR=%7.2f,%7.2f\r\n", AccBuffer[0], AccBuffer[1], AccBuffer[2], pitch, roll ); SetLed(ALL|OFF); if ((fabs(roll) <= 70.0f) && (fabs(pitch) <= 70.0f)) { if( pitch > 25 ) SetLed(L1); if( pitch < -25 ) SetLed(L5); if( roll > 25 ) SetLed(L3); if( roll < -25 ) SetLed(L7); if( pitch > 25 && roll > 25 ) SetLed(L2); if( pitch < -25 && roll > 25 ) SetLed(L8); if( pitch < -25 && roll < -25 ) SetLed(L6); if( pitch < -25 && roll > 25 ) SetLed(L4); } else { SetLed(ALL|TOGGLE); /* Delay 50ms */ Delay(5); } } }
int main(int argc, char* argv[]) { printf("DUOLib Version: v%s\n", GetLibVersion()); // Open DUO camera and start capturing if(!OpenDUOCamera(WIDTH, HEIGHT, FPS)) { printf("Could not open DUO camera\n"); return 0; } // Create OpenCV windows cvNamedWindow("Left"); cvNamedWindow("Right"); // Set exposure and LED brightness SetExposure(50); SetLed(25); // Create image headers for left & right frames IplImage *left = cvCreateImageHeader(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 1); IplImage *right = cvCreateImageHeader(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 1); // Run capture loop until <Esc> key is pressed while((cvWaitKey(1) & 0xff) != 27) { // Capture DUO frame PDUOFrame pFrameData = GetDUOFrame(); if(pFrameData == NULL) continue; // Set the image data left->imageData = (char*)pFrameData->leftData; right->imageData = (char*)pFrameData->rightData; // Process images here (optional) // Display images cvShowImage("Left", left); cvShowImage("Right", right); } // Release image headers cvReleaseImageHeader(&left); cvReleaseImageHeader(&right); // Close DUO camera CloseDUOCamera(); return 0; }
////////////////////////////////////////////////////////////////////selfdefined function////////////////////////////////////// static int ExecutableProcess(char *cmd, char *checkpoint) { FILE *hFile; char buffer[300]; // long enough for single line of output from ipconfig char tempFileName[L_tmpnam]; char command[L_tmpnam + 25]; int hProc; int res=0; int checkflag = 0; tmpnam(tempFileName); sprintf(command, "cmd.exe /C %s > %s", cmd,tempFileName); // sprintf(command, "cmd.exe /C %s", cmd); // if (LaunchExecutableEx(command, LE_SHOWNORMAL, &hProc) >= 0) if (LaunchExecutableEx(command, LE_HIDE, &hProc) >= 0) { SetLed("running...please wait...",0); ProcessSystemEvents (); WriteLog(); ResetTextBox (panelHandle, PANEL_TEXTBOX, ""); while (!ExecutableHasTerminated(hProc)); { RetireExecutableHandle(hProc); } if (hFile = fopen(tempFileName, "r")) { while (fgets(buffer, (int)sizeof(buffer), hFile)) { SetCtrlVal (panelHandle, PANEL_TEXTBOX, buffer); if (!checkflag) { if(NULL != strstr (buffer, checkpoint)) { checkflag = 1; res = 1; } } } fclose(hFile); // DeleteFile(tempFileName); remove (tempFileName); } } return res; }
void GravadorControllerDlg::ProcessaFimDeProducao(BOOL bFim) { // habilita botão gravar e reimprime if (!bFim) { ControlaBotoes(TRUE, FALSE, TRUE); } else { // se for fim do lote bloqueia o botão de gravar. ControlaBotoes(FALSE, FALSE, TRUE); // avisa operador que é fim de produção SetLed(ldVERMELHO); m_Mensagem.SetWindowText(_T("Fim de prod.")); } }
int CVICALLBACK Item_Exit (int panel, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_CLOSE: if((Initial(1, 1)>=0) && (Initial(2, 1)>=0) && (Initial(3, 1)>=0)) // write file type inforamtion to config.ini { RemovePopup (itemHandle); } else { SetLed("Write file type or filter information from UI to config.ini error,please try again!",0); } break; } return 0; }
BOOL GravadorControllerDlg::GravacaoIndividual(int fileNum) { DWORD dwTimeGravacao; dwTimeGravacao = GetTickCount(); // desabilita todos os botões ControlaBotoes(FALSE, FALSE, FALSE); BeginWaitCursor(); if (!bTentandoDeNovo) m_eBox.SetWindowText(_T("")); ShowMess(_T("Iniciando gravação. Aguarde")); multiPlex.SetaInterfaceST(fileNum); ControlaLeds(fileNum, ldAMARELO); SetLed(ledAMARELO); CString cS; if (bTentandoDeNovo) { nTentativas++; cS.Format(_T("Tentativa número: %d."), nTentativas); ShowMess(cS); } BOOL bResultFinal; if (pGravador[fileNum] == NULL) ShowMess(_T("Erro grave. Gravador não inicializado")); bResultFinal = pGravador[fileNum]->Grava(&cS, !bDetalhado); if (cS.GetLength() > 0) ShowMess(cS); EndWaitCursor(); m_debugLog.Log(LOG_INFO, _T("Tempo total de gravacao (ms): %d"), GetTickCount() - dwTimeGravacao); return bResultFinal; }
void DemoGyro() { uint8_t Xval, Yval = 0x00; /* Waiting User Button is pressed */ while (KeyPressCount()==0) { /* Wait for data ready - Demo just wait for 5ms */ Delay(5); /* LEDs Off */ SetLed(ALL|OFF); /* Read Gyro Angular data */ ReadGyro(Buffer); /* Update autoreload and capture compare registers value*/ Xval = ABS((int8_t)(Buffer[0])); Yval = ABS((int8_t)(Buffer[1])); if ( Xval>Yval) { if ((int8_t)Buffer[0] > 5.0f) { SetLed(LED10); } if ((int8_t)Buffer[0] < -5.0f) { SetLed(LED3); } } else { if ((int8_t)Buffer[1] < -5.0f) { SetLed(LED6); } if ((int8_t)Buffer[1] > 5.0f) { SetLed(LED7); } } } SetLed(ALL|OFF); }
void RxStatus::update() { // qDebug() << __FILE__ << __LINE__; // if(!newSamp) // return; extern demodulator *demodulatorPtr; extern int currentSegmentNumber; extern int bodyTotalSegments; extern int rxSegments; extern int robustness_mode; extern bool callsignValid; extern LogView *editor; extern char drmCallsign[9]; extern int fac_valid; extern int spectrum_occupancy_new; extern struct mplex_desc multiplex_description; extern int interleaver_depth_new; extern int msc_mode_new; extern emscStatus msc_valid; extern unsigned int rxTransportID; extern QString rxFname; extern float WMERFAC; extern float freqOffset; extern QList<short unsigned int> drmBlockList; SetLed(Led_Io, Io_Led); SetLed(Led_Freq, Freq_Led); SetLed(Led_Time, Time_Led); SetLed(Led_Frame, Frame_Led); SetLed(Led_FAC, FAC_Led); SetLed(Led_MSC, MSC_Led); // fnamelist << rxFname; // if(chkList(fnamelist) > 1) // { if(!RxFname->text().contains(rxFname)) RxFname->setText(rxFname); // } snrEdit->setText(QString::number(WMERFAC,'g',2)+" dB"); freqOff = (int)round(freqOffset); offsetEdit->setText(QString::number(freqOff)+" Hz"); if(demodulatorPtr->isTimeSync()) { // qDebug() << __FILE__ << __LINE__; Time_Led = Qt::green; } else { // qDebug() << __FILE__ << __LINE__; // Freq_Led = Qt::red; Time_Led = Qt::red; Frame_Led = Qt::red; FAC_Led = Qt::red; MSC_Led = Qt::red; return; } txportEdit->setText(QString::number(rxTransportID)); currentSegment=currentSegmentNumber; currentSegmentEdit->setText(QString::number(currentSegment)); totalSeg=bodyTotalSegments; totalSegmentsEdit->setText(QString::number(totalSeg)); rxSeg=rxSegments; switch(robustness_mode) { case 0: mode="A"; break; case 1: mode="B"; break; case 2: mode="E"; break; default: mode=""; break; } modeEdit->setText(mode); if(callsignValid) { call = drmCallsign; callsignValid = false; calllist << call; if(chkList(calllist) > MAXLIST - 1) { if(!CallEdit->text().contains(call)) { CallEdit->setText(call); editor->insert(call); } } } if(fac_valid==1) { FAC_Led = Qt::green; } else { FAC_Led = Qt::red; } // static QString ncall; switch(msc_valid) { case INVALID: MSC_Led = Qt::red; break; case VALID: MSC_Led = Qt::green; // if(!ncall.contains(call)) // { // editor->insert(call); // ncall = call; // } break; case ALREADYRECEIVED: MSC_Led = Qt::yellow ; break; } if(demodulatorPtr->isFrameSync()) { Frame_Led = Qt::green; // ui->frameLED->setPixmap(*greenPXM); } else { Frame_Led = Qt::red; // ui->frameLED->setPixmap(*redPXM); } if(demodulatorPtr->isTimeSync()) { Time_Led = Qt::green; // ui->timeLED->setPixmap(*greenPXM); } else { Time_Led = Qt::red; // ui->timeLED->setPixmap(*redPXM); } if(mode=="") return; switch(spectrum_occupancy_new) { case 0: bandwidth=2.3; break; case 1: bandwidth=2.5;; break; default:bandwidth=0; break; } bandwidthEdit->setText(QString::number(bandwidth)); switch (multiplex_description.PL_PartB) { case 0: protection="High"; break; case 1: protection="Low"; break; default: break; } protectionEdit->setText(protection); switch(interleaver_depth_new) { case 0: interleave="Long"; break; case 1: interleave="Short"; break; default: ; break; } interleaveEdit->setText(interleave); switch(msc_mode_new) { case 0: qam=64; break; case 1: qam=16; break; case 3: qam=4; break; default: qam=0; break; } qamEdit->setText(QString::number(qam)); rxSegmentsEdit->setText(QString::number(rxSegments)); blocksReceivedFrame->setMaxBlocks(totalSeg); blocksReceivedFrame->setBlocks(drmBlockList); // qDebug() << __FILE__ << __LINE__ << totalSeg; newSamp = false; }
/* * Input thread reading from device. * Generates events on incoming data. */ XBMC_Event CLinuxInputDevice::ReadEvent() { int readlen; struct input_event levt; XBMC_Event devt; if (m_equeue.empty()) { while (1) { bzero(&levt, sizeof(levt)); bzero(&devt, sizeof(devt)); devt.type = XBMC_NOEVENT; if(m_devicePreferredId == LI_DEVICE_NONE) return devt; readlen = read(m_fd, &levt, sizeof(levt)); if (readlen <= 0) { if (errno == ENODEV) { CLog::Log(LOGINFO,"input device was unplugged %s",m_deviceName); m_bUnplugged = true; } break; } //printf("read event readlen = %d device name %s m_fileName %s\n", readlen, m_deviceName, m_fileName.c_str()); // sanity check if we really read the event if(readlen != sizeof(levt)) { CLog::Log(LOGERROR,"CLinuxInputDevice: read error : %s\n", strerror(errno)); break; } if (!TranslateEvent(levt, devt)) continue; /* Flush previous event with DIEF_FOLLOW? */ if (devt.type != XBMC_NOEVENT) { //printf("new event! type = %d\n", devt.type); //printf("key: %d %d %d %c\n", devt.key.keysym.scancode, devt.key.keysym.sym, devt.key.keysym.mod, devt.key.keysym.unicode); if (m_hasLeds && (m_keyMods != m_lastKeyMods)) { SetLed(LED_NUML, m_keyMods & XBMCKMOD_NUM); SetLed(LED_CAPSL, m_keyMods & XBMCKMOD_CAPS); m_lastKeyMods = m_keyMods; } break; } } } else { devt = m_equeue.front(); m_equeue.pop_front(); } return devt; }
int main (void) { // set mosi/sck out DDRB = (1<<DDB5)|(1<<DDB3)|(1<<DDB2); //latch out DDRB |= (1<<DDB1); //blank out DDRD |= (1<<DDD7); // latch aus PORTB &= ~(1<<PORTB1); // blank = high (all LEDs off) PORTD |= (1<<PORTD7); //SPI_Init() SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0); //fill the RAM of the TLC with defined values SetLed(0,0,0,0); writeChannels(); // blank = low (enable LEDs) PORTD &= ~(1<<PORTD7); DDRC &= ~(1<<PORTC0); DDRC &= ~(1<<PORTC1); DDRC &= ~(1<<PORTC2); DDRC &= ~(1<<PORTC3); DDRD &= ~(1<<PORTD2); DDRD &= ~(1<<PORTD3); PORTC |= (1<<PORTC0)|(1<<PORTC1)|(1<<PORTC2)|(1<<PORTC3); PORTD |= (1<<PORTD2)|(1<<PORTD3); //enable pullups ununsed pins PORTD |= (1<<PORTD4); PORTD |= (1<<PORTD5); PORTD |= (1<<PORTD6); PORTB |= (1<<PORTB0); PORTB |= (1<<PORTB2); PORTC |= (1<<PORTC4); PORTC |= (1<<PORTC5); //disable input buffers on unused pins DIDR1 |= (1<<AIN0D); DIDR0 |= (1<<ADC4D); DIDR0 |= (1<<ADC5D); //disable unused hardware (twi,adc,acd,timer0,timer2) PRR |= (1<<PRTWI)|(1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM2); ACSR |= (1<<ACD); //timer1 for tlc sync //set to FastPWM Mode & prescaler 8 TCCR1A |= (1<<WGM10)|(1<<WGM11); TCCR1B |= (1<<WGM12)|(1<<WGM13)|(1<<CS11);//|(1<<CS10); //this is one cycle length of the TLC (2560) OCR1A = 1112; //2780 looks good //enable interrupt TIMSK1 |= (1<<TOIE1); //enable UART RX USART0_Init(); //enable interrupts sei(); uint8_t i = 0; while(1) { for(i=0;i<10;i++) { for(uint8_t j=0;j<10-i;j++) { SetLed(0,255,255,255); writeChannels(); _delay_ms(i*10); SetLed(0,0,0,255); writeChannels(); _delay_ms(i*10); } } for(i=0;i<20;i++) { for(uint8_t j=0;j<10-i;j++) { SetLed(0,0,255,0); writeChannels(); _delay_ms(i*10); SetLed(0,0,0,255); writeChannels(); _delay_ms(i*10); } } for(i=0;i<20;i++) { for(uint8_t j=0;j<10-i;j++) { SetLed(0,0,255,0); writeChannels(); _delay_ms(i*10); SetLed(0,255,0,0); writeChannels(); _delay_ms(i*10); } } for(uint8_t j=50;j<100;j+=10) { for(i=0;i<5;i++) { SetLed(0,255,0,0); writeChannels(); _delay_ms(j); SetLed(0,0,0,255); writeChannels(); _delay_ms(j); } } for(uint8_t j=50;j<100;j+=10) { for(i=0;i<5;i++) { SetLed(0,0,255,0); writeChannels(); _delay_ms(j); SetLed(0,255,255,0); writeChannels(); _delay_ms(j); } } for(uint8_t j=0;j<3;j++) { for(i=1;i<5;i++) { SetLed(0,0,0,0); SetLed(i*2,255,0,0); SetLed(i*2-1,255,0,0); SetLed((5-i)*2,0,0,255); SetLed((5-i)*2-1,0,0,255); writeChannels(); _delay_ms(200); } for(i=4;i>1;i--) { SetLed(0,0,0,0); SetLed(i*2,255,0,0); SetLed(i*2-1,255,0,0); SetLed((5-i)*2,0,0,255); SetLed((5-i)*2-1,0,0,255); writeChannels(); _delay_ms(200); } } for(i=0;i<50;i++) { SetLed(0,255,0,0); writeChannels(); _delay_ms(30); SetLed(0,0,255,0); writeChannels(); _delay_ms(30); SetLed(0,0,0,255); writeChannels(); _delay_ms(30); } for(i=0;i<50;i++) { SetLed(0,255,0,0); writeChannels(); _delay_ms(10); SetLed(0,0,255,0); writeChannels(); _delay_ms(10); SetLed(0,0,0,255); writeChannels(); _delay_ms(10); } for(i=0;i<100;i++) { SetLed(0,0,255,255); writeChannels(); _delay_ms(3); SetLed(0,255,0,255); writeChannels(); _delay_ms(3); SetLed(0,255,255,0); writeChannels(); _delay_ms(3); } SetLed(0,0,0,0); uint16_t q = 0; uint16_t j = 1; for(q=1024;q>2;) { for(uint16_t v=0;v<j;v++) { SetLed(0,0,255,255); writeChannels(); _delay_ms(q); SetLed(0,255,0,255); writeChannels(); _delay_ms(q); SetLed(0,255,255,0); writeChannels(); _delay_ms(q); SetLed(0,255,0,0); writeChannels(); _delay_ms(q); SetLed(0,0,255,0); writeChannels(); _delay_ms(q); SetLed(0,0,0,255); writeChannels(); _delay_ms(q); } j = j * 2; q = q >> 1; } } }
/* * Open the device, fill out information about it, * allocate and fill private data, start input thread. */ bool CLinuxInputDevice::Open() { int fd, ret; unsigned long ledbit[NBITS(LED_CNT)]; /* open device */ fd = open(m_fileName.c_str(), O_RDWR | O_NONBLOCK); if (fd < 0) { CLog::Log(LOGERROR, "CLinuxInputDevice: could not open device: %s\n", m_fileName.c_str()); return false; } /* grab device */ ret = ioctl(fd, EVIOCGRAB, 1); if (ret && errno != EINVAL) { CLog::Log(LOGERROR, "CLinuxInputDevice: could not grab device: %s\n", m_fileName.c_str()); close(fd); return false; } // Set the socket to non-blocking int opts = 0; if ((opts = fcntl(fd, F_GETFL)) < 0) { CLog::Log(LOGERROR, "CLinuxInputDevice %s: fcntl(F_GETFL) failed: %s", __FUNCTION__ , strerror(errno)); close(fd); return false; } opts = (opts | O_NONBLOCK); if (fcntl(fd, F_SETFL, opts) < 0) { CLog::Log(LOGERROR, "CLinuxInputDevice %s: fcntl(F_SETFL) failed: %s", __FUNCTION__, strerror(errno)); close(fd); return false; } /* fill device info structure */ GetInfo(fd); if (m_deviceType & LI_DEVICE_KEYBOARD) SetupKeyboardAutoRepeat(fd); m_fd = fd; m_vt_fd = -1; if (m_deviceMinKeyCode >= 0 && m_deviceMaxKeyCode >= m_deviceMinKeyCode) { if (m_vt_fd < 0) m_vt_fd = open("/dev/tty0", O_RDWR | O_NOCTTY); if (m_vt_fd < 0) m_vt_fd = open("/dev/tty1", O_RDWR | O_NOCTTY); if (m_vt_fd < 0) CLog::Log(LOGWARNING, "no keymap support (requires /dev/tty0 - CONFIG_VT)"); } /* check if the device has LEDs */ ret = ioctl(fd, EVIOCGBIT(EV_LED, sizeof(ledbit)), ledbit); if (ret < 0) CLog::Log(LOGWARNING, "DirectFB/linux_input: could not get LED bits" ); else m_hasLeds = test_bit( LED_SCROLLL, ledbit ) || test_bit( LED_NUML, ledbit ) || test_bit( LED_CAPSL, ledbit ); if (m_hasLeds) { /* get LED state */ ret = ioctl(fd, EVIOCGLED(sizeof(m_ledState)), m_ledState); if (ret < 0) { CLog::Log(LOGERROR, "DirectFB/linux_input: could not get LED state"); goto driver_open_device_error; } /* turn off LEDs */ SetLed(LED_SCROLLL, 0); SetLed(LED_NUML, 0); SetLed(LED_CAPSL, 0); } return true; driver_open_device_error: ioctl(fd, EVIOCGRAB, 0); if (m_vt_fd >= 0) { close(m_vt_fd); m_vt_fd = -1; } close(fd); m_fd = -1; return false; }
int CVICALLBACK UpdateVendor (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char *name = ""; int ret=0; switch (event) { case EVENT_COMMIT: int status; char cmd[100]; name=(char*)malloc(100); memset(name,0,100); GetCtrlVal (customizingHandle, CUSTOM_UPDATENAME, name); ret = strlen(name); if ((NULL != (strstr (name, ".xml")))&&(ret != 4)) { if (ConfirmPopup ("Update Vendor","Do you want to update vendor now?")) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -d:vendor"); DimAction(1); status = ExecutableProcess(cmd,"@action done@"); if (status) { SetLed("Get vendor finished!",1); if(Initial(0, 1)<0) // write local vendor name to config.ini { SetLed("Write local vendor name to config.ini error,please try again!",0); } else { if(ConfirmPopup ("Confirm carrying on...","Make sure upgrading finished then continue updating process?")) { memset(cmd,0,100); strcpy(cmd,"RemoteAction.exe -u:update"); status = ExecutableProcess(cmd,"@action done@"); if (status) { DimAction(0); SetLed("Update vendor finished!",1); } } else { DimAction(0); SetLed("U canceled the update process...",0); } } } else { SetLed("Action failed,please check detail info",0); } DimAction(0); } } else { MessagePopup ("Error", "Please confirm you have input vendor name(.xml) before updating!"); } free(name); break; } return 0; }