-
Notifications
You must be signed in to change notification settings - Fork 387
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
Fix: Planewave EFA char sign #1237
Conversation
The Planewave EFA (apparently) writes unsigned chars to the serial bus instead of signed chars as usually assumed. With this fix the data is interpreted in the correct way. This should also address indilib#1173 .
I don't think this is required all over the place. A byte is a byte whether it is char or unsigned char. I believe we should only fix the calculateChecksum function to perform the correct cast to uint8_t |
Hi Jasem,
which prints
I guess that this is also the problem in the case of the EFA driver. |
Both of these variables are stored as 0xAF in memory. Only when you use printf or use them in a math operation as is that it matters. What can be done is during the checksum, the values are casted to uint8_t first. This should ensure the calculations are correct. |
I tried it already, since this was also my first idea, but it didn't work. When doing so the checksums are fine, but the value of the reported focuser position jumps between the real position and a small, negative number, i.e. -255 to -1.
In both cases I use uint32_t to store the final number by setting the individual bytes starting from the LSB (I think). printf in both cases gets the unsigned 32 bit integer and also interpretes it as an unsigned integer. Note that both positions are initialized to 0 before that. But what comes out of it is
Personally, I would have expected the right one. Note also that this goes good up to c3=0x7F, which is the maximal value for a signed char. I tested the version of the pull request and as I said, reading the focuser position now works perfectly.
See http://planewave.com/files/tech/efa-protocol.html They write that if the raw temperature exceeds 32768 the temperature actually is negative. Wouldn't this also indicate the same problem? I think that this is also the reason for Issue C in #1173 which is also working when reading this values as unsigned chars. |
Ok thank you for taking the time to detail everything. Can you please apply this patch and try it out? It's similar to your PR. |
Thank you very much, I just tried the patch. For some bizarre reason the minus in front of the
Thank you very much for your support. |
|
Going to close this now and let's see if we need another one to fix the remainder of the issues. |
The Planewave EFA (apparently) writes unsigned chars to the serial bus
instead of signed chars as usually assumed. With this fix the data is
interpreted in the correct way. This should also address
#1173 .