-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tx_timed_samples.cpp with float timespec creates LATE errors #592
Comments
As a quick follow-up, this might help to debug:
which shows that in the conversion something happens. And this little difference makes UHD misinterpret time_spec in some way which I cannot debug. |
tl;dr: Use a recent UHD and this won't happen, and don't use There are a couple of things going on here. First, remember that #include <iostream>
int main(void)
{
double t0_d = 0.3;
uint64_t t0_du = t0_d * 245.76e6;
float t0_f = 0.3;
uint64_t t0_fu = double(t0_f) * 245.76e6;
std::cout << t0_du << std::endl; // Will output: 73728000
std::cout << t0_fu << std::endl; // 73728002
return 0;
} Using a float or a double will yield two different tick values, offset by over 8ns, or two samples! This is already too bad to be useful, so the first takeaway is, just don't ever use The next thing is that X410 uses 4 samples-per-clock in the configuration that you're running. Maybe you can see where this is going: The good news is, you don't need to fix your code to make this do something. In 9afa6be, we allowed fractional multiples of SPC. That means that your code with a recent version of UHD won't produce the lates anymore. However, it will still not transmit at the right time, you will be off by 8ns. You might not care, but others might and therefore I must repeat this again: Don't specify timestamps as |
Thanks @mbr0wn for the detailed explanation why this happened in the past. Good that it's fixed! |
Issue Description
I found a weird behaviour in setting the time_spec for a burst transmission in the future. I modified the tx_timed_samples.cpp example, where i changed the type of
seconds_in_future
fromdouble
tofloat
. Moreover, I added some more debug output. I attach the source code below.Setup
If I compile this the program on the USRP X410 with UHD v4.2.0.0 freshly installed with
Expected Behaviour
and run as such:
Everything is as expected.
Erroneous behaviour
However, If I run with a nsecs value which is not exactly representable in floating point (like 0.3), The output becomes erronous (there are many L in the console, and I get many async error code 8 (which is LATE):
if I change back the type of
seconds_in_future
todouble
and also in the options parser line, the error is gone and evreything works as expected.I know that 0.3seconds cannot be fully represented in both double adn float. However, I expect that the casting into double would not create any problems as long as the time is clearly in the future. I do not expect to see these "LATE" messages in the console, even though I supply a float (also, the compiler does not throw a warning regardign a lossy conversion).
Source code
The text was updated successfully, but these errors were encountered: