manual pre-merge - should be safe, functional test of rusEfi custom %..1000f formatting

This commit is contained in:
rusefi 2017-03-30 15:04:20 -04:00
parent 20ebc8d7b5
commit 062ffc5890
1 changed files with 21 additions and 0 deletions

View File

@ -29,6 +29,8 @@
#include "trigger_emulator.h"
#include "engine_controller.h"
#include "map_averaging.h"
#include "memstreams.h"
#include <chprintf.h>
#define DEFAULT_SIM_RPM 1200
#define DEFAULT_SNIFFER_THR 2500
@ -53,6 +55,23 @@ float getMap(void) {
return getRawMap();
}
static void runChprintfTess() {
static MemoryStream testStream;
static char testBuffer[200];
msObjectInit(&testStream, (uint8_t *) testBuffer, sizeof(testBuffer), 0);
// it's a very, very long and mostly forgotten story how this became our %f precision format
testStream.eos = 0; // reset
chprintf((BaseSequentialStream*)&testStream, "%f/%..10000f/%..10000f", 0.239f, 239.932, 0.1234);
testStream.buffer[testStream.eos] = 0;
#define FLOAT_STRING_EXPECTED "0.23/239.9320/0.1234"
if (strcmp(FLOAT_STRING_EXPECTED, testBuffer) != 0) {
firmwareError(OBD_PCM_Processor_Fault, "chprintf test: got %s while %s", testBuffer, FLOAT_STRING_EXPECTED);
}
}
void rusEfiFunctionalTest(void) {
printToWin32Console("Running version:");
printToWin32Console("TODO");
@ -94,6 +113,8 @@ void rusEfiFunctionalTest(void) {
startStatusThreads(engine);
runChprintfTess();
initPeriodicEvents(PASS_ENGINE_PARAMETER_F);
setTriggerEmulatorRPM(DEFAULT_SIM_RPM, engine);