COAST-Lab / Open-Water-Level

An open-source, low-cost, DIY ultrasonic water level sensor
MIT License
9 stars 3 forks source link

Switch from Serial.print to Log.info #33

Closed SUPScientist closed 1 month ago

SUPScientist commented 4 months ago

Problem

Firmware currently uses Serial.print() type statements frequently.

Solution

SUPScientist commented 2 months ago

@gracelower, this would be a great next issue for you to tackle (after chassis updates/during printing).

Recommended approach:

gracelower commented 2 months ago

@SUPScientist Sounds good - I'll get to this ASAP!

gracelower commented 1 month ago

Solution for errors in Line 255:

Serial print_Log info_Issue

Serial print_Log info_PCsolution

gracelower commented 1 month ago

Updated code with Log.info statements and adjusted Getting_Started instructions (in Firmware folder) to reflect these changes https://github.com/COAST-Lab/Open-Water-Level/commit/c8fbb673e3e3e8fefc8327921a47488ecf37b049

gracelower commented 1 month ago
gracelower commented 1 month ago

New proposal: combination of Serial.print + Log.info statements

A WORK-IN-PROGRESS file was created in the Firmware > SLRMaxbotix... folder to house code that combines these two statement types. Resulting zeros in the data are only for battery voltage and battery level (due to the device being powered by a computer, not battery).

Please note that part of this proposal was generated in part by AI.

SUPScientist commented 1 month ago

Everything sounds like it's on the right trajectory till this last comment that starts "New proposal." Not sure I follow. The goal is to switch completely away from Serial.print() type statements and use only Log.info() type statements, so I don't think the combo idea is what we want.

I think the issue is that I disagree with the last bullet of your AI-generated proposal

"If you want to ensure that a message is seen both locally and remotely, use both Serial.print and Log.info for the same message"

Log.info() will print to screen in my understanding.

gracelower commented 1 month ago

I had initially switched all Serial.print statements to Log.info statements to eliminate all instances of Serial.print as you mentioned. The code compiled and flashed successfully, but I ran into a problem where no results were being returned at all to the serial monitor, instead simply showing the serial monitor opening and closing. When I added some of the Serial.print statements back into the code, I was able to see data in the serial monitor once more.

I will do some more research on this and refer back to the Particle Community forum for ways to navigate this issue without reinstating any Serial.print statements. Thanks!

gracelower commented 1 month ago

Added SerialLogHandler logHandler; to Global objects list before void_setup(void) {

7_BAdaFull

Changes staged; will commit & submit pull request once current pull request is merged.

gracelower commented 1 month ago

Pull request https://github.com/COAST-Lab/Open-Water-Level/pull/45 addresses this issue

SUPScientist commented 1 month ago

Agreed. https://github.com/COAST-Lab/Open-Water-Level/pull/45 solves the issue. Closing. Nice work!