Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timing_parser: log failed cause to a file #726

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ If you find value in our project, please consider giving it a star. Your support
* SIMD color space converter between big-endian and little-endian.
* ST2110-22 with encoder/decoder plugin interface.
* ST2022-6 by RTP passthrough interface.
* ST2110-20 RX timing compliance parser with hardware RX timestamp offload.

### 1.2 Architecture

Expand Down
1 change: 1 addition & 0 deletions lib/src/st2110/st_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ struct st_rx_video_session_impl {
bool time_measure;
uint16_t rx_burst_size;
uint16_t cur_succ_burst_cnt;
bool in_continuous_burst[MTL_SESSION_PORT_MAX];

struct st20_rx_ops ops;
char ops_name[ST_MAX_NAME_LEN];
Expand Down
10 changes: 10 additions & 0 deletions lib/src/st2110/st_rx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,11 @@ static inline void rv_tp_pkt_handle(struct st_rx_video_session_impl* s,
tp->stat_untrusted_pkts++;
return;
}
if (s->in_continuous_burst[s_port]) {
/* untrusted result */
tp->stat_untrusted_pkts++;
return;
}
struct mtl_main_impl* impl = rv_get_impl(s);
enum mtl_port port = mt_port_logic2phy(s->port_maps, s_port);

Expand Down Expand Up @@ -2670,11 +2675,16 @@ static int rv_pkt_rx_tasklet(struct st_rx_video_session_impl* s) {
s->stat_burst_succ_cnt++;
s->stat_burst_pkts_sum += rv;
if (rv > s->stat_burst_pkts_max) s->stat_burst_pkts_max = rv;
if (rv >= (s->rx_burst_size / 2)) {
s->in_continuous_burst[s_port] = true;
}

rv_handle_mbuf(&s->priv[s_port], &mbuf[0], rv);
rte_pktmbuf_free_bulk(&mbuf[0], rv);

done = false;
} else {
s->in_continuous_burst[s_port] = false;
}
}

Expand Down
11 changes: 11 additions & 0 deletions python/example/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import argparse
import ctypes
import datetime
import sys

import cv2
Expand Down Expand Up @@ -117,6 +118,10 @@ def parse_args(is_tx):
)
# lcores
parser.add_argument("--lcores", type=str, default="", help="lcores")
# log file
parser.add_argument("--log_file", type=str, default="py_temp.log", help="log_file")
# default max histories 10 mins, 1 entry per second
parser.add_argument("--histories", type=int, default=60 * 10, help="histories")
return parser.parse_args()


Expand Down Expand Up @@ -354,3 +359,9 @@ def copy_to_st_frame(yuv_frame, frame):
memcpy_ops.src = src_address_uint64
memcpy_ops.sz = frame.data_size
mtl.mtl_memcpy_action(memcpy_ops)


def cur_time_str():
current_time = datetime.datetime.now()
formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
return formatted_time
23 changes: 16 additions & 7 deletions python/example/rx_timing_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
class Dashboard:
active = False

def __init__(self, max_histories):
def __init__(self, max_histories, title_str):
self.max_histories = max_histories
# init data
self.init_data()
# init vrx plot
self.fig, self.ax = plt.subplots()
plt.title("ST2110-20 Rx Timing Parser")
plt.title(title_str)
plt.subplots_adjust(bottom=0.2)
(self.vrx_max_line,) = self.ax.plot(
self.times, self.vrx_max_values, label="VRX Max"
Expand Down Expand Up @@ -110,7 +110,7 @@ def update_compliance(self, narrow, wide, fail):
self.fail_count += fail


def rx_frame_loop(st20p_rx, update_interval, plot):
def rx_frame_loop(st20p_rx, update_interval, plot, log_file):
f_idx = 0
vrx_min = 10000
vrx_max = -10000
Expand All @@ -119,8 +119,9 @@ def rx_frame_loop(st20p_rx, update_interval, plot):
wide = 0
fail = 0

# loop until ctrl-c
log_file.write(f"{misc_util.cur_time_str()}: start\n")

# loop until ctrl-c
while plot.active:
frame = mtl.st20p_rx_get_frame(st20p_rx)
if frame:
Expand All @@ -137,6 +138,8 @@ def rx_frame_loop(st20p_rx, update_interval, plot):
wide += 1
else:
fail += 1
log_file.write(f"{misc_util.cur_time_str()}: {tp.failed_cause}\n")
log_file.flush()

if f_idx > update_interval:
vrx_avg = vrx_avg_sum // f_idx
Expand All @@ -160,6 +163,8 @@ def rx_frame_loop(st20p_rx, update_interval, plot):
# sleep to allow ui draw
time.sleep(0.005)

log_file.write(f"{misc_util.cur_time_str()}: ending\n")


def plt_show():
plt.show()
Expand All @@ -168,8 +173,10 @@ def plt_show():
def main():
args = misc_util.parse_args(False)

# initial plot, max 1 hour, 1 item 1 second
plot = Dashboard(max_histories=60 * 60 * 1)
log_file = open(args.log_file, "w")

title_str = f"ST2110-20 Rx Timing Parser: {args.p_rx_ip}@{args.udp_port}"
plot = Dashboard(max_histories=args.histories, title_str=title_str)

# Init mtl para
init_para = mtl.mtl_init_params()
Expand Down Expand Up @@ -226,7 +233,7 @@ def main():
# update plot per 1 s
framerate = mtl.st_frame_rate(rx_para.fps)
rx_frame_thread = threading.Thread(
target=rx_frame_loop, args=(st20p_rx, framerate, plot)
target=rx_frame_loop, args=(st20p_rx, framerate, plot, log_file)
)
rx_frame_thread.start()

Expand All @@ -245,6 +252,8 @@ def main():
# Free MTL instance
mtl.mtl_uninit(mtl_handle)

log_file.close()

print("Everything fine, bye")


Expand Down
Loading