From 3d830067db64de361c9f649803002303de09ecc1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 18 Jun 2021 09:49:16 -0400 Subject: [PATCH] added for loop for sending 5 times first time --- afsk/main.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index f604374e..6adbd623 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -2195,27 +2195,20 @@ void get_tlm_fox() { // if ((mode == BPSK) && (firstTime == 1)) // only do first time if (firstTime == 1) // only do first time - { - start = millis(); // send frame three times - sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); - printf("socket send 3 %d ms bytes: %d \n\n", (unsigned int)millis() - start, sock_ret); - - if (sock_ret < (ctr * 2 + 2)) { - // printf("Not resending\n"); - sleep(0.5); - sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); - printf("socket send 4 %d ms bytes: %d \n\n", millis() - start, sock_ret); - } - start = millis(); // send frame twice - sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); - printf("socket send 5 %d ms bytes: %d \n\n", (unsigned int)millis() - start, sock_ret); - - if (sock_ret < (ctr * 2 + 2)) { - // printf("Not resending\n"); - sleep(0.5); - sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); - printf("socket send 6 %d ms bytes: %d \n\n", millis() - start, sock_ret); - } + { + for (int times = 0; times < 6; times++) + { + start = millis(); // send frame three times + sock_ret = send(sock, buffer, (unsigned int)(ctr * 2 + 2), 0); + printf("socket send %d in %d ms bytes: %d \n\n",times, (unsigned int)millis() - start, sock_ret); + + if (sock_ret < (ctr * 2 + 2)) { + // printf("Not resending\n"); + sleep(0.5); + sock_ret = send(sock, &buffer[sock_ret], (unsigned int)(ctr * 2 + 2 - sock_ret), 0); + printf("socket resend %d in %d ms bytes: %d \n\n",times, millis() - start, sock_ret); + } + } } if (sock_ret == -1) {