aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2017-08-03 23:56:45 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2017-08-03 23:56:45 +0200
commit4e234b854f194eb118b476e0c76b56e4af89d5ff (patch)
tree4f43ce1826b34b24c276ef4a9f09bea9d692e8ce
parentb5a4c3f274bb8bae7396a7d61c578bd9907228f1 (diff)
cec-ctl: fix pin analysis bug
The transition between a NACKed byte and a start bit was not handled correctly, cause incorrect 'low drive' errors. Also fix a bug where the last bit of the pin recording file was not processed. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/cec-ctl/cec-ctl.cpp6
-rw-r--r--utils/cec-ctl/cec-pin.cpp6
2 files changed, 8 insertions, 4 deletions
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index ba185f9d..80ca0163 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -1634,6 +1634,7 @@ static void monitor(struct node &node, __u32 monitor_time, const char *store_pin
static void analyze(const char *analyze_pin)
{
FILE *fanalyze = fopen(analyze_pin, "r");
+ struct cec_event ev = { };
unsigned long tv_sec, tv_nsec, tv_usec;
unsigned version;
unsigned log_addr_mask;
@@ -1682,7 +1683,6 @@ static void analyze(const char *analyze_pin)
printf("Logical Address Mask: 0x%04x\n\n", log_addr_mask);
while (fgets(s, sizeof(s), fanalyze)) {
- struct cec_event ev = { };
unsigned high;
if (sscanf(s, "%lu.%09lu %d\n", &tv_sec, &tv_nsec, &high) != 3 || high > 1) {
@@ -1695,6 +1695,10 @@ static void analyze(const char *analyze_pin)
line++;
}
+ tv_sec++;
+ ev.ts = tv_sec * 1000000000ULL + tv_nsec;
+ log_event(ev);
+
fclose(fanalyze);
return;
diff --git a/utils/cec-ctl/cec-pin.cpp b/utils/cec-ctl/cec-pin.cpp
index 6b40339b..b6df3810 100644
--- a/utils/cec-ctl/cec-pin.cpp
+++ b/utils/cec-ctl/cec-pin.cpp
@@ -193,7 +193,7 @@ static void cec_pin_rx_data_bit_was_high(bool is_high, __u64 ev_ts, __u64 usecs,
s = find_cdc_opcode_name(byte);
}
printf("%10.06f: rx 0x%02x%s%s%s (%s) %s\n",
- (ev_ts / 1000 - usecs) / 1000000.0, byte,
+ (ev_ts / 1000 - usecs - low_usecs + CEC_TIM_DATA_BIT_TOTAL) / 1000000.0, byte,
eom ? " EOM" : "", (bcast ^ bit) ? " NACK" : " ACK",
bcast ? " (broadcast)" : "",
ts2s(ev_ts - usecs * 1000).c_str(),
@@ -210,7 +210,7 @@ static void cec_pin_rx_data_bit_was_high(bool is_high, __u64 ev_ts, __u64 usecs,
if ((!eom && ack) && low_usecs + usecs_min > CEC_TIM_DATA_BIT_TOTAL_MAX)
printf("%10.06f: data bit %d total time too long (%.2f ms)\n",
ts, rx_bit - 1, (low_usecs + usecs_min) / 1000.0);
- if (eom || is_high)
+ if (eom || is_high || low_usecs + usecs_min > CEC_TIM_DATA_BIT_TOTAL_MAX)
state = is_high ? CEC_ST_IDLE : CEC_ST_RECEIVE_START_BIT;
if (state == CEC_ST_IDLE)
printf("\n");
@@ -322,6 +322,7 @@ void log_event_pin(bool is_high, __u64 ev_ts)
if (is_high)
return;
}
+ cec_pin_debug(ev_ts, (ev_ts - last_ts) / 1000, was_high, is_high);
if (show_info) {
printf("%10.06f: ", ts);
if (last_change_ts && is_high && was_high)
@@ -342,7 +343,6 @@ void log_event_pin(bool is_high, __u64 ev_ts)
if (!is_high)
last_1_to_0_ts = ev_ts;
}
- cec_pin_debug(ev_ts, (ev_ts - last_ts) / 1000, was_high, is_high);
if (!is_high) {
float usecs = (ev_ts - last_ts) / 1000;
unsigned periods = usecs / CEC_TIM_DATA_BIT_TOTAL;

Privacy Policy