Ejemplo n.º 1
0
void scheduleLogging(Logging *logging) {
	// this could be done without locking
	int newLength = efiStrlen(logging->buffer);

	bool alreadyLocked = lockOutputBuffer();
	// I hope this is fast enough to operate under sys lock
	int curLength = efiStrlen(pendingBuffer);
	if (curLength + newLength >= DL_OUTPUT_BUFFER) {
		/**
		 * if no one is consuming the data we have to drop it
		 * this happens in case of serial-over-USB, todo: find a better solution
		 *
		 */
//		strcpy(fatalMessage, "datalogging.c: output buffer overflow: ");
//		strcat(fatalMessage, logging->name);
//		fatal(fatalMessage);
		if (!alreadyLocked) {
			unlockOutputBuffer();
		}
		resetLogging(logging);
		return;
	}

	strcat(pendingBuffer, logging->buffer);
	if (!alreadyLocked) {
		unlockOutputBuffer();
	}
	resetLogging(logging);
}
Ejemplo n.º 2
0
/**
 * This method actually sends all the pending data to the communication layer
 */
void printPending(void) {
	lockOutputBuffer();
	// we cannot output under syslock, so another buffer
	strcpy(outputBuffer, pendingBuffer);
	pendingBuffer[0] = 0; // reset pending buffer
	unlockOutputBuffer();

	if (efiStrlen(outputBuffer) > 0) {
		printWithLength(outputBuffer);
	}
}
Ejemplo n.º 3
0
/**
 * @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 */

}
Ejemplo n.º 4
0
/**
 * @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 */
}