OK my background is procedural code and I've no understanding of oop.
I'd be very grateful for some simple advice on preparing my code to post a question.
As its large I've posted it on my own website; its not linked in to the NAV as yet but the sketch is here
http://www.skillbank.co.uk/arduino/netmonitor_FINAL.ino
Its rather trivial, a state machine using globals throughout and not passing parameters to/from functions.
Basically I'd like advice on what to move to a header file? Just the global declarations? Or function prototypes? Or the functions?
Please, I know there are guides but I need a concrete example to help me make sense of this.
Also if you can advise me on posting large blocks of code that would be great. I found this but its no longer relevant.
https://forum.arduino.cc/index.php?topic=3742.0
I'd be very grateful for some simple advice on preparing my code to post a question.
Read this before posting a programming question
How far did you look, it is a sticky post at the top of the forum page
Thanks Helibob, for your quick respone! yes I read that, perhaps you could be a bit more specific?
"With coding problems, if possible post a "minimal" sketch that demonstrates the problem - not hundreds of lines of code."
I'm not sure how I could do that. The code exceeds the 9000 chars. Its the structure I really need help with and that would not be visible if I put snippets. Can I post folded code?
Is there somewhere I should upload the code?
If code exceeds 9000 characters, attach it. If multiple files, zip it and attach; the zip should have the name of the main ino file as that makes it easier to extract and have the correct structure (double clicking the ino will not result in Arduino saying that it needs to be in a directory with that name).
Is there somewhere I should upload the code?
Here, of course
If you read the advice in the link I gave you will have seen that if your code exceeds 9000 characters and you really can't create a minimal example then you can attach the file or files to a post, preferably not a zip file which many members will not download and open
Thanks Helibob, its a learning curve - now I know how to do that.
netmonitor_FINAL.ino (12.8 KB)
johnerrington:
Its rather trivial, a state machine using globals throughout and not passing parameters to/from functions.
I haven't looked at your code yet (and probably won't if I have to do to some random web site to view it). But, what you describe above is, generally speaking, poor programming practice.
Regarding organization of .h (and .cpp) files, see My Reply #3 Here.
Also, I too will not download a .zip file of unknown provenance. And, it's too much trouble to download multiple files, create an Arduino project / directory, etc just to view the structure of your code. My advise would be to create a (free) GitHub account and post it there.
Finally, chances are, you'll get more people to look at your code if you post an MRE. This is a small, concise example that precisely recreates the problem you're trying to solve. It rarely involves your entire project. Doing this frees others from having to wade through hundreds or thousands of lines of unrelated, messing code just to get to the issue at hand.
Thanks GFVALVO its not a zip of multiple files, its a single ino file and attached to my post above.
I'll look into GitHub but from bits I've seen so far it doesnt seem very active.
Useful links I'll need to read around them.
johnerrington:
I'll look into GitHub but from bits I've seen so far it doesnt seem very active.
I can't imagine how or where you got that impression. GitHub is the repository of choice for just about all code in the Arduino ecosystem. It also holds a huge amount of non-Arduino code.
Following a lot of responses to my question that were generally less than helpful, I found these resources that will help me learn.
https://www.arduino.cc/en/Hacking/libraryTutorial
I'm posting these in the hope this will help others in my situation.