Skip to contentSkip to conversation

cec: expand Timer Programming tests

PATCH New Deborah Brouwer 1 participant 3 messages Jul 13, 2021 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

v4 cover cec: expand Timer Programming tests

This is part of an Outreachy project to expand the testing of Timer Programming messages as handled by CEC adapters.

Changes since v3:
Patch 1/2: cec: expand Timer Programming tests
- revise error and overlap function names and return values
- use struct tm as a pointer
- increment year only when follower receives set time message
- clear timers in previous year/next year if any
- add helper functions to send and clear timers
- add logical address Backup to device that may pass tests
- add check for standby message received during recording Patch 2/2: cec-follower: emulate programmed timer recordings
- add check for standby message received during recording

Changes since v2:
Patch 1/2: cec: expand Timer Programming tests
- use 3-character abbreviations for months
- in set_timer tests, simplify the method for finding "tomorrow"
- use fixed dates for timer_error tests
- use full leap-year algorithm
- add source type and recording sequence as ways to compare timers
- add source type and recording sequence to print_timers()
- replace timer field end_time with duration in seconds
- replace timer_duplicate function with std::set::find
- do not truncate overlapped timers, just set them with a warning Patch 2/2: cec-follower: emulate programmed timer recordings
- new patch

Changes since v1:
- rename functions for clarity
- set most test timers as a function of current time, not fixed times
- use time_t instead of struct tm to hold start/stop times
- use std::set instead of std::list to hold timers
- add repeat timers (recording sequence) emulation

Deborah Brouwer (2):
cec: expand Timer Programming tests
cec-follower: emulate programmed timer recordings

 utils/cec-compliance/cec-compliance.cpp |   1 +
 utils/cec-compliance/cec-compliance.h   |   1 +
 utils/cec-compliance/cec-test.cpp       | 424 +++++++++++++++++++-----
 utils/cec-follower/cec-follower.cpp     |  59 ++++
 utils/cec-follower/cec-follower.h       |  44 +++
 utils/cec-follower/cec-processing.cpp   |  65 ++++
 utils/cec-follower/cec-tuner.cpp        | 295 +++++++++++++++--
 7 files changed, 788 insertions(+), 101 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/2 cec: expand Timer Programming tests

Check that Timer Status and Time Cleared Status replies have a valid operand. Send timers with out-of-range dates and check follower's response. Send an out-of-range recording sequence and check that the timer is not set. Send a duplicate timer and check that the timer is not set. Set overlapping timers and check that the timer overlap warning is set. In the follower, keep track of timers that have been received and warn if there may be insufficient space for a programmed recording.

---
 utils/cec-compliance/cec-compliance.cpp |   1 +
 utils/cec-compliance/cec-compliance.h   |   1 +
 utils/cec-compliance/cec-test.cpp       | 424 +++++++++++++++++++-----
 utils/cec-follower/cec-follower.cpp     |  54 +++
 utils/cec-follower/cec-follower.h       |  43 +++
 utils/cec-follower/cec-tuner.cpp        | 284 ++++++++++++++--
 6 files changed, 706 insertions(+), 101 deletions(-)
utils/cec-compliance/cec-compliance.cpp +1 -0
index 25931259..72199762 100644
@@ -1236,6 +1236,7 @@ int main(int argc, char **argv)
 	node.num_log_addrs = laddrs.num_log_addrs;
 	memcpy(node.log_addr, laddrs.log_addr, laddrs.num_log_addrs);
 	node.adap_la_mask = laddrs.log_addr_mask;
+	node.current_time = time(nullptr);
 
 	printf("Find remote devices:\n");
 	printf("\tPolling: %s\n", ok(poll_remote_devs(&node)));
utils/cec-compliance/cec-compliance.h +1 -0
index 41e2d63d..efc828ce 100644
@@ -167,6 +167,7 @@ struct node {
 	__u16 phys_addr;
 	bool in_standby;
 	__u8 prim_devtype;
+	time_t current_time;
 };
 
 struct remote_subtest {
utils/cec-compliance/cec-test.cpp +343 -81

564 lines not on this page · raw message

utils/cec-follower/cec-follower.cpp +54 -0

72 lines not on this page · raw message

utils/cec-follower/cec-follower.h +43 -0

67 lines not on this page · raw message

utils/cec-follower/cec-tuner.cpp +264 -20

316 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/2 cec-follower: emulate programmed timer recordings

In reply to Deborah Brouwer

Start and stop recording as timers are scheduled. Schedule future timers if a completed timer has a recording sequence. Delete overlapped and unfinished timers. Reduce available media space when a recording is completed.

---
 utils/cec-follower/cec-follower.cpp   |  5 +++
 utils/cec-follower/cec-follower.h     |  1 +
 utils/cec-follower/cec-processing.cpp | 65 +++++++++++++++++++++++++++
 utils/cec-follower/cec-tuner.cpp      | 15 ++++++-
 4 files changed, 84 insertions(+), 2 deletions(-)
utils/cec-follower/cec-follower.cpp +5 -0
index b273b988..0adf6ce8 100644
@@ -301,6 +301,10 @@ void print_timers(struct node *node)
 {
 	if (show_info) {
 		printf("Timers Set:\n");
+		if (node->state.recording_controlled_by_timer)
+			printf("Deck is currently recording from the first timer.\n");
+		if (node->state.one_touch_record_on && !node->state.recording_controlled_by_timer)
+			printf("Deck is currently recording independent of timers.\n");
 		for (auto &t : programmed_timers) {
 			std::string start = ctime(&t.start_time);
 			time_t end_time = t.start_time + t.duration;
@@ -373,6 +377,7 @@ void state_init(struct node &node)
 	node.state.one_touch_record_on = false;
 	node.state.record_received_standby = false;
 	node.state.media_space_available = 36000; /* In MB; space for 10 hours @ 1MB/sec */
+	node.state.recording_controlled_by_timer = false;
 	tuner_dev_info_init(&node.state);
 	node.state.last_aud_rate_rx_ts = 0;
 }
utils/cec-follower/cec-follower.h +1 -0
index 69c96aa7..7b22368b 100644
@@ -60,6 +60,7 @@ struct state {
 	bool one_touch_record_on;
 	bool record_received_standby;
 	int media_space_available;
+	bool recording_controlled_by_timer;
 	time_t toggle_power_status;
 	__u64 last_aud_rate_rx_ts;
 };
utils/cec-follower/cec-processing.cpp +65 -0

71 lines not on this page · raw message

utils/cec-follower/cec-tuner.cpp +13 -2
index e3e64a58..c3042e18 100644
@@ -858,6 +858,15 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns
 		cec_msg_record_status(&msg, CEC_OP_RECORD_STATUS_TERMINATED_OK);
 		transmit(node, &msg);
 		node->state.one_touch_record_on = false;
+
+		/* Delete any currently active recording timer or it may restart itself in first minute. */
+		if (node->state.recording_controlled_by_timer) {
+			node->state.recording_controlled_by_timer = false;
+			programmed_timers.erase(programmed_timers.begin());
+			if (show_info)
+				printf("Deleted manually stopped timer.\n");
+			print_timers(node);
+		}
 		/*
 		 * If standby was received during recording, enter standby when the
 		 * recording is finished unless recording device is the active source.
@@ -957,9 +966,10 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns
 		auto it_previous_year = programmed_timers.find(timer_in_previous_year);
 
 		if (it_previous_year != programmed_timers.end()) {
-			if (node->state.one_touch_record_on && it_previous_year == programmed_timers.begin()) {
+			if (node->state.recording_controlled_by_timer && it_previous_year == programmed_timers.begin()) {
 				timer_cleared_status = CEC_OP_TIMER_CLR_STAT_RECORDING;
 				node->state.one_touch_record_on = false;
+				node->state.recording_controlled_by_timer = false;
 			} else {
 				timer_cleared_status = CEC_OP_TIMER_CLR_STAT_CLEARED;
 			}
@@ -972,9 +982,10 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns
 		auto it_current_year = programmed_timers.find(timer_in_current_year);
 
 		if (it_current_year != programmed_timers.end()) {
-			if (node->state.one_touch_record_on && it_current_year == programmed_timers.begin()) {
+			if (node->state.recording_controlled_by_timer && it_current_year == programmed_timers.begin()) {
 				timer_cleared_status = CEC_OP_TIMER_CLR_STAT_RECORDING;
 				node->state.one_touch_record_on = false;
+				node->state.recording_controlled_by_timer = false;
 			} else {
 				/* Do not overwrite status if already set. */
 				if (timer_cleared_status == CEC_OP_TIMER_CLR_STAT_NO_MATCHING)
Signature · 1 line
2.25.1