ir-ctl: usb-uirt device reports carrier frequency for each pulse
PATCH 1/1 ir-ctl: usb-uirt device reports carrier frequency for each pulse
The carrier frequency is reported a number of times. So, rather than printing the last carrier reported, calculate the mean.
Possibly it would be better to calculate the mode rather than the mean.
Signed-off-by Sean Young <[email protected]>
--- utils/ir-ctl/ir-ctl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
utils/ir-ctl/ir-ctl.c +10 -5
@@ -1148,7 +1148,8 @@ int lirc_receive(struct arguments *args, int fd, unsigned features)bool keep_reading = true;bool leading_space = true; -unsigned carrier =0 ; +unsigned long long total_carriers =0 ; +unsigned int no_carriers =0 ;while (keep_reading) {ssize_t ret =TEMP_FAILURE_RETRY (read (fd, buf,sizeof (buf)));
@@ -1201,10 +1202,13 @@ int lirc_receive(struct arguments *args, int fd, unsigned features)switch (msg) {case LIRC_MODE2_TIMEOUT :fprintf (out,"-%u\n" , val); -if (carrier) -fprintf (out," # carrier %uHz, timeout %u\n" , carrier, val); +if (no_carriers) { +// averge of all the carriers reported mean (do we want the mode?) +fprintf (out," # carrier %lluHz, timeout %u\n" , total_carriers / no_carriers, val); + } leading_space = true; - carrier =0 ; + no_carriers =0 ; + total_carriers =0 ;break ;case LIRC_MODE2_PULSE :fprintf (out,"+%u " , val);
@@ -1213,7 +1217,8 @@ int lirc_receive(struct arguments *args, int fd, unsigned features)fprintf (out,"-%u " , val);break ;case LIRC_MODE2_FREQUENCY : - carrier = val; + total_carriers += val; + no_carriers +=1 ;break ; } }
Signature · 1 line
2.31.1