void rFlea_Arduino::rFlea_profile(byte rFlea_profile){ if (rFlea_profile==SENSOR){ mCH[rFlea_profile].channelNR=rFlea_profile; mCH[rFlea_profile].channelType=CHANNEL_TYPE_MASTER_TX_ONLY; mCH[rFlea_profile].networkID=0x00; mCH[rFlea_profile].deviceID=getSerialNumber(); mCH[rFlea_profile].deviceType=0x27; mCH[rFlea_profile].txType=0x01; mCH[rFlea_profile].channelFreq=DEFAULT_RADIO_CHANNEL; mCH[rFlea_profile].channelPeriod=4096; mCH[rFlea_profile].channelStatus=STATUS_ASSIGNED_CHANNEL; }else if (rFlea_profile==SENSOR_RX){ mCH[rFlea_profile].channelNR=rFlea_profile; mCH[rFlea_profile].channelType=CHANNEL_TYPE_MASTER; mCH[rFlea_profile].networkID=0x00; mCH[rFlea_profile].deviceID=getSerialNumber(); mCH[rFlea_profile].deviceType=0x27; mCH[rFlea_profile].txType=0x01; mCH[rFlea_profile].channelFreq=DEFAULT_RADIO_CHANNEL; mCH[rFlea_profile].channelPeriod=4096; mCH[rFlea_profile].channelStatus=STATUS_ASSIGNED_CHANNEL; }else if (rFlea_profile==BEACON_LISTENER){ mCH[rFlea_profile].channelNR=rFlea_profile; mCH[rFlea_profile].channelType=CHANNEL_TYPE_SLAVE; mCH[rFlea_profile].networkID=0x00; mCH[rFlea_profile].deviceID=0x00; //wild card as default mCH[rFlea_profile].deviceType=0x27; //wild card as default mCH[rFlea_profile].txType=0x01; mCH[rFlea_profile].channelFreq=DEFAULT_RADIO_CHANNEL; mCH[rFlea_profile].channelPeriod=4096; mCH[rFlea_profile].channelStatus=STATUS_ASSIGNED_CHANNEL; } }
Json::Value ModuleIdentifier::toJSONObject() { Json::Value output; output["manufacturer"] = getManufacturer(); output["typeNumber"] = getTypeNumber(); output["serialNumber"] = getSerialNumber(); return output; }
STDMETHODIMP HostUSBDeviceFilterWrap::COMGETTER(SerialNumber)(BSTR *aSerialNumber) { LogRelFlow(("{%p} %s: enter aSerialNumber=%p\n", this, "HostUSBDeviceFilter::getSerialNumber", aSerialNumber)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aSerialNumber); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getSerialNumber(BSTROutConverter(aSerialNumber).str()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aSerialNumber=%ls hrc=%Rhrc\n", this, "HostUSBDeviceFilter::getSerialNumber", *aSerialNumber, hrc)); return hrc; }
static int getSerialNumber(int mjd) throw(Exception) { CommonTime t; t=MJD(double(mjd)); return getSerialNumber(t); }
extern void confirmSNonDisk(void) { int exists, handle, ret; char fileSN[PATH_LENGTH],filePattern[PATH_LENGTH]; char sysPath[PATH_LENGTH]; struct f_info file_info; // if (!SNexists()) // return; // no serial number - don't write to disk if (SYSTEM_PATH) strcpy(sysPath,SYSTEM_PATH); else strcpy(sysPath,DEFAULT_SYSTEM_PATH); strcpy(fileSN,sysPath); strcat(fileSN, (char *)getSerialNumber()); strcat(fileSN, (char *)SERIAL_EXT); exists = fileExists((LPSTR) fileSN); if (!exists) { mkdir((LPSTR)sysPath); tbChdir((LPSTR)sysPath); strcpy(filePattern,(char *)"*" SERIAL_EXT); ret =_findfirst((LPSTR)filePattern, &file_info, D_FILE); while (ret >= 0) { ret = unlink((LPSTR)file_info.f_name); ret = _findnext(&file_info); } handle = tbOpen((LPSTR)fileSN,O_CREAT|O_RDWR|O_TRUNC); close(handle); } }
char * getDeviceSN(void) { char *ret; ret = getSerialNumber(); return ret; }
static int getSerialNumber(int mjd) throw(DayTime::DayTimeException) { DayTime t; t.setMJD(double(mjd)); return getSerialNumber(t); }
bool DepthCamera::_init() { { CalibrationInformation &calibInfo = _getCalibrationInformationStructure()[CALIB_SECT_LENS]; calibInfo.name = CALIB_SECT_LENS; calibInfo.id = CALIB_SECT_LENS_ID; calibInfo.definingParameters = {}; calibInfo.calibrationParameters = {"fx", "fy", "cx", "cy", "k1", "k2", "k3", "p1", "p2"}; } String serialNumber; if(getSerialNumber(serialNumber)) { configFile.setHardwareID(serialNumber); configFile.readFromHardware(); } int currentID = -1; if(_getCurrentProfileID(currentID) && currentID >= 0) { if(!setCameraProfile(currentID, true)) return setCameraProfile(configFile.getDefaultCameraProfileID()); else return true; } else return setCameraProfile(configFile.getDefaultCameraProfileID()); }
BEGIN_NAMESPACE_NIDAQ Device::Device(const std::string &name) : name(name), serialNumber(getSerialNumber(name)) { }
bool CloudWatcherController::getConstants(CloudWatcherConstants *cwc) { bool r = getFirmwareVersion(cwc->firmwareVersion); if (!r) { return false; } r = getSerialNumber(&(cwc->internalSerialNumber)); if (!r) { return false; } if (cwc->firmwareVersion[0] >= '3') { r = getElectricalConstants(); if (!r) { return false; } } cwc->zenerVoltage = zenerConstant; cwc->ldrMaxResistance = LDRMaxResistance; cwc->ldrPullUpResistance = LDRPullUpResistance; cwc->rainBetaFactor = rainBeta; cwc->rainResistanceAt25 = rainResAt25; cwc->rainPullUpResistance = rainPullUpResistance; cwc->ambientBetaFactor = ambBeta; cwc->ambientResistanceAt25 = ambResAt25; cwc->ambientPullUpResistance = ambPullUpResistance; return true; }
uint32_t DeviceObjectDvc_c::getSize( const IsoAgLib::ProcData::ConnectionCapabilities_s& caps ) const { uint32_t size = DeviceObject_c::getSize( caps ); size += sizeof( uint8_t ) + CNAMESPACE::strlen( getDesignator() ); size += sizeof( uint8_t ) + CNAMESPACE::strlen( getVersion() ); size += 8; // m_wsmName; size += sizeof( uint8_t ) + CNAMESPACE::strlen( getSerialNumber() ); size += 14; /* m_structLabel + m_localization */ if( caps.versionNr >= 4 ) { size += 1; // Extended Structure Label length byte size += m_extendedStructureLabel.length; } return size; }
void Wagnis::generateId() { // There is no such thing as a reliable unique device ID on SailfishOS. Usually, /etc/machine-id // does the job, but it seems to be the same on a lot of devices of the same kind (e.g. Xperia X) // Therefore, there is no other choice than to use IMEI(s), serial numbers and MAC addresses as // hash data. For those of you who are afraid about data privacy, please use the search engine of // your choice for information about cryptographic hash functions. tl;dr: Nobody can restore the // original data from the hash... QCryptographicHash idHash(QCryptographicHash::Sha256); // If we are on a device which you still can use as a telephone, there's at least one IMEI QStringList imeis = getImeis(); QListIterator<QString> imeiIterator(imeis); while (imeiIterator.hasNext()) { QString imei = imeiIterator.next(); qDebug() << "[Wagnis] Using IMEI for the ID" << imei; idHash.addData(imei.toUtf8()); } // On devices without cellular connection, there should be a unique serial ID as replacement QString serialNumber = getSerialNumber(); if (!serialNumber.isEmpty()) { qDebug() << "[Wagnis] Using Serial Number for the ID" << serialNumber; idHash.addData(serialNumber.toUtf8()); } // Most devices support Wi-Fi - all networking devices have a MAC address QString wifiMacAddress = getWifiMacAddress(); if (!wifiMacAddress.isEmpty()) { qDebug() << "[Wagnis] Using Wi-Fi MAC address for the ID" << wifiMacAddress; idHash.addData(wifiMacAddress.toUtf8()); } // Additional components of the hash are the current application name... idHash.addData(this->applicationName.toUtf8()); // ...and the identifier of this Wagnis release. idHash.addData(QString("Wagnis 42.1807").toUtf8()); idHash.result().toHex(); QString uidHash = QString::fromUtf8(idHash.result().toHex()); qDebug() << "[Wagnis] Complete hash: " << uidHash; wagnisId = uidHash.left(4) + "-" + uidHash.mid(4,4) + "-" + uidHash.mid(8,4) + "-" + uidHash.mid(12,4); qDebug() << "[Wagnis] ID: " << wagnisId; }
void USB::init() { iprintf("init\n"); uint32_t chip_serial[4]; getSerialNumber(4, chip_serial); for (int j = 0; j < 4; j++) { for (int i = 0; i < 8; i++) { uint8_t c = (chip_serial[j] & 15); serial.str[j * 8 + 7 - i] = (c < 10)?(c + '0'):(c - 10 + 'A'); chip_serial[j] >>= 4; } } setDescriptors(descriptors); USBHAL::init(); iprintf("OK\n"); }
CIMInstance ComputerSystem::buildInstance(const CIMName& className) { CIMInstance instance(className); CIMProperty p; //-- fill in properties for CIM_ComputerSystem if (getCaption(p)) instance.addProperty(p); if (getDescription(p)) instance.addProperty(p); if (getInstallDate(p)) instance.addProperty(p); if (getStatus(p)) instance.addProperty(p); if (getOperationalStatus(p)) instance.addProperty(p); if (getStatusDescriptions(p)) instance.addProperty(p); if (getElementName(p)) instance.addProperty(p); if (getCreationClassName(p)) instance.addProperty(p); if (getName(p)) instance.addProperty(p); if (getNameFormat(p)) instance.addProperty(p); if (getPrimaryOwnerName(p)) instance.addProperty(p); if (getPrimaryOwnerContact(p)) instance.addProperty(p); if (getRoles(p)) instance.addProperty(p); if (getOtherIdentifyingInfo(p)) instance.addProperty(p); if (getIdentifyingDescriptions(p)) instance.addProperty(p); if (getDedicated(p)) instance.addProperty(p); if (getResetCapability(p)) instance.addProperty(p); if (getPowerManagementCapabilities(p)) instance.addProperty(p); // Done if we are servicing CIM_ComputerSystem if (className.equal (CLASS_CIM_COMPUTER_SYSTEM)) return instance; // Fill in properties for CIM_UnitaryComputerSystem if (getInitialLoadInfo(p)) instance.addProperty(p); if (getLastLoadInfo(p)) instance.addProperty(p); if (getPowerManagementSupported(p)) instance.addProperty(p); if (getPowerState(p)) instance.addProperty(p); if (getWakeUpType(p)) instance.addProperty(p); // Done if we are servicing CIM_UnitaryComputerSystem if (className.equal (CLASS_CIM_UNITARY_COMPUTER_SYSTEM)) return instance; // Fill in properties for <Extended>_ComputerSystem if (className.equal (CLASS_EXTENDED_COMPUTER_SYSTEM)) { if(getPrimaryOwnerPager(p)) instance.addProperty(p); if(getSecondaryOwnerName(p)) instance.addProperty(p); if(getSecondaryOwnerContact(p)) instance.addProperty(p); if(getSecondaryOwnerPager(p)) instance.addProperty(p); if(getSerialNumber(p)) instance.addProperty(p); if(getIdentificationNumber(p)) instance.addProperty(p); } return instance; }
int main(){ pid_t pid, sid; int list_s; /* listening socket */ int conn_s; /* connection socket */ short int port = 1995; /* port number */ struct sockaddr_in servaddr; /* socket address structure */ int i; uint8_t numClients = 0; threadInfo* info; /* Fork off the parent process */ pid = fork(); if(pid < 0) { exit(EXIT_FAILURE); } /* If we got a good PID, then we can exit the parent process */ if(pid > 0){ exit(EXIT_SUCCESS); } umask(0); printf("Daemon started. Writing all further notices to daemon log: /var/log/daemon.log\n"); // Enable Signal Handler signal(SIGTERM, catch_term); /* Open Log File Here */ openlog("SEASSERVER",LOG_PID,LOG_DAEMON); syslog(LOG_DAEMON|LOG_INFO,"Daemon Started."); /* Open Config File Here */ if(!readConfig()){ syslog(LOG_DAEMON|LOG_ERR,"Unable to Read Configuration File. Daemon Terminated.\n"); exit(EXIT_FAILURE); } /* Create a new SID for the child process */ sid = setsid(); if(sid < 0){ syslog(LOG_DAEMON|LOG_ERR,"Unable to create a new SID for child process. Daemon Terminated."); exit(EXIT_FAILURE); } /* Change the current working directory */ if((chdir("/")) < 0){ syslog(LOG_DAEMON|LOG_ERR,"Unable to switch working directory. Daemon Terminated."); exit(EXIT_FAILURE); } close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); /* Setup TCP/IP Socket */ if((list_s = socket(AF_INET, SOCK_STREAM, 0)) < 0){ syslog(LOG_DAEMON|LOG_ERR,"Unable to create socket. Daemon Terminated."); exit(EXIT_FAILURE); } memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(port); #ifdef DEBUG syslog(LOG_DAEMON|LOG_INFO,"Opening Spectrometers."); #endif // Power Cycle GPIO for USB Hub to make sure USB ports initialized correctly //system("echo 0 > /sys/class/gpio/gpio168/value"); //sleep(3); //system("echo 1 > /sys/class/gpio/gpio168/value"); //sleep(3); // Connect the USB Spectrometers char *serialNumbers[NUM_SPECS] = {getSerialNumber(0),getSerialNumber(1)}; if(connectSpectrometers(serialNumbers) == CONNECT_ERR) { syslog(LOG_DAEMON|LOG_ERR,"Spectrometers could not be opened. Daemon Exiting"); exit(EXIT_FAILURE); } #ifdef DEBUG syslog(LOG_DAEMON|LOG_INFO,"Spectrometers Opened."); #endif applyConfig(); logConfig(); // Start LON Dispatch syslog(LOG_DAEMON|LOG_INFO,"Starting LON Connection."); if(startDispatch(LONPORT) == -1){ syslog(LOG_DAEMON|LOG_ERR,"LON Not Connected! Check serial port."); exit(EXIT_FAILURE); } else { syslog(LOG_DAEMON|LOG_INFO,"LON Connection Started."); } // Init Bench Config and Power Management GPIOs (See SEASPeriperalCommands.c) readBenchConfig(); initPeripherals(); // Start CTD Sink CTDSink* ctdSink = CTDSink::Instance(); /* Bind our socket addresss to the listening socket, and call listen() */ if ( bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) { syslog(LOG_DAEMON|LOG_ERR,"Unable to bind socket. Daemon Terminated."); exit(EXIT_FAILURE); } if ( listen(list_s, NUM_THREADS) < 0 ) { syslog(LOG_DAEMON|LOG_ERR,"Unable to listen on socket. Daemon Terminated."); exit(EXIT_FAILURE); } for(i=0; i < NUM_THREADS; i++) thread_bin_available[i] = AVAILABLE; execMode(); while(keep_going){ syslog(LOG_DAEMON|LOG_INFO,"Listening for connection on port %i", port); /* Wait for TCP/IP Connection */ conn_s = accept(list_s, NULL, NULL); if ( conn_s < 0 ) { syslog(LOG_DAEMON|LOG_ERR,"Unable to call accept() on socket."); break; } /* Spawn a POSIX Server Thread to Handle Connected Socket */ for(i=0; i < NUM_THREADS; i++){ if(thread_bin_available[i]){ thread_bin_available[i] = UNAVAILABLE; syslog(LOG_DAEMON|LOG_INFO,"Handling new connection on port %i",port); numClients++; info = (threadInfo*)malloc(sizeof(threadInfo)); info->socket_connection = conn_s; info->thread_bin_index = i; pthread_create(&thread_bin[i],NULL,handleConnection, (void*)info); break; } } if(i > NUM_THREADS){ syslog(LOG_DAEMON|LOG_ERR,"Unable to create thread to handle connection. Continuing..."); } } if(disconnectSpectrometers() == CONNECT_OK) syslog(LOG_DAEMON|LOG_INFO,"Spectrometers Successfully Disconnected"); else syslog(LOG_DAEMON|LOG_ERR,"Unable to Disconnect Spectrometers"); syslog(LOG_DAEMON|LOG_INFO,"Daemon Exited Politely."); exit(EXIT_SUCCESS); }
/** Like most memory stuff this won't work across DLL's in windows, it should work fine in linux or with static library files in windows. **/ AREXPORT std::string ArRobotConfigPacketReader::buildString(void) const { std::string ret; char line[32000]; sprintf(line, "General information:\n"); ret += line; sprintf(line, "Robot is type '%s' subtype '%s'\n", getType(), getSubType()); ret += line; sprintf(line, "serial number '%s' name '%s'\n", getSerialNumber(), getName()); ret += line; sprintf(line, "Intrinsic properties and unsettable maxes:\n"); ret += line; sprintf(line, "RotVelTop %d RotAccelTop %d\n", getRotVelTop(), getRotAccelTop()); ret += line; sprintf(line, "TransVelTop %d TransAccelTop %d\n", getTransVelTop(), getTransAccelTop()); ret += line; sprintf(line, "PWMMax %d ResetBaud %s\n", getPwmMax(), ArUtil::convertBool(getResetBaud())); ret += line; sprintf(line, "Current values:\n"); ret += line; sprintf(line, "RotVelMax %d RotAccel %d RotDecel %d\n", getRotVelMax(), getRotAccel(), getRotDecel()); ret += line; sprintf(line, "TransVelMax %d TransAccel %d TransDecel %d\n", getTransVelMax(), getTransAccel(), getTransDecel()); ret += line; sprintf(line, "Accessories:\n"); ret += line; sprintf(line, "Gripper %s FrontSonar %s RearSonar %s Charger %d Gyro %s\n", ArUtil::convertBool(getHasGripper()), ArUtil::convertBool(getFrontSonar()), ArUtil::convertBool(getRearSonar()), getHasCharger(), ArUtil::convertBool(getHasGyro())); ret += line; sprintf(line, "FrontBumps %d RearBumps %d\n", getFrontBumps(), getRearBumps()); ret += line; sprintf(line, "Settings:\n"); ret += line; sprintf(line, "SipCycle %d SonarCycle %d HostBaud %d Aux1Baud %d\n", getSipCycleTime(), getSonarCycle(), getHostBaud(), getAux1Baud()); ret += line; sprintf(line, "StallVal %d StallCount %d RevCount %d Watchdog %d\n", getStallVal(), getStallCount(), getRevCount(), getWatchdog()); ret += line; sprintf(line, "JoyVel %d JoyRVel %d NormalMotorPackets %s\n", getJoyVel(), getJoyRotVel(), ArUtil::convertBool(getNormalMPacs())); ret += line; sprintf(line, "PID Settings:\n"); ret += line; sprintf(line, "Rot kp %d kv %d ki %d\n", getRotKP(), getRotKV(), getRotKI()); ret += line; sprintf(line, "Trans kp %d kv %d ki %d\n", getTransKP(), getTransKV(), getTransKI()); ret += line; sprintf(line, "DriftFactor %d\n", getDriftFactor()); ret += line; sprintf(line, "Aux2Baud setting %d, Aux3Baud setting %d\n", getAux2Baud(), getAux3Baud()); ret += line; sprintf(line, "TicksMM: %d\n", getTicksMM()); ret += line; sprintf(line, "Shutdown Voltage: %d\n", getShutdownVoltage()); ret += line; return ret; }
int main(int argc, char *argv[]) { char cBufRead[BUF_SIZE]; DWORD dwBytesRead; FT_STATUS ftStatus; FT_HANDLE ftHandle; int iport; int i; char c; if(argc > 1) { sscanf(argv[1], "%d", &iport); } else { iport = 0; } // Note! // The second version of open should work from version 0.4.9 it may be prefered // in many situations. On Fedora Core 4, kernal 2.6.15 it fails however. //ftStatus = FT_Open(iport, &ftHandle); ftStatus = FT_OpenEx( "LWO65RKA", FT_OPEN_BY_SERIAL_NUMBER, &ftHandle); //ftStatus = FT_OpenEx( NULL, FT_OPEN_BY_SERIAL_NUMBER, &ftHandle); // First found if(ftStatus != FT_OK) { /* This can fail if the ftdi_sio driver is loaded use lsmod to check this and rmmod ftdi_sio to remove also rmmod usbserial */ printf("FT_Open(%d) failed. rv=%d\n", iport, ftStatus); return 1; } FT_SetTimeouts(ftHandle, 3000, 3000 ); // 3 second read timeout while ( 1 ) { printf("\n\n\n"); printf("=====================================================================\n"); printf(" Lawicel AB -- CANUSB test application\n"); printf("=====================================================================\n\n"); printf("S - Send test frames.\n"); printf("R - Read five frames.\n"); printf("N - Get Serial number.\n"); printf("V - Get Version Information.\n"); printf("Q - Quit application.\n"); while ( 0x0a == ( c = getchar() )); if ( 'q' == c || 'Q' == c ) break; else if ( 'v' == c || 'V' == c ){ getVersionInfo( ftHandle ); } else if ( 'n' == c || 'N' == c ){ getSerialNumber( ftHandle ); } else if ( 's' == c || 'S' == c ){ SendTestFrames( ftHandle ); } else if ( 'r' == c || 'R' == c ){ GetTestFrames( ftHandle ); } } printf("Bye,bye....\n"); FT_Close(ftHandle); return 0; }
/** Like most memory stuff this won't work across DLL's in windows, it should work fine in linux or with static library files in windows. **/ AREXPORT std::string ArRobotConfigPacketReader::buildString(void) const { std::string ret; char line[32000]; sprintf(line, "General information:\n"); ret += line; sprintf(line, "Robot is type '%s' subtype '%s'\n", getType(), getSubType()); ret += line; sprintf(line, "serial number '%s' name '%s'\n", getSerialNumber(), getName()); ret += line; sprintf(line, "firmware version '%s'\n", getFirmwareVersion()); ret += line; sprintf(line, "Intrinsic properties and unsettable maxes:\n"); ret += line; sprintf(line, "TransVelTop %d TransAccelTop %d\n", getTransVelTop(), getTransAccelTop()); ret += line; sprintf(line, "RotVelTop %d RotAccelTop %d\n", getRotVelTop(), getRotAccelTop()); ret += line; if (myRobot->hasLatVel()) { sprintf(line, "LatVelTop %d LatAccelTop %d\n", getLatVelTop(), getLatAccelTop()); ret += line; } sprintf(line, "PWMMax %d ResetBaud %s\n", getPwmMax(), ArUtil::convertBool(getResetBaud())); ret += line; sprintf(line, "Current values:\n"); ret += line; sprintf(line, "TransVelMax %d TransAccel %d TransDecel %d\n", getTransVelMax(), getTransAccel(), getTransDecel()); ret += line; sprintf(line, "RotVelMax %d RotAccel %d RotDecel %d\n", getRotVelMax(), getRotAccel(), getRotDecel()); ret += line; if (myRobot->hasLatVel()) { sprintf(line, "LatVelMax %d LatAccel %d LatDecel %d\n", getLatVelMax(), getLatAccel(), getLatDecel()); ret += line; } sprintf(line, "Accessories:\n"); ret += line; sprintf(line, "Gripper %s FrontSonar %s RearSonar %s Charger %d GyroType %d\n", ArUtil::convertBool(getHasGripper()), ArUtil::convertBool(getFrontSonar()), ArUtil::convertBool(getRearSonar()), getHasCharger(), getGyroType()); ret += line; sprintf(line, "FrontBumps %d RearBumps %d\n", getFrontBumps(), getRearBumps()); ret += line; sprintf(line, "Settings:\n"); ret += line; sprintf(line, "SipCycle %d SonarCycle %d HostBaud %d Aux1Baud %d\n", getSipCycleTime(), getSonarCycle(), getHostBaud(), getAux1Baud()); ret += line; sprintf(line, "StallVal %d StallCount %d RevCount %d Watchdog %d\n", getStallVal(), getStallCount(), getRevCount(), getWatchdog()); ret += line; sprintf(line, "GyroRateLimit %d\n", getGyroRateLimit()); ret += line; sprintf(line, "JoyVel %d JoyRVel %d NormalMotorPackets %s\n", getJoyVel(), getJoyRotVel(), ArUtil::convertBool(getNormalMPacs())); ret += line; sprintf(line, "PID Settings:\n"); ret += line; sprintf(line, "Trans kp %d kv %d ki %d\n", getTransKP(), getTransKV(), getTransKI()); ret += line; sprintf(line, "Rot kp %d kv %d ki %d\n", getRotKP(), getRotKV(), getRotKI()); ret += line; sprintf(line, "Other:\n"); ret += line; sprintf(line, "DriftFactor %d KinematicsDelay %d\n", getDriftFactor(), getKinematicsDelay()); ret += line; sprintf(line, "Aux2Baud setting %d Aux3Baud setting %d\n", getAux2Baud(), getAux3Baud()); ret += line; sprintf(line, "PDBPort setting %d\n", getPDBPort()); ret += line; sprintf(line, "TicksMM %d GyroCW %d GyroCCW %d\n", getTicksMM(), getGyroCW(), getGyroCCW()); ret += line; sprintf(line, "ShutdownVoltage %d PowerbotChargeTreshold %d\n", getShutdownVoltage(), getPowerbotChargeThreshold()); ret += line; char buf[128]; int i, j; unsigned int value = getPowerBits(); int bit; buf[0] = '\0'; for (j = 0, bit = 1; j < 16; ++j, bit *= 2) { if (j == 8) sprintf(buf, "%s ", buf); if (value & bit) sprintf(buf, "%s%d", buf, 1); else sprintf(buf, "%s%d", buf, 0); } sprintf(line, "HighTempShutdown %d PowerBits %s\n", getHighTemperatureShutdown(), buf); ret += line; return ret; }
boost::shared_ptr<FreenectDevice> getDeviceByIndex(unsigned device_idx) { return getDeviceBySerialNumber(std::string(getSerialNumber(device_idx))); }
extern void setSystemData(struct SystemData *sd) { struct SystemCounts2 sc; int size, totalSize, i, reflashes; dumpSystemDataToLog(sd); sd->structType = NOR_STRUCT_ID_SYSTEM; reflashes = getReflashCount(); if (!sd->countReflashes) sd->countReflashes = reflashes + 1; if (!sd->serialNumber[0]) { strcpy(sd->serialNumber,getSerialNumber()); if (!sd->serialNumber[0]) { strcpy(sd->serialNumber,(char *)"UNKNOWN"); } } if (!sd->location[0]) { strcpy(sd->location,getLocation()); if (!sd->location[0]) { strcpy(sd->location,(char *)"UNKNOWN"); } } if (!sd->imageName[0]) { strcpy(sd->imageName,getImageName()); if (!sd->imageName[0]) { strcpy(sd->imageName,(char *)"UNKNOWN"); } } if (!sd->updateNumber[0]) strcpy(sd->updateNumber,getUpdateNumber()); if (!sd->monthLastUpdated) sd->monthLastUpdated = getUpdateMonth(); if (!sd->dateLastUpdated) sd->dateLastUpdated = getUpdateDate(); if (!sd->yearLastUpdated) sd->yearLastUpdated = getUpdateYear(); dumpSystemDataToLog(sd); systemCounts.monthday = sd->dateLastUpdated; systemCounts.month = sd->monthLastUpdated; systemCounts.year = sd->yearLastUpdated; sc.structType = NOR_STRUCT_ID_COUNTS; sc.period = 0; sc.cumulativeDays = 0; sc.corruptionDay = 0; sc.powerups = 0; sc.lastInitVoltage = 0; sc.rotations[0].structType = NOR_STRUCT_ID_ROTATION; sc.rotations[0].rotationNumber = 0; sc.rotations[0].periodNumber = 0; sc.rotations[0].hoursAfterLastUpdate = 0; checkVoltage(); sc.rotations[0].initVoltage = vCur_1; for (i=1; i< MAX_ROTATIONS; i++) { sc.rotations[i].structType = -2; // -1 is bad since FF is unwritten memory } // startup() assumes that struct SystemData is written first at TB_SERIAL_NUMBER_ADDR totalSize = 0; size = sizeof(struct SystemData); // round up # of words write_app_flash((int *)sd, size, totalSize); totalSize += size; ptrsCounts.systemData = (struct SystemData *)(TB_SERIAL_NUMBER_ADDR); size = sizeof(struct SystemCounts2); // round up # of words write_app_flash((int *)&sc, size, totalSize); ptrsCounts.systemCounts = (struct SystemCounts2 *)(TB_SERIAL_NUMBER_ADDR + totalSize); ptrsCounts.period = NULL; ptrsCounts.cumulativeDays = NULL; ptrsCounts.powerups = NULL; ptrsCounts.corruptionDay = NULL; ptrsCounts.latestRotation = NULL; }
std::string ModuleIdentifier::toString() { return "{\"manufacturer\":" + getManufacturer() + "\"typeNumber\":" + getTypeNumber() + "\"serialNumber\":" + getSerialNumber() + "}"; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); IO::IODevicePtr src_device = nullptr; if (argc == param_count) { uint64_t start_offset = 0; std::string offset_txt(argv[offset_param]); if (offset_txt.compare(offset_str) == 0) { start_offset = boost::lexical_cast<uint64_t>(argv[offset_value]); qInfo() << "offset : " << start_offset <<"(sectors)"; } std::string disk_file_string(argv[disk_file_param]); if (disk_file_string.compare(d_str) == 0) { auto drive_number = boost::lexical_cast<uint32_t>(argv[source_value]); auto drive_list = IO::ReadPhysicalDrives(); auto physical_drive = drive_list.find_by_number(drive_number); start_offset *= physical_drive->getBytesPerSector(); if (physical_drive) { qInfo() << "You selected"; qInfo() << "Number : " << drive_number; qInfo() << "Name :" << physical_drive->getDriveName().c_str(); qInfo() << "Serial number : " << physical_drive->getSerialNumber().c_str(); qInfo() << "Size : " << physical_drive->getSize() << "(bytes)"; } src_device = std::make_shared<IO::DiskDevice>(physical_drive); } else if (disk_file_string.compare(f_str) == 0) { std::string src_path = argv[source_value]; src_device = IO::makeFilePtr(IO::path_string(src_path.begin(), src_path.end())); start_offset *= default_sector_size; } if (!src_device->Open(IO::OpenMode::OpenRead)) { qInfo() << "Error open source device."; return -1; } std::string targer_path = argv[target_value]; IO::path_string target_folder(targer_path.begin(), targer_path.end()); if (!src_device) return -1; ////////////////////////////////////////////////////////////////////////// QList<JsonFileStruct> listFileStruct; QFile file("video.json"); if (!file.open(QIODevice::ReadOnly)) { qInfo() << "Error to open file. \"" << file.fileName() << "\""; return -1; } auto json_str = file.readAll(); ReadJsonFIle(json_str, listFileStruct); if ( listFileStruct.empty()) { qInfo() << "Error to read" << file.fileName() << "file. Wrong syntax."; return -1; } IO::HeaderBase::Ptr headerBase = std::make_shared<IO::HeaderBase>(); for (auto theFileStruct : listFileStruct) headerBase->addFileFormat(toFileStruct(theFileStruct)); IO::RawFactoryManager factory_manager; initFactoryMananger(factory_manager); IO::SignatureFinder signatureFinder(src_device, headerBase); //uint64_t start_offset = 0x0; uint64_t header_offset = 0; uint32_t counter = 0; while (start_offset < src_device->Size()) { auto file_struct = signatureFinder.findHeader(start_offset, header_offset); if (!file_struct) { qInfo() << endl << endl << endl << "No more signatures found. Press any key to exit."; break; } qInfo() << "Found signature for [" << file_struct->getName().c_str() << "] file."; qInfo() << "Offset : " << header_offset << "(bytes)"; start_offset = header_offset; auto raw_factory = factory_manager.Lookup(file_struct->getName()); IO::RawAlgorithm * raw_algorithm = nullptr; if (!raw_factory) { IO::StandartRaw * standard_raw = new IO::StandartRaw(src_device); standard_raw->setMaxFileSize(file_struct->getMaxFileSize()); standard_raw->setFooter(file_struct->getFooter(), file_struct->getFooterTailEndSize()); standard_raw->setFooterOffsetSearchBlock(4, 4096); raw_algorithm = standard_raw; } else { raw_algorithm = raw_factory->createRawAlgorithm(src_device); } if (raw_algorithm->Specify(header_offset)) { auto target_file = IO::offsetToPath(target_folder, header_offset, file_struct->getExtension(), 512); auto dst_file = IO::makeFilePtr(target_file); if (dst_file->Open(IO::OpenMode::Create)) { auto target_size = raw_algorithm->SaveRawFile(*dst_file, header_offset); if ( target_size == 0) { qInfo() << "Error to save file. Exit." ; //break; } auto dst_size = dst_file->Size(); dst_file->Close(); qInfo() << "Successfully saved " << target_size << "(bytes)" << endl << endl; uint64_t jump_size = default_sector_size; if ( raw_algorithm->Verify(target_file) ) { target_size /= default_sector_size; target_size *= default_sector_size; ////////////////////////////////////////////////////////////////////////// jump_size = target_size; } else { // remove file IO::path_string new_fileName = target_file + L".bad_file"; boost::filesystem::rename(target_file, new_fileName); //{ // qInfo() << "File" << target_file.c_str() << "was removed." << endl; //} //else // qInfo() << "File" << target_file.c_str() << "Error to delete." << endl; } //if (jump_size == 0) jump_size = default_sector_size; start_offset = header_offset + jump_size; } else { qInfo() << "Error to create target file." << QString::fromStdWString(target_file); qInfo() << "Exit."; break; } } else { qInfo() << "Not specified for " << QString::fromStdString(file_struct->getName()) << "continue search for other signatures."<<endl; start_offset += default_sector_size; } if ( raw_algorithm) delete raw_algorithm; } } else qInfo() << "Wrong params"; return a.exec(); }