Commit a20f85ef authored by Joanne Hugé's avatar Joanne Hugé

Add socket option for timestamps

parent 3d857a59
...@@ -54,7 +54,7 @@ static size_t tx_buffer_len = sizeof(tx_buffer); ...@@ -54,7 +54,7 @@ static size_t tx_buffer_len = sizeof(tx_buffer);
static int fd; static int fd;
static int so_timestamping_flags = static int so_timestamping_flags =
SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_TX_SOFTWARE; SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_RAW_HARDWARE;
// Sets the interface // Sets the interface
static int set_if(char *network_if) { static int set_if(char *network_if) {
...@@ -165,12 +165,15 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime, ...@@ -165,12 +165,15 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
if (sendmsgerr < 0) if (sendmsgerr < 0)
error(EXIT_FAILURE, errno, "sendmsg failed, ret value: %d\n", sendmsgerr); error(EXIT_FAILURE, errno, "sendmsg failed, ret value: %d\n", sendmsgerr);
pollerr = poll(&poll_fd, 1, 0); for(int i = 0; i < (use_timestamps + 1); i++) {
// If the poll revents containts a POLLERR flag printf("Polling...\n");
if (pollerr == 1 && (poll_fd.revents & POLLERR)) { pollerr = poll(&poll_fd, 1, 0);
process_socket_error_queue(fd); // If the poll revents containts a POLLERR flag
} else if(use_timestamps) { if (pollerr == 1 && (poll_fd.revents & POLLERR)) {
process_timestamps(fd); process_socket_error_queue(fd);
} else if(use_timestamps) {
process_timestamps(fd);
}
} }
} }
...@@ -192,11 +195,12 @@ static void process_timestamps(int sock) { ...@@ -192,11 +195,12 @@ static void process_timestamps(int sock) {
msg.msg_control = &control; msg.msg_control = &control;
msg.msg_controllen = sizeof(control); msg.msg_controllen = sizeof(control);
if (recvmsg(sock, &msg, 0) == -1) { if (recvmsg(sock, &msg, MSG_DONTWAIT) == -1) {
fprintf(stderr, "recvmsg failed"); fprintf(stderr, "recvmsg failed");
exit(EXIT_FAILURE);
} }
print_timestamps(&msg); else {
print_timestamps(&msg);
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment