2022-10-11 09:41 AM
I'm trying to transmit a 4D array of floats from an stm32l552zet6q to a PC using a USB connection. I can collect the array elements and store them, but when I pass the array into the transmission function, I don't see the same elements.
This image is of the array values as they should be, and are when outside the sendData and sendMatrix functions.
And this image is what arrives inside the sendData/sendMatrix functions:
Additionally, I cannot get sprintf to format a string with ANY float values, as shown in the below screenshot
The test matrix I've declared is a local variable with a defined size (test[4][35][42][3]).
I've tried altering the code to instead use pointers to the test matrix, but I get the exact same results, though it's entirely possible I was using them incorrectly. Any assistance is appreciated.
Solved! Go to Solution.
2022-10-12 11:57 AM
Found the final problem. At some point, I'd accidentally changed configuration from debug to release, and did so before enabling the sprintf float option. So, whenever I fired up debug, I couldn't send any float information. I switched back to debug, re-enabled the float sprintf option, and everything is working
2022-10-11 09:56 AM
Make sure floating point (s)printf() functionality has been enabled and the correct libraries selected. By default I think it's disabled to keep the code foot-print low. There's been 1000's of such posts, you should be able to find some suggestions or tutorials.
Some of the debug screens seem to should addresses of pointers
Check that the sizeof() for the array matches expectations of size vs dimensions.
It should be possible to pass the data as a block, and be able to memcpy() it
2022-10-11 10:01 AM
I do have that functionality enabled (CubeIDE pestered me about it when it wasn't). I'll recheck the posts as well while I'm trying your suggestions. Thanks for the quick response!
That said, I am confused why the debug screens would be showing the addresses of pointers, since they don't do anything like that in other functions where I pass the same array in to set the values; It's all zeroes there. The main difference is that I'm setting the values in the one function, and putting those values into a string in the other, but I'm lost on why that would change the appearance of the array when I enter the other function.
2022-10-11 11:34 AM
Okay, I tried the memcpy thing, and it the array I tried to copy the code into just came out as all zeroes, even though the array I'm copying from shows the proper contents.
I'll try to get more information while I'm perusing more pages for solutions
Update: Figured out the problem I was having with memcpy. I was passing the maximum sizes of the array (which also read as the very end of the array), rather than the specific slots I wanted copied into the temporary array. It was always going to be zero, since that was constantly checking the last three slots that wouldn't be updated until the very end
Unfortunately, that doesn't solve the problem of the floats not showing up when I use sprintf to format a string that includes them. I even replaced the array with three separate floats to see if that changed things and it didn't. I've read that there's a known bug with ST linkers that can prevent floats from working, but I can't find it in my linker.
2022-10-12 11:57 AM
Found the final problem. At some point, I'd accidentally changed configuration from debug to release, and did so before enabling the sprintf float option. So, whenever I fired up debug, I couldn't send any float information. I switched back to debug, re-enabled the float sprintf option, and everything is working