Always emit a message reception time, as otherwise the FR24 uploader is unhappy.
When we don't have a time available (e.g. remote message) use the system time.
This commit is contained in:
parent
bf111360bc
commit
15f3408d8e
41
net_io.c
41
net_io.c
|
@ -293,8 +293,8 @@ void modesSendRawOutput(struct modesMessage *mm) {
|
||||||
void modesSendSBSOutput(struct modesMessage *mm) {
|
void modesSendSBSOutput(struct modesMessage *mm) {
|
||||||
char msg[256], *p = msg;
|
char msg[256], *p = msg;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
struct timeb epocTime;
|
struct timeb epocTime_receive, epocTime_now;
|
||||||
struct tm stTime;
|
struct tm stTime_receive, stTime_now;
|
||||||
int msgType;
|
int msgType;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -336,26 +336,33 @@ void modesSendSBSOutput(struct modesMessage *mm) {
|
||||||
// Fields 1 to 6 : SBS message type and ICAO address of the aircraft and some other stuff
|
// Fields 1 to 6 : SBS message type and ICAO address of the aircraft and some other stuff
|
||||||
p += sprintf(p, "MSG,%d,111,11111,%06X,111111,", msgType, mm->addr);
|
p += sprintf(p, "MSG,%d,111,11111,%06X,111111,", msgType, mm->addr);
|
||||||
|
|
||||||
// Fields 7 & 8 are the message reception time and date
|
// Find current system time
|
||||||
if (mm->timestampMsg && !mm->remote) { // Make sure the records' timestamp is valid before outputing it
|
ftime(&epocTime_now); // get the current system time & date
|
||||||
epocTime = Modes.stSystemTimeBlk; // This is the time of the start of the Block we're processing
|
stTime_now = *localtime(&epocTime_now.time);
|
||||||
|
|
||||||
|
// Find message reception time
|
||||||
|
if (mm->timestampMsg && !mm->remote) { // Make sure the records' timestamp is valid before using it
|
||||||
|
epocTime_receive = Modes.stSystemTimeBlk; // This is the time of the start of the Block we're processing
|
||||||
offset = (int) (mm->timestampMsg - Modes.timestampBlk); // This is the time (in 12Mhz ticks) into the Block
|
offset = (int) (mm->timestampMsg - Modes.timestampBlk); // This is the time (in 12Mhz ticks) into the Block
|
||||||
offset = offset / 12000; // convert to milliseconds
|
offset = offset / 12000; // convert to milliseconds
|
||||||
epocTime.millitm += offset; // add on the offset time to the Block start time
|
epocTime_receive.millitm += offset; // add on the offset time to the Block start time
|
||||||
if (epocTime.millitm > 999) // if we've caused an overflow into the next second...
|
if (epocTime_receive.millitm > 999) { // if we've caused an overflow into the next second...
|
||||||
{epocTime.millitm -= 1000; epocTime.time ++;} // ..correct the overflow
|
epocTime_receive.millitm -= 1000;
|
||||||
stTime = *localtime(&epocTime.time); // convert the time to year, month day, hours, min, sec
|
epocTime_receive.time ++; // ..correct the overflow
|
||||||
p += sprintf(p, "%04d/%02d/%02d,", (stTime.tm_year+1900),(stTime.tm_mon+1), stTime.tm_mday);
|
}
|
||||||
p += sprintf(p, "%02d:%02d:%02d.%03d,", stTime.tm_hour, stTime.tm_min, stTime.tm_sec, epocTime.millitm);
|
stTime_receive = *localtime(&epocTime_receive.time);
|
||||||
} else {
|
} else {
|
||||||
p += sprintf(p, ",,");
|
epocTime_receive = epocTime_now; // We don't have a usable reception time; use the current system time
|
||||||
}
|
stTime_receive = stTime_now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields 7 & 8 are the message reception time and date
|
||||||
|
p += sprintf(p, "%04d/%02d/%02d,", (stTime_receive.tm_year+1900),(stTime_receive.tm_mon+1), stTime_receive.tm_mday);
|
||||||
|
p += sprintf(p, "%02d:%02d:%02d.%03d,", stTime_receive.tm_hour, stTime_receive.tm_min, stTime_receive.tm_sec, epocTime_receive.millitm);
|
||||||
|
|
||||||
// Fields 9 & 10 are the current time and date
|
// Fields 9 & 10 are the current time and date
|
||||||
ftime(&epocTime); // get the current system time & date
|
p += sprintf(p, "%04d/%02d/%02d,", (stTime_now.tm_year+1900),(stTime_now.tm_mon+1), stTime_now.tm_mday);
|
||||||
stTime = *localtime(&epocTime.time); // convert the time to year, month day, hours, min, sec
|
p += sprintf(p, "%02d:%02d:%02d.%03d", stTime_now.tm_hour, stTime_now.tm_min, stTime_now.tm_sec, epocTime_now.millitm);
|
||||||
p += sprintf(p, "%04d/%02d/%02d,", (stTime.tm_year+1900),(stTime.tm_mon+1), stTime.tm_mday);
|
|
||||||
p += sprintf(p, "%02d:%02d:%02d.%03d", stTime.tm_hour, stTime.tm_min, stTime.tm_sec, epocTime.millitm);
|
|
||||||
|
|
||||||
// Field 11 is the callsign (if we have it)
|
// Field 11 is the callsign (if we have it)
|
||||||
if (mm->bFlags & MODES_ACFLAGS_CALLSIGN_VALID) {p += sprintf(p, ",%s", mm->flight);}
|
if (mm->bFlags & MODES_ACFLAGS_CALLSIGN_VALID) {p += sprintf(p, ",%s", mm->flight);}
|
||||||
|
|
Loading…
Reference in a new issue