mirror of https://github.com/rusefi/rusefi-1.git
first bugfixes
This commit is contained in:
parent
8365e5719e
commit
35e69c1c99
|
@ -63,14 +63,6 @@ static void writeAs(int64_t value, int numBytes) {
|
|||
}
|
||||
}
|
||||
|
||||
static void writeString(const char *value) {
|
||||
int len = strlen(value);
|
||||
writeByte(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
writeByte(value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// This is the main secret of this format! :)
|
||||
static void write(int64_t value) {
|
||||
if (value < 0 || value > 0xFFFFFFFFL) {
|
||||
|
@ -88,6 +80,14 @@ static void write(int64_t value) {
|
|||
}
|
||||
}
|
||||
|
||||
static void writeString(const char *value) {
|
||||
int len = strlen(value);
|
||||
write(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
writeByte(value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// todo: some C++ magic would allow us to drop 'count' parameter
|
||||
// todo: Look at efi::size in util
|
||||
static void write(int values[], int count) {
|
||||
|
@ -138,16 +138,31 @@ static void writeHeader() {
|
|||
|
||||
}
|
||||
|
||||
static void writeDouble(double value) {
|
||||
static_assert(sizeof(double) == 8);
|
||||
|
||||
if (value == 0.0) {
|
||||
writeByte(0);
|
||||
} else {
|
||||
writeByte(8);
|
||||
char *ptr = (char*) (void*) &value;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
writeByte(ptr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void writeChannelHeader(int ch) {
|
||||
write(0xff);
|
||||
write(ch);
|
||||
writeString(channelNames[ch]);
|
||||
write(0, 2);
|
||||
write(1.0);
|
||||
writeDouble(1.0);
|
||||
write(0);
|
||||
write(0.0);
|
||||
writeDouble(0.0);
|
||||
write(1); // or 2
|
||||
write(0.0); // or 1.0
|
||||
writeDouble(0.0); // or 1.0
|
||||
|
||||
// this part sounds like the 'next' pointer?
|
||||
if (ch == numChannels - 1) {
|
||||
|
@ -197,6 +212,7 @@ static void writeChannelData(int ch, int64_t *chDeltas, int chLastState,
|
|||
write(ch + 1);
|
||||
write(0);
|
||||
write(realDurationInSamples);
|
||||
printf("realDurationInSamples=%d\n", realDurationInSamples);
|
||||
write(1);
|
||||
write(lastRecord);
|
||||
|
||||
|
@ -417,10 +433,10 @@ static void writeEvents(CompositeEvent *events, int count) {
|
|||
prevTs = ts;
|
||||
chPrevState = chState;
|
||||
}
|
||||
}
|
||||
writeChannelData(ch, chDeltas, chPrevState, prevTs, useLongDeltas,
|
||||
deltaCount);
|
||||
}
|
||||
}
|
||||
|
||||
free(chDeltas);
|
||||
|
||||
|
@ -458,7 +474,7 @@ static void writeFooter() {
|
|||
|
||||
write(BLOCK);
|
||||
write(0);
|
||||
write(1.0);
|
||||
writeDouble(1.0);
|
||||
write(SUB);
|
||||
write(0, 6);
|
||||
write(1);
|
||||
|
|
Loading…
Reference in New Issue