Skip to content
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

Code correction needed? - bGeigie-nano.ino missing two braces at end of Main loop. #49

Open
dbgitter opened this issue Sep 25, 2018 · 11 comments

Comments

@dbgitter
Copy link

Reviewing the code revealed that first and second braces for Main loop were not matched (using ultraedit ctrl-B to match braces). Adding two right braces at the end of the loop allowed all braces to match.

@fakufaku
Copy link
Member

fakufaku commented Sep 25, 2018

Hi @dbgitter , thanks for pointing this out. This is very puzzling. Indeed, it seems that if two braces are missing it shouldn't compile at all.

The confusion with the braces matching might be due to the large number of #if/#endif statements throughout the code.
I think the outer brace of the (Main) loop (line 611) is matched with the opening brace of the for loop line 453. However, the matching closing brace of this for loop is in fact on line 477. Within this for loop, the following piece of code

 460 #if ENABLE_SOFTGPS
 461     while (gpsSerial.available())
 462     {
 463       char c = gpsSerial.read();
 464 #else
 465     while (Serial.available())
 466     {
 467       char c = Serial.read();
 468 #endif

adds two opening braces, but only one of these is used at compile time due to the pre-compiler options. This might be what throws off the parenthesis matching algorithm of the text editor.

@dbgitter
Copy link
Author

dbgitter commented Sep 25, 2018 via email

@robouden
Copy link
Contributor

robouden commented Sep 25, 2018 via email

@fakufaku
Copy link
Member

@dbgitter Sorry, I made a small terminology mistake, this is not a precompiler, but a preprocessor ("The" C preprocessor). It will parse the code and do some automatic modifications based on instructions starting with a # (#define, #include, etc). In the case of #if/#else statement, either set of instructions will be removed prior to compilation. At compile time, all braces are thus matching in the above code statement.

As Rob emphasized, were some parenthesis missing, the compiler should fail with some error. Was it the case for you ?

The above code fragment provides evidence for one extra opening brace, and I'm pretty sure that if we look close enough, we can find the second one.

@dbgitter
Copy link
Author

@robouden Attached is a snippet of the Main loop with closing comments added for all the conditional blocks. Could you please have a look and comment on any that are wrong? Thank you.
mainloopdbgitter.txt

@fakufaku
Copy link
Member

@dbgitter That makes the code much easier to read! Thanks for doing that. I checked the file you provided and it seemed correct to me.

@robouden
Copy link
Contributor

@dbgitter thanks. Yes, much nicer. Good job!!

@dbgitter
Copy link
Author

@robouden @fakufaku You are most welcome! My original intent was to try to make a small version of the code to load into an Arduino NANO that I could program with the Arduino IDE so I could troubleshoot my bgeigie nano kit #3106. The kit works and Safecast data was uploaded, but the display is intermittent. Do either of you know who might be able to help with signal tracing?

@robouden
Copy link
Contributor

robouden commented Sep 27, 2018 via email

@dbgitter
Copy link
Author

@robouden Yes that would be very helpful to have a smaller scale set of software that works with the Arduino IDE.
Thank you.

Dan

@robouden
Copy link
Contributor

robouden commented Oct 6, 2018

https://github.com/Safecast/bGeigieNanoKit/tree/ASCII
and also on my private repo for first generation board at:
https://github.com/robouden/bGiegeiNano_rob

rob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants