Fix and Consolidate Date and Time Functions (WIP); #255

This commit is contained in:
lwvmobile
2024-04-24 16:42:25 -04:00
parent 499134bc2d
commit 1ffddf823f
11 changed files with 240 additions and 333 deletions

View File

@@ -13,8 +13,9 @@
//processing voice and/or data on both BS slots (channels) simultaneously
void dmrBS (dsd_opts * opts, dsd_state * state)
{
int i, dibit;
char * timestr;
int i, dibit;
char ambe_fr[4][24];
char ambe_fr2[4][24];
char ambe_fr3[4][24];
@@ -55,22 +56,6 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
uint8_t dummy_bits[196];
memset (dummy_bits, 0, sizeof(dummy_bits));
//add time to mirror printFrameSync
char * getTime(void) //get pretty hh:mm:ss timestamp
{
time_t t = time(NULL);
char * curr;
char * stamp = asctime(localtime( & t));
curr = strtok(stamp, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
return curr;
}
//Init slot lights
sprintf (state->slot1light, " slot1 ");
sprintf (state->slot2light, " slot2 ");
@@ -114,6 +99,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
cleanupAndExit (opts, state);
}
timestr = getTimeC();
memset (ambe_fr, 0, sizeof(ambe_fr));
memset (ambe_fr2, 0, sizeof(ambe_fr2));
memset (ambe_fr3, 0, sizeof(ambe_fr3));
@@ -279,7 +266,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
if ( strcmp (sync, DMR_BS_DATA_SYNC) == 0 )
{
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
if (internalslot == 0)
{
if (opts->inverted_dmr == 0)
@@ -315,7 +302,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
//check to see if we are expecting a VC at this point vc > 7
if (strcmp (sync, DMR_BS_DATA_SYNC) != 0 && internalslot == 0 && vc1 > 6)
{
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
//simplifying things
// char polarity[3];
@@ -336,7 +323,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
//check to see if we are expecting a VC at this point vc > 7
if (strcmp (sync, DMR_BS_DATA_SYNC) != 0 && internalslot == 1 && vc2 > 6)
{
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
//simplifying things
// char polarity[3];
@@ -374,7 +361,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
skipcount = 0; //reset skip count if processing voice frames
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
//simplifying things
char polarity[3];
@@ -585,7 +572,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
if (tact_okay != 1 || emb_ok != 1)
{
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
fprintf (stderr,"Sync: DMR ");
fprintf (stderr, "%s", KRED);
fprintf (stderr, "| VOICE CACH/EMB ERR");
@@ -608,6 +595,8 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
}
free (timestr);
}
//Process buffered half frame and 2nd half and then jump to full BS decoding
@@ -643,22 +632,9 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
11, 12, 2, 13, 14,
15, 3, 16, 4, 17, 18,
19, 5, 20, 21, 22, 6, 23
};
//add time to mirror printFrameSync
char * getTime(void) //get pretty hh:mm:ss timestamp
{
time_t t = time(NULL);
};
char * curr;
char * stamp = asctime(localtime( & t));
curr = strtok(stamp, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
return curr;
}
char * timestr = getTimeC();
//payload buffer
//CACH + First Half Payload + Sync = 12 + 54 + 24
@@ -807,7 +783,7 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
fclose (pFile);
}
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
char polarity[3];
char light[18];
@@ -909,7 +885,7 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
//if we have a tact err, then produce sync pattern/err message
if (tact_okay != 1 || sync_okay != 1)
{
fprintf (stderr,"%s ", getTime());
fprintf (stderr,"%s ", timestr);
fprintf (stderr,"Sync: DMR ");
fprintf (stderr, "%s", KRED);
fprintf (stderr, "| VOICE CACH/SYNC ERR");
@@ -931,5 +907,6 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state)
dmr_reset_blocks (opts, state);
}
free (timestr);
}