From: Josh Blum Date: Sat, 26 Sep 2009 00:28:52 +0000 (-0700) Subject: use the new htonll and vrt types to send cal and lo freqs X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=3cb87bce0f8f20912a16f54e03d37f9fef4e0c3f;p=debian%2Fgnuradio use the new htonll and vrt types to send cal and lo freqs --- diff --git a/vrt/lib/quadradio.cc b/vrt/lib/quadradio.cc index 906f88df..cc810e68 100644 --- a/vrt/lib/quadradio.cc +++ b/vrt/lib/quadradio.cc @@ -22,6 +22,8 @@ #include #endif #include +#include +#include #include #include #include @@ -377,12 +379,11 @@ vrt::quadradio::set_mem32(int addr, int value) bool vrt::quadradio::set_lo_freq(double freq) { - uint64_t lo_freq = uint64_t(freq * (uint64_t(1)<<20)); //q20 format + vrt_freq_t lo_freq = htonll(double_to_vrt_freq(freq)); uint32_t cmd[4]; cmd[0] = htonl(0); // verb: set cmd[1] = htonl(6); // id: lo freq - cmd[2] = htonl((lo_freq >> 32) & 0xffffffff); - cmd[3] = htonl((lo_freq >> 0) & 0xffffffff); + memcpy(cmd+2, &lo_freq, sizeof(lo_freq)); return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); } @@ -390,12 +391,11 @@ vrt::quadradio::set_lo_freq(double freq) bool vrt::quadradio::set_cal_freq(double freq) { - uint64_t cal_freq = uint64_t(freq * (uint64_t(1)<<20)); //q20 format + vrt_freq_t cal_freq = htonll(double_to_vrt_freq(freq)); uint32_t cmd[4]; cmd[0] = htonl(0); // verb: set cmd[1] = htonl(7); // id: cal freq - cmd[2] = htonl((cal_freq >> 32) & 0xffffffff); - cmd[3] = htonl((cal_freq >> 0) & 0xffffffff); + memcpy(cmd+2, &cal_freq, sizeof(cal_freq)); return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); }