Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ka9q committed Aug 15, 2023
1 parent 400da94 commit 51b259a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions control.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ int decode_radio_status(struct demod *demod,uint8_t const *buffer,int length){
case EOL:
break;
case CMD_CNT:
Frontend.commands = decode_int(cp,optlen);
demod->commands = decode_int(cp,optlen);
break;
case DESCRIPTION:
decode_string(cp,optlen,Frontend.description,sizeof(Frontend.description));
Expand Down Expand Up @@ -1020,7 +1020,7 @@ int decode_radio_status(struct demod *demod,uint8_t const *buffer,int length){
demod->output.samples = decode_int(cp,optlen);
break;
case COMMAND_TAG:
Frontend.command_tag = decode_int(cp,optlen);
demod->command_tag = decode_int(cp,optlen);
break;
case RADIO_FREQUENCY:
demod->tune.freq = decode_double(cp,optlen);
Expand Down Expand Up @@ -1383,7 +1383,7 @@ void display_output(WINDOW *w,struct demod const *demod){
pprintw(w,row++,col,"","%s->%s",formatsock(&Metadata_source_address),
formatsock(&Metadata_dest_address));
pprintw(w,row++,col,"Status pkts","%'llu",Metadata_packets);
pprintw(w,row++,col,"Control pkts","%'llu",Frontend.commands);
pprintw(w,row++,col,"Control pkts","%'llu",demod->commands);
pprintw(w,row++,col,"Blocks since last poll","%'llu",demod->blocks_since_poll);

mvwhline(w,row,0,0,1000);
Expand Down
9 changes: 2 additions & 7 deletions radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ struct frontend {

// Stuff maintained by our upstream source and filled in by the status daemon
char description[256]; // Free-form text
uint64_t commands; // Command counter
uint32_t command_tag; // Last received command tag
int samprate; // Sample rate on data stream
int64_t timestamp; // Nanoseconds since GPS epoch 6 Jan 1980 00:00:00 UTC
double frequency;
Expand Down Expand Up @@ -253,6 +251,8 @@ struct demod {
float rate;
} deemph;

uint32_t commands;
uint32_t command_tag;
uint64_t blocks_since_poll; // Used for averaging signal levels

pthread_t sap_thread;
Expand All @@ -277,8 +277,6 @@ extern char const *Modefile;
extern int Verbose;
extern float Blocktime; // Common to all receiver slices. NB! Milliseconds, not seconds
extern uint64_t Metadata_packets;
extern uint64_t Commands;
extern uint32_t Command_tag; // Echoed in responses to commands (settable)

// Functions/methods to control a demod instance
struct demod *alloc_demod(void);
Expand All @@ -294,13 +292,10 @@ int start_demod(struct demod * restrict demod);
int kill_demod(struct demod ** restrict demod);
double set_first_LO(struct demod const * restrict, double);
int downconvert(struct demod *demod);
int decode_fe_status(struct frontend *frontend,uint8_t const *buffer,int length);

// Helper threads
void *proc_samples(void *);
void *sap_send(void *);
void *radio_status(void *);
void *sdr_status(void *);
void *demod_reaper(void *);

// Demodulator thread entry points
Expand Down
8 changes: 4 additions & 4 deletions radio_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void *radio_status(void *arg){
if(length <= 0 || (enum pkt_type)buffer[0] != CMD)
continue; // short packet, or a response; ignore

Commands++;
// for a specific ssrc?
uint32_t ssrc = get_ssrc(buffer+1,length-1);
if(ssrc != 0){
Expand Down Expand Up @@ -87,6 +86,7 @@ void *radio_status(void *arg){
if(demod != NULL){
if(demod->lifetime != 0)
demod->lifetime = 20; // Restart 20 second self-destruct timer
demod->commands++;
decode_radio_commands(demod,buffer+1,length-1);
send_radio_status(&Frontend,demod,1); // Send status in response
}
Expand Down Expand Up @@ -144,7 +144,7 @@ static int decode_radio_commands(struct demod *demod,uint8_t const *buffer,int l
case EOL: // Shouldn't get here
goto done;
case COMMAND_TAG:
Command_tag = decode_int(cp,optlen);
demod->command_tag = decode_int(cp,optlen);
break;
case OUTPUT_SAMPRATE:
// Restart the demodulator to recalculate filters, etc
Expand Down Expand Up @@ -392,8 +392,8 @@ static int encode_radio_status(struct frontend const *frontend,struct demod cons
*bp++ = STATUS; // 0 = status, 1 = command

// parameters valid in all modes
encode_int32(&bp,COMMAND_TAG,Command_tag); // at top to make it easier to spot in dumps
encode_int64(&bp,CMD_CNT,Commands); // integer
encode_int32(&bp,COMMAND_TAG,demod->command_tag); // at top to make it easier to spot in dumps
encode_int64(&bp,CMD_CNT,demod->commands); // integer
if(strlen(frontend->description) > 0)
encode_string(&bp,DESCRIPTION,frontend->description,strlen(frontend->description));

Expand Down

0 comments on commit 51b259a

Please sign in to comment.