const void * BufferedTransport::peek(size_t &size) { ScopedMutexLock(lock_); if(remainingSize() < size) { size = remainingSize(); } return currentPtr(); }
int BufferedTransport::peek(char *buffer, size_t size) { ScopedMutexLock(lock_); if(remainingSize() < size) { size = remainingSize(); } memcpy(buffer, currentPtr(), size); return size; }
int BufferedTransport::read(void *ptr, size_t size) { ScopedMutexLock(lock_); if(remainingSize() < size) { size = remainingSize(); } memcpy(ptr, currentPtr(), size); fastforward(size); return size; }
int BufferedTransport::read(std::string &data, size_t size) { ScopedMutexLock(lock_); if(remainingSize() < size) { size = remainingSize(); } data.assign((const char *)currentPtr(), size); fastforward(size); return size; }
std::string BufferedTransport::readString(size_t size) { ScopedMutexLock(lock_); if(remainingSize() < size) { size = remainingSize(); } std::string str; str.assign((const char *)currentPtr(), size); fastforward(size); return str; }
void K3b::Device::DiskInfo::debug() const { kDebug() << "DiskInfo:" << endl << "Mediatype: " << K3b::Device::mediaTypeString( mediaType() ) << endl << "Current Profile: " << K3b::Device::mediaTypeString( currentProfile() ) << endl << "Disk state: " << ( diskState() == K3b::Device::STATE_EMPTY ? "empty" : ( diskState() == K3b::Device::STATE_INCOMPLETE ? "incomplete" : ( diskState() == K3b::Device::STATE_COMPLETE ? "complete" : ( diskState() == K3b::Device::STATE_NO_MEDIA ? "no media" : "unknown" ) ) ) ) << endl << "Empty: " << empty() << endl << "Rewritable: " << rewritable() << endl << "Appendable: " << appendable() << endl << "Sessions: " << numSessions() << endl << "Tracks: " << numTracks() << endl << "Layers: " << numLayers() << endl << "Capacity: " << capacity() << " (LBA " << capacity().lba() << ") (" << capacity().mode1Bytes() << " Bytes)" << endl << "Remaining size: " << remainingSize() << " (LBA " << remainingSize().lba() << ") (" << remainingSize().mode1Bytes() << " Bytes)" << endl << "Used Size: " << size() << " (LBA " << size().lba() << ") (" << size().mode1Bytes() << " Bytes)" << endl; if( mediaType() == K3b::Device::MEDIA_DVD_PLUS_RW ) kDebug() << "Bg Format: " << ( bgFormatState() == BG_FORMAT_NONE ? "none" : ( bgFormatState() == BG_FORMAT_INCOMPLETE ? "incomplete" : ( bgFormatState() == BG_FORMAT_IN_PROGRESS ? "in progress" : ( bgFormatState() == BG_FORMAT_COMPLETE ? "complete" : "unknown" ) ) ) ) << endl; }
/** * @returns true if data does not fit into this buffer */ static bool validateBuffer(Logging *logging, uint32_t extraLen) { if (logging->buffer == NULL) { firmwareError("Logging not initialized: %s", logging->name); return true; } if (remainingSize(logging) < extraLen + 1) { warning(OBD_PCM_Processor_Fault, "buffer overflow %s", logging->name); return true; } return false; }
/** * @brief Register an event for digital sniffer */ void addWaveChartEvent3(WaveChart *chart, const char *name, const char * msg, const char * msg2) { efiAssertVoid(chart->isInitialized, "chart not initialized"); #if DEBUG_WAVE scheduleSimpleMsg(&debugLogging, "current", chart->counter); #endif if (isWaveChartFull(chart)) { return; } #if EFI_HISTOGRAMS && EFI_PROD_CODE int beforeCallback = hal_lld_get_counter_value(); #endif int time100 = getTimeNowUs() / 10; bool alreadyLocked = lockOutputBuffer(); // we have multiple threads writing to the same output buffer if (chart->counter == 0) { chart->startTime = time100; } chart->counter++; if (remainingSize(&chart->logging) > 30) { /** * printf is a heavy method, append is used here as a performance optimization */ appendFast(&chart->logging, name); appendFast(&chart->logging, CHART_DELIMETER); appendFast(&chart->logging, msg); appendFast(&chart->logging, CHART_DELIMETER); /** * We want smaller times within a chart in order to reduce packet size. */ time100 -= chart->startTime; itoa10(timeBuffer, time100); appendFast(&chart->logging, timeBuffer); appendFast(&chart->logging, msg2); appendFast(&chart->logging, CHART_DELIMETER); } if (!alreadyLocked) { unlockOutputBuffer(); } #if EFI_HISTOGRAMS && EFI_PROD_CODE int64_t diff = hal_lld_get_counter_value() - beforeCallback; if (diff > 0) { hsAdd(&waveChartHisto, diff); } #endif /* EFI_HISTOGRAMS */ }
/** * @returns true if data does not fit into this buffer */ static INLINE bool validateBuffer(Logging *logging, uint32_t extraLen) { if (logging->buffer == NULL) { firmwareError("Logging not initialized: %s", logging->name); return true; } if (remainingSize(logging) < extraLen + 1) { #if EFI_PROD_CODE warning(OBD_PCM_Processor_Fault, "output overflow %s", logging->name); #endif return true; } return false; }
void scAddData(float angle, float value) { if (!initialized) { return; // this is possible because of initialization sequence } if (engineConfiguration->sensorChartFrequency < 2) { /** * analog chart frequency cannot be 1 because of the way * data flush is implemented, see below */ //todofirmwareError() return; } if (getRevolutionCounter() % engineConfiguration->sensorChartFrequency != 0) { /** * We are here if we do NOT need to add an event to the analog chart */ if (pendingData) { /** * We are here if that's the first time we do not need to add * data after we have added some data - meaning it's time to flush */ // message terminator appendPrintf(&logging, DELIMETER); // output pending data #if EFI_PROD_CODE || defined(__DOXYGEN__) if (getFullLog()) { scheduleLogging(&logging); } #endif pendingData = false; } return; } if (!pendingData) { pendingData = true; resetLogging(&logging); // message header appendPrintf(&logging, "analog_chart%s", DELIMETER); } if (remainingSize(&logging) > 100) { appendPrintf(&logging, "%f|%f|", angle, value); } }
std::string BufferedTransport::toStringFromCurrentPtr() { std::string str; str.assign((char *)currentPtr(), remainingSize()); return str; }
/** * @brief Register an event for digital sniffer */ void WaveChart::addEvent3(const char *name, const char * msg) { #if EFI_TEXT_LOGGING if (!ENGINE(isEngineChartEnabled)) { return; } if (skipUntilEngineCycle != 0 && ENGINE(rpmCalculator.getRevolutionCounter()) < skipUntilEngineCycle) return; #if EFI_SIMULATOR // todo: add UI control to enable this for firmware if desired // CONFIG(alignEngineSnifferAtTDC) && if (!collectingData) { return; } #endif efiAssertVoid(CUSTOM_ERR_6651, name!=NULL, "WC: NULL name"); #if EFI_PROD_CODE efiAssertVoid(CUSTOM_ERR_6652, getCurrentRemainingStack() > 32, "lowstck#2c"); #endif /* EFI_PROD_CODE */ efiAssertVoid(CUSTOM_ERR_6653, isInitialized, "chart not initialized"); #if DEBUG_WAVE scheduleSimpleMsg(&debugLogging, "current", chart->counter); #endif /* DEBUG_WAVE */ if (isFull()) { return; } #if EFI_HISTOGRAMS && EFI_PROD_CODE int beforeCallback = hal_lld_get_counter_value(); #endif efitick_t nowNt = getTimeNowNt(); bool alreadyLocked = lockOutputBuffer(); // we have multiple threads writing to the same output buffer if (counter == 0) { startTimeNt = nowNt; } counter++; /** * We want smaller times within a chart in order to reduce packet size. */ /** * todo: migrate to binary fractions in order to eliminate * this division? I do not like division * * at least that's 32 bit division now */ uint32_t diffNt = nowNt - startTimeNt; uint32_t time100 = NT2US(diffNt / 10); if (remainingSize(&logging) > 35) { /** * printf is a heavy method, append is used here as a performance optimization */ appendFast(&logging, name); appendChar(&logging, CHART_DELIMETER); appendFast(&logging, msg); appendChar(&logging, CHART_DELIMETER); // time100 -= startTime100; itoa10(timeBuffer, time100); appendFast(&logging, timeBuffer); appendChar(&logging, CHART_DELIMETER); logging.linePointer[0] = 0; } if (!alreadyLocked) { unlockOutputBuffer(); } #if EFI_HISTOGRAMS && EFI_PROD_CODE int64_t diff = hal_lld_get_counter_value() - beforeCallback; if (diff > 0) { hsAdd(&engineSnifferHisto, diff); } #endif /* EFI_HISTOGRAMS */ #endif /* EFI_TEXT_LOGGING */ }