|
|
@@ -7,6 +7,8 @@
|
|
|
#include <strings.h>
|
|
|
#include <string.h>
|
|
|
#include <sys/socket.h>
|
|
|
+#include <unistd.h>
|
|
|
+#include <time.h>
|
|
|
|
|
|
#include "Devices/lmx2594.h"
|
|
|
|
|
|
@@ -37,17 +39,32 @@ void handleFreqCmd(const char* recvBuff)
|
|
|
void handleLdCmd(const char* recvBuff)
|
|
|
{
|
|
|
int n = 0;
|
|
|
- char messageLd[] = "0\n";
|
|
|
+ char messageLd[] = "1\n";
|
|
|
|
|
|
printf("\nTMSG44:LD?\n");
|
|
|
|
|
|
- if (1)
|
|
|
- {
|
|
|
- strcpy(messageLd, "1\n");
|
|
|
- }
|
|
|
- else if (0)
|
|
|
+ uint32_t ld_status = lmx_ld_status(bar1);
|
|
|
+ printf("LD status: %d\n", ld_status);
|
|
|
+
|
|
|
+ clock_t before = clock();
|
|
|
+ clock_t difference;
|
|
|
+ int difference_msec = 0;
|
|
|
+ int trigger = 10; //10ms
|
|
|
+
|
|
|
+ while(!ld_status)
|
|
|
{
|
|
|
- strcpy(messageLd, "0\n");
|
|
|
+ difference = clock() - before;
|
|
|
+ difference_msec = difference * 1000 / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ if(difference_msec >= trigger)
|
|
|
+ {
|
|
|
+ strcpy(messageLd, "0\n");
|
|
|
+ printf("LD timeout\n");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ usleep(1000);
|
|
|
+ uint32_t ld_status = lmx_ld_status(bar1);
|
|
|
}
|
|
|
|
|
|
send(conn_fd, messageLd, sizeof(messageLd), 0);
|