bool KTPackageHandler::makePackage(const QString &projectPath, const QString &packagePath) { if ( !QFile::exists(projectPath)) { qWarning("Project not saved!"); return false; } QFileInfo packageInfo(packagePath); QuaZip zip(packagePath); if(!zip.open(QuaZip::mdCreate)) { dError() << "Error while create package: " << zip.getZipError(); return false; } if ( ! compress(&zip, projectPath )) { dError() << "Error while compress project" << zip.getZipError(); return false; } zip.close(); if(zip.getZipError() != 0) { dError() << "Error: " << zip.getZipError(); return false; } return true; }
/* -------------------------------------------------------------------- *\ * DSET METHODS \* -------------------------------------------------------------------- */ static long dsetInit_devAiSyncSoft(aiRecord *pai) { CONTEXT *p_myContext; char p_myCommand[BUFLEN]="(null)"; int myStatus; #ifdef DEBUG1 packageInfo(); printf( __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pai->name); #endif p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); myStatus=sscanf(pai->inp.value.instio.string, "c=%[^\n]", p_myCommand); #ifdef DEBUG2 printf( __FILE__ "[%d] param = >%s<\n", __LINE__, pai->inp.value.instio.string); printf( __FILE__ "[%d] command = >%s<\n", __LINE__, p_myCommand); #endif p_myContext->errorCode=0; strncpy(p_myContext->p_command, p_myCommand, BUFLEN); pai->dpvt= (void *)p_myContext; #ifdef DEBUG1 printf( __FILE__ "[%d] <- %s\n", __LINE__, __func__); #endif return(SUCCESS); }
static long dsetInit_devSiSyncTimestamp(stringinRecord *psi) { CONTEXT *p_myContext; char p_myDateFormat[BUFLEN]="(null)"; int myStatus; FILE *p_myFileHandle; char p_myWarmstartFilename[BUFLEN]; int myLogMark; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, psi->name); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); myStatus=sscanf(psi->inp.value.instio.string, "@lm=%d,df=%[^\n]", &myLogMark, p_myDateFormat); dsetLog(5, __FILE__ "[%d] param = >%s<\n", __LINE__, psi->inp.value.instio.string); dsetLog(5, __FILE__ "[%d] logMark = %d\n", __LINE__, myLogMark); dsetLog(5, __FILE__ "[%d] dateFormat= >%s<\n", __LINE__, p_myDateFormat); p_myContext->logMark=myLogMark; strncpy(p_myContext->p_dateFormat, p_myDateFormat, BUFLEN); psi->dpvt=(void *)p_myContext; sprintf(p_myWarmstartFilename, WARMSTART_FILE_PREFIX "/%s",psi->name); p_myFileHandle=fopen(p_myWarmstartFilename,"r"); if (p_myFileHandle!=NULL) { fscanf(p_myFileHandle,"%[^\n]", psi->val); dsetLog(5, __FILE__ "[%d] timestamp =>%s<", __LINE__, psi->val); fclose(p_myFileHandle); } dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); return(SUCCESS); }
/*---------------------------------------------------------------------- * EXTERNAL VARIABLES & FUNCTIONS *----------------------------------------------------------------------*/ extern int openSocket( char *p_serverName, int servicePort) { INTERNET_SOCKET_ADDRESS *p_myServerSocketAddress; SOCKET myClientSocketDescriptor; #ifdef DEBUG1 packageInfo(); printf (__FILE__ "[%d] -> %s(%s,%d)\n", __LINE__, __func__, p_serverName, servicePort); #endif p_myServerSocketAddress=(INTERNET_SOCKET_ADDRESS *) calloc(1,sizeof(INTERNET_SOCKET_ADDRESS)); if (getServerSocketAddress(p_myServerSocketAddress, p_serverName,servicePort) <=ERROR) { fprintf( stderr, __FILE__ "[%d] Error: Couldn't compute server socket!\n" ,__LINE__); return(ERROR); } /* Create a connection oriented socket using ARPA internet protocols */ if ((myClientSocketDescriptor = socket(AF_INET, SOCK_STREAM, 0)) == ERROR ) { fprintf( stderr, __FILE__ "[%d] Error: Couldn't create socket\n",__LINE__); return(ERROR); } #ifdef DEBUG2 printf( __FILE__ "[%d] Socket was created(%d)!\n", __LINE__, myClientSocketDescriptor); printf( __FILE__ "[%d] Now attempting a connection...\n", __LINE__); printf( __FILE__ "[%d] Warning: Check firewall settings!\n", __LINE__); printf( __FILE__ "[%d] Warning: Check number of allowed connections!\n", __LINE__); #endif /* Request a connection to the server listen socket * From this point forward read/write on the client socket will be * equivalent to read/write on the network */ if (connect(myClientSocketDescriptor, (SOCKET_ADDRESS *)p_myServerSocketAddress, sizeof(SOCKET_ADDRESS)) <= ERROR) { fprintf( stderr, __FILE__ "[%d] Error: Couldn't connect to server\n", __LINE__); fprintf( stderr, __FILE__ "[%d] Error: Is server running on this port?\n", __LINE__); closeSocket(myClientSocketDescriptor); return(ERROR); } #ifdef DEBUG1 printf( __FILE__ "[%d] <- %s(%d)\n", __LINE__, __func__, myClientSocketDescriptor); #endif return(myClientSocketDescriptor); }
static long dsetInit_devMbboAsyncGpib(mbboRecord *pmbbo) { CONTEXT *p_myContext; CALLBACK *p_myCallback; #ifdef DEBUG1 packageInfo(); printf( __FILE__ "[%d] -> %s(%s) \n", __LINE__, __func__, pmbbo->name); #endif p_myContext = (CONTEXT *)calloc(1, sizeof(CONTEXT)); p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetUser(pmbbo,p_myCallback); callbackSetCallback(myCallback_devMbboAsyncGpib,p_myCallback); p_myContext->p_callback=p_myCallback; if (sscanf(pmbbo->out.value.instio.string, "gba=%d gpa=%d", &p_myContext->gpibBoardAddress, &p_myContext->primaryAddress) != 2 ) { printf( __FILE__ "[%d] Error: Couldn't parse the parameters correctly!", __LINE__ ); printf( __FILE__ "[%d] >%s<!", __LINE__, pmbbo->out.value.instio.string ); sleep(SLEEPTIME_ERROR); return(ERROR); } /* end_of_if */ p_myContext->secondaryAddress=0; p_myContext->gpibDeviceHandle = gpibOpenDevice( p_myContext->gpibBoardAddress, p_myContext->primaryAddress, p_myContext->secondaryAddress); pmbbo->dpvt = (void *)p_myContext; #ifdef WARMSTART pmbbo->omsl=menuOmslclosed_loop; pmbbo->pini=1; #endif #ifdef DEBUG2 printf( __FILE__ "[%d] gpibBoardAddress= %d\n", __LINE__,p_myContext->gpibBoardAddress); printf( __FILE__ "[%d] primaryAddress = %d\n", __LINE__,p_myContext->primaryAddress); printf( __FILE__ "[%d] gpibDeviceHandle= %d\n", __LINE__, p_myContext->gpibDeviceHandle); #endif return(SUCCESS); }
bool AbstractPackagingStep::isPackagingNeeded() const { QFileInfo packageInfo(packageFilePath()); if (!packageInfo.exists() || d->deploymentDataModified) return true; const DeploymentData &dd = target()->deploymentData(); for (int i = 0; i < dd.fileCount(); ++i) { if (Utils::FileUtils::isFileNewerThan(dd.fileAt(i).localFilePath(), packageInfo.lastModified())) { return true; } } return false; }
bool AbstractPackagingStep::isPackagingNeeded() const { const QSharedPointer<DeploymentInfo> &deploymentInfo = deployConfiguration()->deploymentInfo(); QFileInfo packageInfo(packageFilePath()); if (!packageInfo.exists() || deploymentInfo->isModified()) return true; const int deployableCount = deploymentInfo->deployableCount(); for (int i = 0; i < deployableCount; ++i) { if (Utils::FileUtils::isFileNewerThan(deploymentInfo->deployableAt(i).localFilePath, packageInfo.lastModified())) return true; } return false; }
static long dsetInit_devMbbiDirectAsyncGpib (mbbiDirectRecord *p_mbbiDirect) { CONTEXT *p_myContext; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s) \n", __LINE__, __func__,p_mbbiDirect->name); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); sscanf(p_mbbiDirect->inp.value.instio.string, "gba=%d gpa=%d c=%[^\n]", &p_myContext->gpibBoardAddress, &p_myContext->gpibPrimaryAddress, p_myContext->p_gpibCommand); p_myContext->gpibSecondaryAddress=0; p_myContext->gpibDeviceHandle=gpibOpenDevice( p_myContext->gpibBoardAddress, p_myContext->gpibPrimaryAddress, p_myContext->gpibSecondaryAddress); dsetLog(5, __FILE__ "[%d] Parsed options >%s<\n", __LINE__, p_mbbiDirect->inp.value.instio.string); dsetLog(5, __FILE__ "[%d] gpibBoardAddress = %d\n", __LINE__,p_myContext->gpibBoardAddress); dsetLog(5, __FILE__ "[%d] gpibPrimaryAddress = %d\n", __LINE__, p_myContext->gpibPrimaryAddress); dsetLog(5, __FILE__ "[%d] gpibSecondaryAddress= %d\n", __LINE__, p_myContext->gpibSecondaryAddress); dsetLog(5, __FILE__ "[%d] p_gpibCommand = >%s<\n", __LINE__, p_myContext->p_gpibCommand); dsetLog(5, __FILE__ "[%d] gpibDeviceHandle = %d\n", __LINE__, p_myContext->gpibDeviceHandle); p_myContext->p_callback=(CALLBACK *)(calloc(1,sizeof(CALLBACK))); callbackSetCallback(myCallback_devMbbiDirectAsyncGpib,p_myContext->p_callback); callbackSetUser(p_mbbiDirect,p_myContext->p_callback); p_mbbiDirect->dpvt=(void *)p_myContext; dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__); return(SUCCESS); }
/* -------------------------------------------------------------------- *\ * DSET METHODS \* -------------------------------------------------------------------- */ static long dsetInit_devMbboAsyncGpib(mbboRecord *pmbbo) { int myGpibBoardAddress; int myPrimaryAddress; int mySecondaryAddress; int myGpibDeviceHandle; CONTEXT *p_myContext; CALLBACK *p_myCallback; packageInfo(); dsetLog(3,__FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__,pmbbo->name ); p_myContext = (CONTEXT *)calloc(1, sizeof(CONTEXT)); p_myCallback = (CALLBACK *)calloc(1, sizeof(CALLBACK)); callbackSetUser(pmbbo,p_myCallback); callbackSetCallback(myCallback_devMbboAsyncGpib,p_myCallback); sscanf(pmbbo->out.value.instio.string, "gba=%d gpa=%d", &myGpibBoardAddress, &myPrimaryAddress); mySecondaryAddress=0; dsetLog(5,__FILE__ "[%d] params = >%s<\n", __LINE__, pmbbo->out.value.instio.string); dsetLog(5,__FILE__ "[%d] gpibBoardAddress = %d\n", __LINE__, myGpibBoardAddress); dsetLog(5,__FILE__ "[%d] primaryAddress = %d\n", __LINE__, myPrimaryAddress); dsetLog(5,__FILE__ "[%d] secondayAddress = %d\n", __LINE__, mySecondaryAddress); myGpibDeviceHandle = gpibOpenDevice( myGpibBoardAddress, myPrimaryAddress, mySecondaryAddress); p_myContext->gpibBoardAddress=myGpibBoardAddress; p_myContext->gpibDeviceHandle=myGpibDeviceHandle; p_myContext->primaryAddress=myPrimaryAddress; p_myContext->p_callback=p_myCallback; pmbbo->dpvt = (void *)p_myContext; dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__); return(SUCCESS); }
static long dsetInit_devAiAsyncEthernet(aiRecord *pai) { CONTEXT *p_myContext; int myServicePortNumber; SOCKET mySocket=-1; char p_myCommand[BUFLEN]; char p_myServerName[BUFLEN]; CALLBACK *p_myCallback; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pai->name); if (sscanf(pai->inp.value.instio.string, "sn=%s spn=%d c=%[^\n]", p_myServerName, &myServicePortNumber, p_myCommand)!=3) { dsetLog(1, __FILE__ "[%d] Error: %s\n", __LINE__, pai->name); dsetLog(1, __FILE__ "[%d] Error: Couldn't parse parameters\n", __LINE__); dsetLog(1, __FILE__ "[%d] Error: Parameters >%s<\n", __LINE__, pai->inp.value.instio.string); sleep(SLEEPTIME_ERROR); return(ERROR); } dsetLog(5,__FILE__ "[%d] p_serverName= >%s<\n",__LINE__,p_myServerName); dsetLog(5,__FILE__ "[%d] servicePort = %d\n",__LINE__,myServicePortNumber); dsetLog(5,__FILE__ "[%d] p_Command = >%s<\n",__LINE__,p_myCommand); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetUser(pai,p_myCallback); callbackSetCallback(myCallback_devAiAsyncEthernet,p_myCallback); p_myContext->p_callback=p_myCallback; p_myContext->servicePortNumber=myServicePortNumber; p_myContext->socket=mySocket; strncpy(p_myContext->p_command, p_myCommand, BUFLEN); strncpy(p_myContext->p_serverName, p_myServerName, BUFLEN); pai->dpvt=(void *)p_myContext; dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__); return(SUCCESS); }
bool ZmdUpdaterCore::qt_emit( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->signalOffset() ) { case 0: userListing((QValueList<Identity>)(*((QValueList<Identity>*)static_QUType_ptr.get(_o+1)))); break; case 1: serviceListing((QValueList<Service>)(*((QValueList<Service>*)static_QUType_ptr.get(_o+1)))); break; case 2: catalogListing((QValueList<Catalog>)(*((QValueList<Catalog>*)static_QUType_ptr.get(_o+1)))); break; case 3: patchListing((QValueList<Patch>)(*((QValueList<Patch>*)static_QUType_ptr.get(_o+1)))); break; case 4: updateListing((QValueList<Package>)(*((QValueList<Package>*)static_QUType_ptr.get(_o+1)))); break; case 5: lockListing((QValueList<PackageLock>)(*((QValueList<PackageLock>*)static_QUType_ptr.get(_o+1)))); break; case 6: packageInfo((Package)(*((Package*)static_QUType_ptr.get(_o+1)))); break; case 7: packageDetails((PackageDetails)(*((PackageDetails*)static_QUType_ptr.get(_o+1)))); break; case 8: realPackages((QValueList<Package>)(*((QValueList<Package>*)static_QUType_ptr.get(_o+1))),(QValueList<Package>)(*((QValueList<Package>*)static_QUType_ptr.get(_o+2))),(QValueList<Package>)(*((QValueList<Package>*)static_QUType_ptr.get(_o+3)))); break; case 9: transactionFinished((int)static_QUType_int.get(_o+1),(QString)static_QUType_QString.get(_o+2)); break; case 10: serviceAdded((QString)static_QUType_QString.get(_o+1),(int)static_QUType_int.get(_o+2),(QString)static_QUType_QString.get(_o+3)); break; case 11: generalFault((QString)static_QUType_QString.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 12: progress((Progress)(*((Progress*)static_QUType_ptr.get(_o+1)))); break; case 13: downloadProgress((Progress)(*((Progress*)static_QUType_ptr.get(_o+1)))); break; default: return QObject::qt_emit(_id,_o); } return TRUE; }
bool TupPackageHandler::makePackage(const QString &projectPath, const QString &packagePath) { if (!QFile::exists(projectPath)) { #ifdef K_DEBUG tError() << "TupPackageHandler::makePackage() - Project path doesn't exist -> " << projectPath; #endif return false; } QFileInfo packageInfo(packagePath); QuaZip zip(packagePath); if (!zip.open(QuaZip::mdCreate)) { #ifdef K_DEBUG tError() << "TupPackageHandler::makePackage() - Error while create package: " << zip.getZipError(); #endif return false; } if (! compress(&zip, projectPath)) { #ifdef K_DEBUG tError() << "TupPackageHandler::makePackage() - Error while compress project" << zip.getZipError(); #endif return false; } zip.close(); if (zip.getZipError() != 0) { #ifdef K_DEBUG tError() << "TupPackageHandler::makePackage() - Error: " << zip.getZipError(); #endif return false; } return true; }
uint32 PackageInstall::_Install() { PackageInfo* info = fParent->GetPackageInfo(); pkg_profile* type = static_cast<pkg_profile*>(info->GetProfile( fParent->CurrentType())); uint32 n = type->items.CountItems(); uint32 m = info->GetScriptCount(); PackageStatus* progress = fParent->StatusWindow(); progress->Reset(n + m + 5); progress->StageStep(1, B_TRANSLATE("Preparing package")); InstalledPackageInfo packageInfo(info->GetName(), info->GetVersion()); status_t err = packageInfo.InitCheck(); if (err == B_OK) { // The package is already installed, inform the user BAlert* reinstall = new BAlert("reinstall", B_TRANSLATE("The given package seems to be already installed on " "your system. Would you like to uninstall the existing one " "and continue the installation?"), B_TRANSLATE("Continue"), B_TRANSLATE("Abort")); reinstall->SetShortcut(1, B_ESCAPE); if (reinstall->Go() == 0) { // Uninstall the package err = packageInfo.Uninstall(); if (err != B_OK) { fprintf(stderr, "Error uninstalling previously installed " "package: %s\n", strerror(err)); // Ignore error } err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true); if (err != B_OK) { fprintf(stderr, "Error marking installation of package: " "%s\n", strerror(err)); return P_MSG_I_ERROR; } } else { // Abort the installation return P_MSG_I_ABORT; } } else if (err == B_ENTRY_NOT_FOUND) { err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true); if (err != B_OK) { fprintf(stderr, "Error marking installation of package: " "%s\n", strerror(err)); return P_MSG_I_ERROR; } } else if (progress->Stopped()) { return P_MSG_I_ABORT; } else { fprintf(stderr, "returning on error\n"); return P_MSG_I_ERROR; } progress->StageStep(1, B_TRANSLATE("Installing files and folders")); // Install files and directories packageInfo.SetName(info->GetName()); // TODO: Here's a small problem, since right now it's not quite sure // which description is really used as such. The one displayed on // the installer is mostly package installation description, but // most people use it for describing the application in more detail // then in the short description. // For now, we'll use the short description if possible. BString description = info->GetShortDescription(); if (description.Length() <= 0) description = info->GetDescription(); packageInfo.SetDescription(description.String()); packageInfo.SetSpaceNeeded(type->space_needed); fItemExistsPolicy = P_EXISTS_NONE; const char* installPath = fParent->CurrentPath()->Path(); for (uint32 i = 0; i < n; i++) { ItemState state(fItemExistsPolicy); PackageItem* item = static_cast<PackageItem*>(type->items.ItemAt(i)); err = item->DoInstall(installPath, &state); if (err == B_FILE_EXISTS) { // Writing to path failed because path already exists - ask the user // what to do and retry the writing process int32 choice = fParent->ItemExists(*item, state.destination, fItemExistsPolicy); if (choice != P_EXISTS_ABORT) { state.policy = choice; err = item->DoInstall(installPath, &state); } } if (err != B_OK) { fprintf(stderr, "Error while writing path\n"); return P_MSG_I_ERROR; } if (progress->Stopped()) return P_MSG_I_ABORT; // Update progress progress->StageStep(1, NULL, get_item_progress_string(i, n).String()); // Mark installed item in packageInfo packageInfo.AddItem(state.destination.Path()); } progress->StageStep(1, B_TRANSLATE("Running post-installation scripts"), ""); // Run all scripts // TODO: Change current working directory to installation location! for (uint32 i = 0; i < m; i++) { PackageScript* script = info->GetScript(i); fCurrentScriptLocker.Lock(); fCurrentScript = script; status_t status = script->DoInstall(installPath); if (status != B_OK) { fprintf(stderr, "Error while running script: %s\n", strerror(status)); fCurrentScriptLocker.Unlock(); return P_MSG_I_ERROR; } fCurrentScriptLocker.Unlock(); wait_for_thread(script->GetThreadId(), &status); fCurrentScriptLocker.Lock(); script->SetThreadId(-1); fCurrentScript = NULL; fCurrentScriptLocker.Unlock(); if (progress->Stopped()) return P_MSG_I_ABORT; progress->StageStep(1, NULL, get_item_progress_string(i, m).String()); } progress->StageStep(1, B_TRANSLATE("Finishing installation"), ""); err = packageInfo.Save(); if (err != B_OK) return P_MSG_I_ERROR; progress->StageStep(1, B_TRANSLATE("Done")); // Inform our parent that we finished return P_MSG_I_FINISHED; }
/* -------------------------------------------------------------------- *\ * DSET METHODS \* -------------------------------------------------------------------- */ static long dsetInit_devAiSyncComedi(aiRecord *pai) { CONTEXT *p_myContext; int myMinorOfDeviceFile; int myPinNumber; int myChannel = 0; int mySubdevice = 0; int myRange = 0; int myAnalogReference = AREF_DIFF; int myNumberOfRanges; char p_myDeviceFile[BUFLEN]; comedi_t *p_myComediFileHandle; int i; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pai->name ); sscanf(pai->inp.value.instio.string, "modf=%d pn=%d", &myMinorOfDeviceFile, &myPinNumber); sprintf(p_myDeviceFile, "/dev/comedi%d", myMinorOfDeviceFile); dsetLog(5,__FILE__ "[%d] minorOfDeviceFile >%d<\n", __LINE__, myMinorOfDeviceFile); dsetLog(5,__FILE__ "[%d] pinNumber >%d<\n", __LINE__, myPinNumber); dsetLog(5,__FILE__ "[%d] deviceFile >%s<\n", __LINE__, p_myDeviceFile); /** * Convert the pin number to the appropriate channel number. */ for (i = 0; i < MAX_NUM_CHANNELS; i++) { if (pinsToChannels[i] == myPinNumber) { myChannel = i; } } p_myComediFileHandle = comedi_open(p_myDeviceFile); if (!p_myComediFileHandle) { comedi_perror(p_myDeviceFile); dsetLog(1, __FILE__ "[%d] Error: Failed to open the file handler\n", __LINE__); sleep(SLEEPTIME_ERROR); return(ERROR); } mySubdevice = comedi_find_subdevice_by_type(p_myComediFileHandle, COMEDI_SUBD_AI, 0); if (mySubdevice < 0) { dsetLog(1, __FILE__ "[%d] Error: Couldn't find an analog input subdevice\n", __LINE__); sleep(SLEEPTIME_ERROR); return(ERROR); } dsetLog(5,__FILE__ "[%d] mySubdevice = %d\n", __LINE__, mySubdevice); myNumberOfRanges = comedi_get_n_ranges(p_myComediFileHandle, mySubdevice, myChannel); dsetLog(5,__FILE__ "[%d] # of comedi range = %d\n", __LINE__, myNumberOfRanges); p_myContext = (CONTEXT *)calloc(1, sizeof(CONTEXT)); strcpy(p_myContext->p_deviceFile, p_myDeviceFile); p_myContext->channel = myChannel; p_myContext->range = myRange; p_myContext->pinNumber = myPinNumber; p_myContext->subdevice = mySubdevice; p_myContext->analogReference = myAnalogReference; p_myContext->p_comediFileHandle = p_myComediFileHandle; pai->dpvt = p_myContext; dsetLog(3,__FILE__ "[%d] <- %s\n", __LINE__, __func__); return(SUCCESS); }
static long dsetInit_devAiAsyncSerial(aiRecord *pai) { CONTEXT *p_myContext; CALLBACK *p_myCallback; int myPortNumber; int myPrimaryAddress; int myNumberOfDataBits; int myParity; int myNumberOfStopBits; int myBaudRate; char p_myCommand[BUFLEN]; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pai->name); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetUser(pai,p_myCallback); callbackSetCallback(myCallback_devAiAsyncSerial,p_myCallback); p_myContext->p_callback=p_myCallback; pai->dpvt = (void *)p_myContext; if (sscanf(pai->inp.value.instio.string, "spn=%d spa=%d br=%d nodb=%d p=%d nosb=%d c=%[^\n]", &myPortNumber, &myPrimaryAddress, &myBaudRate, &myNumberOfDataBits, &myParity, &myNumberOfStopBits, p_myCommand)!=7) { dsetLog(1, __FILE__ "[%d] Error: Couldn't parse paramters\n", __LINE__); dsetLog(1, __FILE__ "[%d] Error: Parameters >%s<\n", __LINE__, pai->inp.value.instio.string); sleep(SLEEPTIME_ERROR); return(ERROR); } dsetLog(5,__FILE__ "[%d] portNumber = %d\n",__LINE__,myPortNumber); dsetLog(5,__FILE__ "[%d] baudRate = %d\n",__LINE__,myBaudRate); dsetLog(5,__FILE__ "[%d] parity = %d\n",__LINE__,myParity); dsetLog(5,__FILE__ "[%d] numberOfDataBits= %d\n",__LINE__,myNumberOfDataBits); dsetLog(5,__FILE__ "[%d] numberOfStopBits= %d\n",__LINE__,myNumberOfStopBits); dsetLog(5,__FILE__ "[%d] serialCommand = >%s<\n",__LINE__,p_myCommand); initSerialPort2(myPortNumber); setBaudRate2(myPortNumber,myBaudRate); setNumberOfDataBits2(myPortNumber,myNumberOfDataBits); setParity2(myPortNumber,myParity); setFlowControl2(myPortNumber,COMBINED_FLOW_CONTROL); /* setFlowControl2(myPortNumber,NO_FLOW_CONTROL); * Required for this dev */ setNumberOfStopBits2(myPortNumber,myNumberOfStopBits); openSerialPort2(myPortNumber); p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetCallback(myCallback_devAiAsyncSerial,p_myCallback); callbackSetUser(pai,p_myCallback); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myContext->portNumber=myPortNumber; p_myContext->p_callback=p_myCallback; p_myContext->primaryAddress=myPrimaryAddress; strncpy(p_myContext->p_command, p_myCommand, BUFLEN); pai->dpvt=(void *)p_myContext; dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__); return(SUCCESS); }
static long dsetInit_devAiAsyncGpib(aiRecord *pai) { int gpibBoardAddress; int gpibPrimaryAddress; int gpibSecondaryAddress=0; char *p_gpibCommand; /* Pointer to the gpib read command */ int index=0; /* An array index */ int gpibDeviceHandle; /* A handle to communicate with the dev */ CALLBACK *p_myCallback; CONTEXT *p_myContext; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pai->name ); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); sscanf(pai->inp.value.instio.string, "gba=%d gpa=%d c=%[^\n]", &p_myContext->gpibBoardAddress, &p_myContext->gpibPrimaryAddress, p_myContext->p_gpibCommand); p_myContext->gpibSecondaryAddress=0; gpibBoardAddress=p_myContext->gpibBoardAddress; gpibPrimaryAddress=p_myContext->gpibPrimaryAddress; gpibSecondaryAddress=p_myContext->gpibSecondaryAddress; p_gpibCommand=p_myContext->p_gpibCommand; p_myContext->gpibDeviceHandle = gpibOpenDevice(gpibBoardAddress, gpibPrimaryAddress, gpibSecondaryAddress); gpibDeviceHandle=p_myContext->gpibDeviceHandle; dsetLog(5, __FILE__ "[%d] Param = >%s<\n", __LINE__, pai->inp.value.instio.string); dsetLog(5, __FILE__ "[%d] gpibBoardAddress = %d\n", __LINE__, gpibBoardAddress); dsetLog(5, __FILE__ "[%d] gpibPrimaryAddress= %d\n", __LINE__, gpibPrimaryAddress); dsetLog(5, __FILE__ "[%d] command = >%s<\n", __LINE__, p_gpibCommand); dsetLog(5, __FILE__ "[%d] gpibDeviceHandle = %d\n", __LINE__, gpibDeviceHandle); /* IOC and Instrument must agree on */ /* input/output format. */ dsetLog(5, __FILE__ "[%d] -- %s -- Input Formating\n",__LINE__, __func__); if (p_myContext->gpibInitDevice) { /* initialize the device */ index=0; while (dataFormatCommand[index]) { dsetLog(5, __FILE__ "[%d] Sending >%s< to %s\n", __LINE__ , dataFormatCommand[index], pai->name); /* Write command on gpib */ gpibWrite(gpibDeviceHandle, dataFormatCommand[index]); usleep(30000); /* Pause: Do not write on gpib too fast!*/ index++; /* Get ready to send following message */ } /* end_of_while */ } p_myCallback=(CALLBACK *)(calloc(1,sizeof(CALLBACK))); callbackSetCallback(myCallback_devAiAsyncGpib,p_myCallback); callbackSetUser(pai,p_myCallback); p_myContext->p_callback=p_myCallback; pai->dpvt=(void *)p_myContext; dsetLog(3, __FILE__ "[%d] <- %s \n", __LINE__, __func__ ); return(SUCCESS); }
static long dsetInit_devMbboAsyncSerial(mbboRecord *pmbbo) { CONTEXT *p_myContext; CALLBACK *p_myCallback; int mySerialPrimaryAddress; int mySerialPortNumber; int myParity; int myNumberOfDataBits; int myNumberOfStopBits; int myBaudRate; char p_myCommand[BUFLEN]; packageInfo(); dsetLog(3,__FILE__ "[%d] -> %s (%s)\n", __LINE__, __func__, pmbbo->name); if(sscanf(pmbbo->out.value.instio.string, "spn=%d spa=%d br=%d nodb=%d p=%d nosb=%d c=%[^\n]", &mySerialPortNumber, &mySerialPrimaryAddress, &myBaudRate, &myNumberOfDataBits, &myParity, &myNumberOfStopBits, p_myCommand)!=7) { dsetLog(1,__FILE__ "[%d] Error: Couldn't parse the parameters correctly!\n", __LINE__ ); dsetLog(1,__FILE__ "[%d] Params >%s<!\n", __LINE__, pmbbo->out.value.instio.string ); sleep(SLEEPTIME_ERROR); return(ERROR); } initSerialPort2(mySerialPortNumber); setBaudRate2(mySerialPortNumber,myBaudRate); setNumberOfDataBits2(mySerialPortNumber,myNumberOfDataBits); setParity2(mySerialPortNumber,myParity); /* setFlowControl2(mySerialPortNumber,NO_FLOW_CONTROL); Required for this dev */ setNumberOfStopBits2(mySerialPortNumber,myNumberOfStopBits); if (openSerialPort2(mySerialPortNumber) <= ERROR ) { dsetLog(1, __FILE__ "[%d] Error: Couldn't open serial port (%s)\n", __LINE__, getSerialPortName2(mySerialPortNumber)); sleep(SLEEPTIME_ERROR); return(ERROR); } dsetLog(5,__FILE__ "[%d] serialPortNumber = %d\n", __LINE__, mySerialPortNumber); dsetLog(5,__FILE__ "[%d] serialPrimaryAddress = %d\n", __LINE__, mySerialPrimaryAddress); dsetLog(5,__FILE__ "[%d] baudRate = %d\n", __LINE__, getBaudRate2(mySerialPortNumber)); dsetLog(5,__FILE__ "[%d] numberOfDataBits = %d\n", __LINE__, getNumberOfDataBits2(mySerialPortNumber)); dsetLog(5,__FILE__ "[%d] parity = %d\n", __LINE__, getParity2(mySerialPortNumber)); dsetLog(5,__FILE__ "[%d] numberOfStopBits = %d\n", __LINE__, getNumberOfStopBits2(mySerialPortNumber)); p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetCallback(myCallback_devMbboAsyncSerial,p_myCallback); callbackSetUser(pmbbo,p_myCallback); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myContext->serialPortNumber=mySerialPortNumber; p_myContext->p_callback=p_myCallback; p_myContext->serialPrimaryAddress=mySerialPrimaryAddress; strncpy(p_myContext->p_command, p_myCommand, BUFLEN); p_myContext->operatingMode=NORMAL_MODE; #ifdef WARMSTART p_myContext->operatingMode=WARMSTART_MODE; pmbbo->pini=1; pmbbo->omsl=menuOmslclosed_loop; #endif pmbbo->dpvt=(void *)p_myContext; dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__); return(SUCCESS); }
static long dsetInit_devAiAsyncGpib(aiRecord *pai) { CONTEXT *p_myContext; CALLBACK *p_myCallback; char p_writeBuffer[BUFLEN]; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s (%s)\n", __LINE__, __func__, pai->name); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetUser(pai,p_myCallback); callbackSetCallback(myCallback_devAiAsyncGpib,p_myCallback); p_myContext->pcallback=p_myCallback; pai->dpvt = (void *)p_myContext; if ( sscanf(pai->inp.value.instio.string, "gba=%d gpa=%d c=%[^\n]", &p_myContext->gpibBoardAddress, &p_myContext->gpibPrimaryAddress, p_myContext->p_gpibCommand)!=3) { dsetLog(1, __FILE__ "[%d] Error: Couldn't parse paramters\n", __LINE__); dsetLog(1, __FILE__ "[%d] Parameters >%s<\n", __LINE__, pai->inp.value.instio.string); sleep(SLEEPTIME_ERROR); return(ERROR); } /* Open the connection with the device */ p_myContext->gpibSecondaryAddress=0; p_myContext->gpibDeviceHandle = gpibOpenDevice( p_myContext->gpibBoardAddress, p_myContext->gpibPrimaryAddress, p_myContext->gpibSecondaryAddress); dsetLog(5, __FILE__ "[%d] %s\n", __LINE__, pai->name); dsetLog(5, __FILE__ "[%d] gpibBoardAddress= %d\n", __LINE__, p_myContext->gpibBoardAddress); dsetLog(5, __FILE__ "[%d] primaryAddress = %d\n", __LINE__, p_myContext->gpibPrimaryAddress); dsetLog(5, __FILE__ "[%d] p_gpibCommand = >%s<\n", __LINE__, p_myContext->p_gpibCommand); dsetLog(5, __FILE__ "[%d] secondaryAddress= %d\n", __LINE__, p_myContext->gpibSecondaryAddress); dsetLog(5, __FILE__ "[%d] gpibDeviceHandle = %d\n", __LINE__, p_myContext->gpibDeviceHandle); /* set units to farenheit & convert later for greater precision */ sprintf(p_writeBuffer,"UNIT %d,FHRN\n", p_myContext->gpibSecondaryAddress); dsetLog(5,__FILE__ "[%d] Writing >%s< on %s\n", __LINE__, p_writeBuffer, pai->name); if (gpibWrite(p_myContext->gpibDeviceHandle, p_writeBuffer)<=ERROR) { dsetLog(1, __FILE__ "[%d] Error: Couldn't write >%s< on %s\n", __LINE__, p_writeBuffer, pai->name); sleep(SLEEPTIME_ERROR); return(ERROR); } sleep(1); /* SR630 can't take commands too quickly */ dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); return(SUCCESS); }
static long dsetInit_devAoSyncAdlink (aoRecord *pao) { CONTEXT *p_myContext; ADLINKDEV_AO *p_myAnalogOutput; int myPinNumber; int myCardIdentifier; double myMinimumVoltage; double myMaximumVoltage; int i; int myMinorNumber; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pao->name ); p_myAnalogOutput=(ADLINKDEV_AO *)calloc(1, sizeof(ADLINKDEV_AO)); /** * Get the card and pin numbers. */ if (sscanf(pao->out.value.instio.string, "ci=%d pn=%d", &myCardIdentifier, &myPinNumber) != 2) { dsetLog(1, __FILE__ "[%d] Error: %s\n", __LINE__, pao->name); dsetLog(1, __FILE__ "[%d] Error: Couldn't parse parameters\n", __LINE__); dsetLog(1, __FILE__ "[%d] Error: >%s<\n", __LINE__,pao->out.value.instio.string); sleep(SLEEPTIME_ERROR); return(ERROR); } myMinorNumber=myCardIdentifier-1; /** * Set the device filename. */ sprintf(p_myAnalogOutput->p_deviceFilename,"/dev/PCI6208W%d", (myMinorNumber)); /** * Initialize the DAQ 6208 card. */ if ((p_myAnalogOutput->cardHandle = Register_Card(PCI_6208V, myMinorNumber)) < NoError) { dsetLog(1, __FILE__ "[%d] Error: %s\n", __LINE__, pao->name); dsetLog(1, __FILE__ "[%d] Error: Failed to register with the card\n", __LINE__); sleep(SLEEPTIME_ERROR); return(ERROR); } /** * Convert the pin number to the appropriate channel number. */ for (i = 0; i < MAX_NUM_CHANNELS; i++) { if (pinToChannels[i] == myPinNumber) { p_myAnalogOutput->channel=i; } } /** * Set the voltage values. */ myMinimumVoltage=pao->drvl; myMaximumVoltage=pao->drvh; p_myAnalogOutput->range=getOptimalOperatingRange(pao); dsetLog(5,__FILE__ "[%d] Parsed options >%s<\n", __LINE__, pao->out.value.instio.string); dsetLog(5,__FILE__ "[%d] p_deviceFilename = >%s<\n", __LINE__, p_myAnalogOutput->p_deviceFilename); dsetLog(5,__FILE__ "[%d] channel = %d\n", __LINE__, p_myAnalogOutput->channel); dsetLog(5,__FILE__ "[%d] range = %d\n", __LINE__, p_myAnalogOutput->range); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myContext->p_analogOutput=p_myAnalogOutput; p_myContext->minimumVoltage=myMinimumVoltage; p_myContext->maximumVoltage=myMaximumVoltage; /** * Load the channel value from the file. */ readChannelValueFromFile(pao); pao->pini=menuYesNoYES; pao->dpvt=(void *)p_myContext; dsetLog(5, __FILE__ "[%d] Calibration algo : %d\n", __LINE__, pao->linr); dsetLog(5, __FILE__ "[%d] Calibration slope : %lg\n", __LINE__, pao->aslo); dsetLog(5, __FILE__ "[%d] Calibration offset: %lg\n", __LINE__, pao->aoff); dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); /* Convert according to calibration? NO!*/ /* Convert update val based on rval and in iwarmstart file is stored val*/ return(DO_NOT_CONVERT); }
void UpdateProcess::readStandardError() { int idx; bool ok; QString line, type; QHash<QString,QString> args; setReadChannel(QProcess::StandardError); while (canReadLine()) { line = readLine().trimmed(); vInfo("updater (stderr): %1").arg(line); idx = line.indexOf(" "); if (idx < 0 || idx == line.length()-1) continue; type = line.mid(0, idx); line = line.mid(idx + 1); args = string_parse_keyvals(line, &ok); if (! ok) continue; else if (line.startsWith("thandy.InstallFailed: ", Qt::CaseInsensitive)) { /** XXX: This is a f*****g kludge. If installation fails, Thandy just * dumps a Python traceback that (for obvious reasons) doesn't * follow the expected format. There isn't a defined control * message type for this yet we'd really like the error, so treat * this one specially. */ emit installUpdatesFailed(line); continue; } if (! type.compare("CAN_INSTALL", Qt::CaseInsensitive)) { QString package = args.value("PKG"); if (! package.isEmpty()) { PackageInfo pkgInfo = packageInfo(package); if (pkgInfo.isValid()) _packageList << pkgInfo; } } else if (_currentCommand == CheckForUpdates && ! type.compare("DEBUG") && args.value("msg").startsWith("Got ")) { /* XXX: This is an even worse f*****g kludge. Thandy only reports * download progress in a not-so-parser-friendly log message, * though, so we must kludge again. * * Here's an example of what we're parsing: * "Got 1666048/1666560 bytes from http://updates.torproject.org/thandy/data/win32/tor-0.2.1.9-alpha.msi" * * (Note that the kludge above would even match on "Got milk?".) */ QStringList parts = args.value("msg").split(" "); if (parts.size() == 5) { QStringList progress = parts.at(1).split("/"); if (progress.size() == 2) { int bytesReceived = progress.at(0).toUInt(); int bytesTotal = progress.at(1).toUInt(); vInfo("updater: Downloaded %1 of %2 bytes of file %3").arg(bytesReceived) .arg(bytesTotal) .arg(parts.at(4)); emit downloadProgress(parts.at(4), bytesReceived, bytesTotal); } } } } }
/*----------------------------------------------------------------------*/ extern int openSerialPort2( int portNumber ) { struct termios term_info; /* Communication port attribute */ int BAUDRATE; /* A flag to configure communication */ int HARDWARE_CONTROL_MODE; /* Another flag to configure the com */ SERIALPORT *p_mySerialPort; struct file *p_myDeviceFile; /* A pointer to the attached device file*/ #ifdef DEBUG1 packageInfo(); printf(__FILE__ "[%d] -> %s(%d)\n", __LINE__, __func__, portNumber); #endif /* Basic error checking */ if (portNumber<0) { printf( __FILE__ "[%d] Error: portNumber is not valid (%d)\n", __LINE__, portNumber); sleep(SLEEPTIME_ERROR); return(ERROR); } if (portNumber>=MAX_NB_OF_SERIAL_PORTS_PER_CPU) { printf( __FILE__ "[%d] Error: portNumber (%d) is too big (> %d)\n", __LINE__, portNumber, MAX_NB_OF_SERIAL_PORTS_PER_CPU); sleep(SLEEPTIME_ERROR); return(ERROR); } p_mySerialPort=&serialPortArray[portNumber]; /* Configure the port speed */ switch(p_mySerialPort->baudRate) { case 50: BAUDRATE = B50; break; case 75: BAUDRATE = B75; break; case 110: BAUDRATE = B110; break; case 134: BAUDRATE = B134; break; case 150: BAUDRATE = B150; break; case 200: BAUDRATE = B200; break; case 300: BAUDRATE = B300; break; case 600: BAUDRATE = B600; break; case 1200: BAUDRATE = B1200; break; case 1800: BAUDRATE = B1800; break; case 2400: BAUDRATE = B2400; break; case 4800: BAUDRATE = B4800; break; case 9600: BAUDRATE = B9600; break; case 19200: BAUDRATE = B19200; break; case 38400: BAUDRATE = B38400; break; case 57600: BAUDRATE = B57600; break; case 115200: BAUDRATE = B115200; break; case 230400: BAUDRATE = B230400; break; case 460800: BAUDRATE = B460800; break; default: printf(__FILE__ "[%d] Error: Unsupported baud rate %d\n", __LINE__, p_mySerialPort->baudRate); sleep(SLEEPTIME_ERROR); return(ERROR); } #ifdef DEBUG3 printf( __FILE__ "[%d] BAUDRATE = %d (9600=%d, 19200=%d)\n", __LINE__, BAUDRATE, B9600, B19200); #endif /* Configure some more flags... */ /* Check the parity settings... */ /* Note that they are only 3 possible */ /* settings: NONE, EVEN, ODD. */ if (p_mySerialPort->parity==NO_PARITY) { if (p_mySerialPort->numberOfDataBits==8) { if(p_mySerialPort->numberOfStopBits==1) { HARDWARE_CONTROL_MODE=MODE_8N1; } else HARDWARE_CONTROL_MODE=MODE_8N2; } else { if (p_mySerialPort->numberOfStopBits==1) HARDWARE_CONTROL_MODE=MODE_7N1; else HARDWARE_CONTROL_MODE=MODE_7N2; } /* end_of_if_then_else */ } if (p_mySerialPort->parity==EVEN_PARITY) { if (p_mySerialPort->numberOfDataBits==8) { if(p_mySerialPort->numberOfStopBits==1) HARDWARE_CONTROL_MODE=MODE_8E1; else HARDWARE_CONTROL_MODE=MODE_8E2; } else { if (p_mySerialPort->numberOfStopBits==1) HARDWARE_CONTROL_MODE=MODE_7E1; else HARDWARE_CONTROL_MODE=MODE_7E2; } /* end_of_if_then_else */ } if (p_mySerialPort->parity==ODD_PARITY) { if (p_mySerialPort->numberOfDataBits==8) { if(p_mySerialPort->numberOfStopBits==1) HARDWARE_CONTROL_MODE=MODE_8O1; else HARDWARE_CONTROL_MODE=MODE_8O2; } else { if (p_mySerialPort->numberOfStopBits==1) HARDWARE_CONTROL_MODE=MODE_7O1; else HARDWARE_CONTROL_MODE=MODE_7O2; } /* end_of_if_then_else */ } #ifdef DEBUG3 printf( __FILE__ "[%d] HARDWARE_CONTROL_MODE = %d (8N1=%d)\n", __LINE__, HARDWARE_CONTROL_MODE, MODE_8N1); #endif /* Open the device file and communicate.*/ p_myDeviceFile=&p_mySerialPort->deviceFile; #ifdef DEBUG2 printf(__FILE__ "[%d] deviceFile = %s\n",__LINE__,p_myDeviceFile->name); #endif /* Open the unix device file */ /* * Open the device. * O_RDRW - open for reading and writing * O_NDELAY - ignore the state of the DCD line. Otherwise * the ioctl() blocks until DCD indicates the * remote side is ready. Also affects behavior of * the read(2) system call, which will now not block * if there is no input data available. * O_NOCTTY - Do not become a controlling terminal. Has no effect for STREAMS */ p_myDeviceFile->handle = open(p_myDeviceFile->name, O_RDWR | O_SYNC | O_NOCTTY); if (p_myDeviceFile->handle <= FILE_IS_CLOSED) { printf(__FILE__ "[%d] Error: Cannot open %s\n", __LINE__, p_myDeviceFile->name); sleep(SLEEPTIME_ERROR); return(ERROR); } /* end_of_if */ /* Configure terminal */ /* Get current terminale attributes */ if ((tcgetattr(p_myDeviceFile->handle, &term_info)) == ERROR) { printf(__FILE__ "[%d] Error: Can't tcgetattr on %s\n", __LINE__, p_myDeviceFile->name); sleep(SLEEPTIME_ERROR); return(ERROR); } /* end_of_if */ /* CFLAG: Control mode */ /* Configuring communication w/ device */ term_info.c_cflag |= HARDWARE_CONTROL_MODE; /* Enable the receipt of characters */ term_info.c_cflag |= CREAD; /* Additional configuration... */ /* ... setup raw mode */ /* OFLAG: Output mode */ /* Turn off output processing */ term_info.c_oflag &= ~OPOST; /* LFLAG: Local mode */ /* XCASE? */ /* Do not echo NewLine character */ /* Enable flush on queue */ term_info.c_lflag &= ~(XCASE|ECHONL|NOFLSH); /* Disable canonical input processing */ /* Disable signals */ /* Disable local echoing of input char. */ term_info.c_lflag &= ~(ICANON | ISIG | ECHO); /* IFLAG: Input mode */ /* Disable conversion of received */ /* carriage return (/r) in newline (/n) */ /* and vice-versa. */ term_info.c_iflag &= ~(ICRNL|INLCR); #ifdef DEBUG3 printf( __FILE__ "[%d] term_info.c_cflag = %d\n",__LINE__,term_info.c_cflag); printf( __FILE__ "[%d] term_info.c_lflag = %d\n",__LINE__,term_info.c_lflag); printf( __FILE__ "[%d] term_info.c_iflag = %d\n",__LINE__,term_info.c_iflag); printf( __FILE__ "[%d] term_info.c_oflag = %d\n",__LINE__,term_info.c_oflag); #endif /* Flow control */ /* Required for the HPS937A */ switch (p_mySerialPort->flowControl) { case NO_FLOW_CONTROL: term_info.c_cflag &= ~CRTSCTS; term_info.c_iflag &= ~(IXOFF|IXON|IXANY); break; case SOFTWARE_FLOW_CONTROL: term_info.c_cflag &= ~CRTSCTS; term_info.c_iflag |= (IXOFF|IXON|IXANY); break; case HARDWARE_FLOW_CONTROL: term_info.c_cflag |= CRTSCTS; term_info.c_iflag &= ~(IXOFF|IXON|IXANY); break; case COMBINED_FLOW_CONTROL: term_info.c_cflag |= CRTSCTS; term_info.c_iflag |= (IXOFF|IXON|IXANY); break; default: printf( __FILE__ "[%d] Error: Unknown flow control (%d)\n", __LINE__, p_mySerialPort->flowControl); } #ifdef DEBUG3 printf( __FILE__ "[%d] term_info.c_cflag = %d\n",__LINE__,term_info.c_cflag); printf( __FILE__ "[%d] term_info.c_lflag = %d\n",__LINE__,term_info.c_lflag); printf( __FILE__ "[%d] term_info.c_iflag = %d\n",__LINE__,term_info.c_iflag); printf( __FILE__ "[%d] term_info.c_oflag = %d\n",__LINE__,term_info.c_oflag); #endif /* According to ICANON, we are in a */ /* non-canonical mode.Now look at the */ /* control characters */ /* VTIME and VMIN are used only in non */ /* canonical mode. */ /* MIN=0 & TIME>0, in this case the fct */ /* 'read' will return when any character*/ /* is available to be read of when TIME */ /* tenths of second have elapsed. If no */ /* char was read because timer expired, */ /* the 'read' fct will return 0 */ term_info.c_cc[VTIME] = 5; term_info.c_cc[VMIN] = 0; /* Set the input and output line speed */ cfsetispeed(&term_info, BAUDRATE); cfsetospeed(&term_info, BAUDRATE); /* Change terminal config IMMEDIATELY */ if ((tcsetattr(p_myDeviceFile->handle, TCSANOW, &term_info)) == ERROR) { printf(__FILE__ "[%d] Error: Can't tcsetattr port %s\n", __LINE__, p_myDeviceFile->name); sleep(SLEEPTIME_ERROR); return(ERROR); } /* end_of_if */ #ifdef DEBUG2 printf(__FILE__ "[%d] %s was opened successfully (%d)\n", __LINE__, getSerialPortDeviceFile2(portNumber), getSerialPortDeviceFileHandle2(portNumber)); #endif #ifdef DEBUG1 printf( __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); #endif return(SUCCESS); }
static long dsetInit_devDiSyncComedi (biRecord *pbi) { comediSupport *p_myDigitalInput; #ifdef DEBUG1 packageInfo(); printf( __FILE__ "[%d] -> %s \n", __LINE__, __func__ ); #endif #ifdef DEBUG2 printf( __FILE__ "[%d] Initializing %s\n", __LINE__, pbi->name); #endif p_myDigitalInput=(comediSupport *)calloc(1,sizeof(comediSupport)); /* Get the options from the db file */ sscanf(pbi->inp.value.instio.string, "d=%s s=%d c=%d", p_myDigitalInput->filename, &p_myDigitalInput->subdevice, &p_myDigitalInput->channel); #ifdef DEBUG2 printf(__FILE__ "[%d] Parsed options >%s<\n", __LINE__, pbi->inp.value.instio.string); printf(__FILE__ "[%d] filename = >%s<\n",__LINE__,p_myDigitalInput->filename); printf(__FILE__ "[%d] subdevice = %d\n",__LINE__, p_myDigitalInput->subdevice); printf(__FILE__ "[%d] channel = %d\n",__LINE__, p_myDigitalInput->channel); #endif p_myDigitalInput->device=comedi_open(p_myDigitalInput->filename); /* p_myDigitalInput->maxdata=comedi_get_maxdata( p_myDigitalInput->device, p_myDigitalInput->subdevice, p_myDigitalInput->channel); p_myDigitalInput->c_range=comedi_get_range( p_myDigitalInput->device, p_myDigitalInput->subdevice, p_myDigitalInput->channel, p_myDigitalInput->range); */ if ( initComediDI(p_myDigitalInput) <= ERROR ) { printf(__FILE__ "[%d] Error initializing digital input (%s)\n", __LINE__, pbi->name); sleep(SLEEPTIME_ERROR); return(ERROR); } pbi->dpvt=(void *)p_myDigitalInput; /* initialize the hardware to match the epics record value (probably 0) */ if (readComediDI((unsigned int *)&pbi->val,(comediSupport *)pbi->dpvt) <= ERROR) { printf(__FILE__ "[%d] Error: Couldn't read %s\n", __LINE__, pbi->name); sleep(SLEEPTIME_ERROR); return(ERROR); } #ifdef DEBUG1 printf( __FILE__ "[%d] <- %s\n", __LINE__, __func__); #endif return(SUCCESS); }
static long dsetInit_devDoSyncComedi (boRecord *pbo) { CONTEXT *p_myContext; comediSupport *p_myBinaryOutput; #ifdef DEBUG1 packageInfo(); printf( __FILE__ "[%d] -> %s \n", __LINE__, __func__ ); #endif #ifdef DEBUG2 printf( __FILE__ "[%d] Initializing %s\n", __LINE__, pbo->name); #endif p_myBinaryOutput=(comediSupport *)calloc(1,sizeof(comediSupport)); /* Get the options from the db file */ sscanf(pbo->out.value.instio.string, "d=%s s=%d c=%d", p_myBinaryOutput->filename, &p_myBinaryOutput->subdevice, &p_myBinaryOutput->channel); #ifdef DEBUG2 printf(__FILE__ "[%d] Parsed options >%s<\n", __LINE__, pbo->out.value.instio.string); printf(__FILE__ "[%d] filename = >%s<\n", __LINE__, p_myBinaryOutput->filename); printf(__FILE__ "[%d] subdevice = %d\n", __LINE__, p_myBinaryOutput->subdevice); printf(__FILE__ "[%d] channel = %d\n", __LINE__, p_myBinaryOutput->channel); #endif p_myBinaryOutput->device=comedi_open(p_myBinaryOutput->filename); p_myBinaryOutput->maxdata=comedi_get_maxdata( p_myBinaryOutput->device, p_myBinaryOutput->subdevice, p_myBinaryOutput->channel); /* p_myBinaryOutput->c_range=comedi_get_range( p_myBinaryOutput->device, p_myBinaryOutput->subdevice, p_myBinaryOutput->channel, p_myBinaryOutput->range); */ if (initComediDO(p_myBinaryOutput) <= ERROR ) { printf(__FILE__ "[%d] Error: Couldn't intialize %s\n", __LINE__, pbo->name); sleep(SLEEPTIME_ERROR); return(ERROR); } /* Save the context */ p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myContext->p_binaryOutput=p_myBinaryOutput; #ifdef WARMSTART p_myContext->operatingMode=WARMSTART_MODE; pbo->pini=menuYesNoYES; #endif pbo->dpvt=(void *)p_myContext; #ifdef DEBUG1 printf( __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); #endif return(SUCCESS); }
static long dsetInit_devAoSyncComedi (aoRecord *pao) { CONTEXT *p_myContext; COMEDIDEV_AO *p_myAnalogOutput; int myPinNumber; int myMinorOfDeviceFile; double myMinimumVoltage; double myMaximumVoltage; int myDifferentialMode; char p_myWarmstartFilename[BUFLEN]; FILE *p_myFileHandle; packageInfo(); dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pao->name ); p_myAnalogOutput=(COMEDIDEV_AO *)calloc(1, sizeof(COMEDIDEV_AO)); if ( sscanf(pao->out.value.instio.string, "modf=%d pn=%d dm=%d", &myMinorOfDeviceFile, &myPinNumber, &myDifferentialMode) != 3) { dsetLog(1, __FILE__ "[%d] Error: %s\n", __LINE__, pao->name); dsetLog(1, __FILE__ "[%d] Error: Couldn't parse parameters\n", __LINE__); dsetLog(1, __FILE__ "[%d] Error: >%s<\n", __LINE__,pao->out.value.instio.string); sleep(SLEEPTIME_ERROR); return(ERROR); } p_myAnalogOutput->aref=myDifferentialMode+1; /* always 2 ! */ sprintf(p_myAnalogOutput->p_deviceFilename,"/dev/comedi%d", myMinorOfDeviceFile); p_myAnalogOutput->device=comedi_open(p_myAnalogOutput->p_deviceFilename); p_myAnalogOutput->subdevice=0; p_myAnalogOutput->channel=(myPinNumber-1)/2; /* Get some values from the drivers */ p_myAnalogOutput->maxdata=comedi_get_maxdata(p_myAnalogOutput->device, p_myAnalogOutput->subdevice, p_myAnalogOutput->channel); myMinimumVoltage=pao->drvl; myMaximumVoltage=pao->drvh; p_myAnalogOutput->range=getOptimalOperatingRange(pao); p_myAnalogOutput->c_range=comedi_get_range(p_myAnalogOutput->device, p_myAnalogOutput->subdevice, p_myAnalogOutput->channel, p_myAnalogOutput->range); dsetLog(5,__FILE__ "[%d] Parsed options >%s<\n", __LINE__, pao->out.value.instio.string); dsetLog(5,__FILE__ "[%d] p_deviceFilename = >%s<\n", __LINE__, p_myAnalogOutput->p_deviceFilename); dsetLog(5,__FILE__ "[%d] subdevice = %d\n", __LINE__, p_myAnalogOutput->subdevice); dsetLog(5,__FILE__ "[%d] channel = %d\n", __LINE__, p_myAnalogOutput->channel); dsetLog(5,__FILE__ "[%d] range = %d\n", __LINE__, p_myAnalogOutput->range); dsetLog(5,__FILE__ "[%d] aref = %d\n", __LINE__, p_myAnalogOutput->aref); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myContext->p_analogOutput=p_myAnalogOutput; p_myContext->minimumVoltage=myMinimumVoltage; p_myContext->maximumVoltage=myMaximumVoltage; sprintf(p_myWarmstartFilename, WARMSTART_FILE_PREFIX "/%s", pao->name); p_myFileHandle=fopen(p_myWarmstartFilename, "r"); if (p_myFileHandle!=NULL) { fscanf(p_myFileHandle, "%lg", &pao->val); fclose(p_myFileHandle); dsetLog(5, __FILE__ "[%d] Warmstart: %lg (File) -> %s\n", __LINE__, pao->val, pao->name); } else { dsetLog(5, __FILE__ "[%d] Warmstart: %lg (Default) -> %s\n", __LINE__, pao->val , pao->name); } pao->pini=menuYesNoYES; pao->dpvt=(void *)p_myContext; dsetLog(5, __FILE__ "[%d] Calibration algo : %d\n", __LINE__, pao->linr); dsetLog(5, __FILE__ "[%d] Calibration slope : %lg\n", __LINE__, pao->aslo); dsetLog(5, __FILE__ "[%d] Calibration offset: %lg\n", __LINE__, pao->aoff); dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); /* Convert according to calibration? NO!*/ /* Convert update val based on rval and in iwarmstart file is stored val*/ return(DO_NOT_CONVERT); }
/* initialize the epics record and the hardware */ static long dsetInit_devAiAsyncSerial(aiRecord *pai) { CONTEXT *p_myContext; CALLBACK *p_myCallback; char p_writeBuffer[BUFLEN]; char p_readBuffer[BUFLEN]; int myPrimaryAddress; int myPortNumber; int myParity; int myNumberOfDataBits; int myNumberOfStopBits; int myBaudRate; char p_myCommand[BUFLEN]; #ifdef DEBUG1 packageInfo(); printf(__FILE__ "[%d] -> %s (%s)\n", __LINE__, __func__, pai->name); #endif /* Parse the db file paramters */ /* and set the value of key variables */ if(sscanf(pai->inp.value.instio.string, "spn=%d pad=%d br=%d nodb=%d p=%d nosb=%d c=%[^\n]", &myPortNumber, &myPrimaryAddress, &myBaudRate, &myNumberOfDataBits, &myParity, &myNumberOfStopBits, p_myCommand)!=7) { printf( __FILE__ "[%d] Error: Couldn't parse the parameters correctly!", __LINE__ ); printf( __FILE__ "[%d] >%s<!", __LINE__, pai->inp.value.instio.string ); sleep(SLEEPTIME_ERROR); return(ERROR); } /* end_of_if */ initSerialPort2(myPortNumber); setBaudRate2(myPortNumber,myBaudRate); setNumberOfDataBits2(myPortNumber,myNumberOfDataBits); setParity2(myPortNumber,myParity); setFlowControl2(myPortNumber,NO_FLOW_CONTROL); /* Required for this dev */ setNumberOfStopBits2(myPortNumber,myNumberOfStopBits); #ifdef DEBUG2 printf(__FILE__ "[%d] portNumber = %d\n", __LINE__, myPortNumber); printf(__FILE__ "[%d] primaryAddress = %d\n", __LINE__, myPrimaryAddress); printf(__FILE__ "[%d] baudRate = %d\n", __LINE__, getBaudRate2(myPortNumber)); printf(__FILE__ "[%d] numberOfDataBits = %d\n", __LINE__, getNumberOfDataBits2(myPortNumber)); printf(__FILE__ "[%d] parity = %d\n", __LINE__, getParity2(myPortNumber)); printf(__FILE__ "[%d] numberOfStopBits = %d\n", __LINE__, getNumberOfStopBits2(myPortNumber)); printf(__FILE__ "[%d] p_myCommand = >%s<\n", __LINE__, p_myCommand); #endif if (lockSerialPort2(myPortNumber,LOCK, pai->name)<=ERROR) { printf( __FILE__ "[%d] Error: Couldn't lock serial port (%s)\n", __LINE__, getSerialPortName2(myPortNumber)); sleep(SLEEPTIME_ERROR); return(ERROR); } /* Disable front panel */ /* This operation should work if */ /* communication parameters are ok */ strcpy(p_writeBuffer,"XFRONT"); strcat(p_writeBuffer,TERMINATOR); openSerialPort2(myPortNumber); if (writeSerialPort2(myPortNumber, p_writeBuffer ) <= ERROR) { printf( __FILE__ "[%d] Error: Couldn't write on %s\n", __LINE__, getSerialPortName2(myPortNumber)); sleep(SLEEPTIME_ERROR); return(ERROR); } usleep(USLEEPTIME_WRITE); memset(p_readBuffer,0,BUFLEN); if (readSerialPort2(myPortNumber, p_readBuffer, BUFLEN) <= ERROR) { printf( __FILE__ "[%d] Error: Couldn't read on %s\n", __LINE__, getSerialPortName2(myPortNumber)); sleep(SLEEPTIME_ERROR); return(ERROR); } usleep(USLEEPTIME_READ); if (lockSerialPort2(myPortNumber,UNLOCK, pai->name)<=ERROR) { printf ( __FILE__ "Error"); sleep(SLEEPTIME_ERROR); return(ERROR); } p_myCallback=(CALLBACK *)calloc(1,sizeof(CALLBACK)); callbackSetCallback(myCallback_devAiAsyncSerial,p_myCallback); callbackSetUser(pai,p_myCallback); p_myContext=(CONTEXT *)calloc(1,sizeof(CONTEXT)); p_myContext->portNumber=myPortNumber; p_myContext->p_callback=p_myCallback; p_myContext->primaryAddress=myPrimaryAddress; strncpy(p_myContext->p_command, p_myCommand, BUFLEN); pai->dpvt=(void *)p_myContext; /* Check acknowledgement */ if (strncmp(p_readBuffer,"OK",2)!=0) { printf( __FILE__ "[%d] Error: Couldn't communicate with %s\n", __LINE__, pai->name); printf( __FILE__ "[%d] Check configuration parameters?\n", __LINE__); return(ERROR); } #ifdef DEBUG1 printf( __FILE__ "[%d] <- %s\n", __LINE__, __func__); #endif return(SUCCESS); } /* end init_press_record() */