comparison FXAnalyse.c @ 257:8cbfce046d41

Try to read back the frequency values from AD9912 at startup Reset the AD9912 frequencies to the default value only as a fallback.
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 05 Jun 2015 21:51:25 +0200
parents 708de02ef948
children dfbee05fe464
comparison
equal deleted inserted replaced
256:708de02ef948 257:8cbfce046d41
717 int value, void *callbackData); 717 int value, void *callbackData);
718 718
719 719
720 int main (int argc, char *argv[]) 720 int main (int argc, char *argv[])
721 { 721 {
722 int rv; 722 int i, rv, nchan;
723 int nchan; 723 double frequency, clock;
724 double frequency;
725 char expr[1024]; 724 char expr[1024];
726 char host[256]; 725 char host[256];
727 double clock; 726 int PANEL_DDS[4] = { PANEL_DDS1, PANEL_DDS2, PANEL_DDS3, PANEL_DDS4 };
728 727
729 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) 728 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0)
730 return -1; 729 return -1;
731 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) 730 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0)
732 return -1; 731 return -1;
784 // initialize AD9912 DDS box 783 // initialize AD9912 DDS box
785 rv = ad9912_init(&ad9912, host, clock); 784 rv = ad9912_init(&ad9912, host, clock);
786 if (rv) 785 if (rv)
787 logmessage(ERROR, "ad9912 init erorr=%d", -rv); 786 logmessage(ERROR, "ad9912 init erorr=%d", -rv);
788 787
789 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); 788 // try to read back current frequency from DDS
790 ad9912_set_frequency_w(&ad9912, 0, frequency); 789 for (i = 0; i < 4; i++) {
791 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); 790 rv = ad9912_get_frequency(&ad9912, i, &frequency);
792 ad9912_set_frequency_w(&ad9912, 1, frequency); 791 if ((rv) || (frequency == 0.0)) {
793 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); 792 logmessage(WARNING, "reset DDS%d frequency to default value", i + 1);
794 ad9912_set_frequency_w(&ad9912, 2, frequency); 793 GetCtrlVal(MainPanel, PANEL_DDS[i], &frequency);
795 GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); 794 ad9912_set_frequency_w(&ad9912, i, frequency);
796 ad9912_set_frequency_w(&ad9912, 3, frequency); 795 }
796 SetCtrlVal(MainPanel, PANEL_DDS[i], frequency);
797 }
797 798
798 // setup ZMQ pub socket 799 // setup ZMQ pub socket
799 char *socket; 800 char *socket;
800 rv = Ini_GetStringCopy(configuration, "ZMQ", "socket", &socket); 801 rv = Ini_GetStringCopy(configuration, "ZMQ", "socket", &socket);
801 if (! rv) 802 if (! rv)