jvoermans / Vibration_Logger

Logger to measure sea ice vibrations
3 stars 1 forks source link

Problems with the sonar #42

Open jerabaul29 opened 3 years ago

jerabaul29 commented 3 years ago

@patrickelectric this is the repo where we work on a high frequency logger using the Arduino Due.

Basically, the logger itself is this code:

https://github.com/jvoermans/Vibration_Logger/tree/master/material_Jean/Due_SD_high_frequency_logger

We have very strange issues when trying to add the sonar. I and @jvoermans have spent quite a bit of time trying to debug that (see for example #36 ) without success.

jerabaul29 commented 3 years ago

The strange things are:

But somehow the sonar and the rest of the logger do not play well together.

I am for example very shocked at how things fail in #36 . I do not understand how it is possible that I do not get any serial information from within the call to measure_and_log. I may be missing something obvious, but I cannot find what is wrong. This is why I start to believe that there may be some memory corruption happening somehow that really mess up things. That idea got reinforced when seeing that 1) the ping library uses some malloc, which is not great on MCUs, 2) some of the malloc was done wrongly (see https://github.com/bluerobotics/ping-arduino/issues/21 ). Same thing, used og memcpy make me a bit worried.

jerabaul29 commented 3 years ago

In particular, how is it possible that this gets executed fine

https://github.com/jvoermans/Vibration_Logger/blob/f38884c6edd2fd734e08d48b29d071d47a1c405e/material_Jean/Due_SD_high_frequency_logger/src/main.cpp#L126

As it is visible on the dump in #36 , but then we never see

https://github.com/jvoermans/Vibration_Logger/blob/f38884c6edd2fd734e08d48b29d071d47a1c405e/material_Jean/Due_SD_high_frequency_logger/src/SonarManager.cpp#L61

And I really cannot understand why / how without the hypothesis of some memory corruption.

jerabaul29 commented 3 years ago

Any help / tips welcome :) .