-
Notifications
You must be signed in to change notification settings - Fork 24
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
Debugging and unit testing Arduino (Part 3) issues & comments #5
Comments
to clarify the clash: when building the debug configuration, I am getting errors with a 'conflicting declaration of C function 'int rand()' int _EXFUN(rand, (_VOID)); which looks like is coming from the /usr/include/stdlib.h in the cygwin libraries. Phil. |
The problem you have with rand() is caused by the following info in platform.txt -Dsrandom=srand -Drandom=rand |
Why do you say "I tried to add a comment to Debugging and unit testing Arduino (Part 3) on you blog but I'm not a registered user." |
Jantje, I'll go through your suggestions today, hopefully it will all come together. I am grateful for your efforts, and I think if we can get some things working more easily others will come to appreciate them too. It's just that one can spend so much time on distractions in getting things working that the original task is lost in the many in/significant details with little to show if it doesn't work straight away. Most people just give up, and get frustrated, and generally don't or want to understand all the bits and pieces to start with. I've used Eclipse a lot with Java and it can be confusing at times. But I haven't used it much with c/c++. I've used Visual studio mostly for c/c++ and Intellij Ideas doesn't support c/c++ that well. So I'm hoping when I get the debugging and unit testing working nicely a couple of my friends here in Australia working with ESP8266/Arduino will start to use it too. I also have a Parrallella that I would like to understand better and it uses Eclipse as an IDE as well. Hence my previous question about understanding the Eclipse plugin framework that you have been through already...... Regards, Phil. |
It is all brand new so this is bleeding edge. However it should just work (within boundaries). |
Jantje, 1/ What actually controls where the project includes come from? and, When I installed windows MingW and Cygwin I put MingW on the path first: So what builder should I use with MinGW GCC? the options I get are: "Arduino sketch builder", "CDT Internal builder", "Gnu Make Builder", and"org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder". Then what should I set the Current builder to? Othertimes it won't find the iostream library from HardwareSerial.h, and other times it won't find srandom for WMath.cpp? if I try using cygwin the same builder options are available. I think maybe using the "Gnu Make Builder" would be right but maybe the "Arduino sketch builder" is needed? What did you have set in your setup, the other person wasn't so specific in what he used when he used MingW? Is there a way to see what the actual command lines that are generated in the compile and build process (like a verbose or something?) because I'm not so sure that the -Dsrandom=srand -Drandom=rand are effective in some cases? I looked in the debug makfile and .mk files but couldn't see any? Regards, |
I really think you should reread the blog post and start again sticking closely to it. About how you see the code: Have you turned "use active build configuration" on for "build configuration for the indexer" in windows->preferences->C/C++->indexer?
Can't you see that in your console view? If not I don't understand what you are asking for.
I fully agree. It is a fix I did for mingw which might not be needed for cygwin. It is probably better to fix this in the code based on defines.
Are you sure you have downloaded the latest version? #2 |
I have followed the blog post part 3 process closely. But my questions about includes and compiler/build have arisen where what I see when I perform the step differ slightly from the screen shots in the post. Where you suggest that things are happening "hidden and easy" may not be happening exactly as you expect. So I decided to do the whole process again and note where things are different and I noticed some things. I think that depending on the build configuration that is selected different things happen. For example, if one does a clean project only the build configuration selected is cleaned not the whole project. Also if a specific build is selected as active different things happen when a build all config is done. If a build selected config is done separately for each config the results are different too. I think that a very specific sequence of steps needs to be followed to get your required outcome and if the wrong build configuration is selected at the wrong time the results vary widely (missing includes iostream.h/pgmspace.h. for example the debug configuration created by the debug build configurations is different depending what configuration is selected with a wrong directory path and a missing .exe sometimes. All this is very confusing for a beginner not knowing what files in what configurations should have been created when? I'm going to try to follow step by step and make some specific observations of what isn't the same at specific process steps. It actually enough to send someone crazy......I will collect my observations and try to document it in my next post to be more specific. |
If I use build all I get the errors previously mentioned. BUT, If I build the configurations separately and don't use build all, each one builds individually. In the post part3 where you perform the "debug as"->debug configurations then Select C/C++ application and new. when I do it sometimes there is already a debugDemo Debug C/C++ application already created, other times not, but either way the path is Release\debugDemo.elf NOT Debug\debugDemo.elf because there is no .elf created in the Debug directory. Then when I press the debug button if it isn't greyed/out the debug session starts but ends with a Problem Occurred dialog 'Launching debugDemo Debug' has encountered a problem."Target request failed: Error creating process Release\debugDemo.elf, (error 193). |
I'm sure I have the latest jantje hardware as it has a an empty pgmspace.h file in it. I didn't select any toolchain in the debug configuration, but it still should the arduino toolchain/builder independent of whatever it does actually use based on the hardware selected..... |
Question: Do you use ino .files? What you should compare are the console outputs. There you see all the info being used by make. Without those I can only read your conclusions, I can not see what you get as a result.
http://iloapp.baeyens.it/blog/blog?ShowFile&image=1435787909.png states .exe. The path should be debug\debugDemo.exe. There is no way I know of to debug a .elf file on a pc.
If the compile doesn't find pgmspace.h file; the please provide the console output. Without that I can not help you out. If this one is missing it is the arduino eclipse plugin. |
Jantje, Yes I'm using .ino files. Here is some console output for If Release config is active and build all done 01:34:11 **** Build of configuration Debug for project debugDemo **** 01:34:12 Build Finished (took 547ms) It looks like its continuing to using the release hardware file for the debug configuration after its done the release build or something? You are right! it should be .exe, but for some reason this demoDebug debug configuration is being created sometimes with everything 'nearly' the same as what is needed, except the directory and the extension are different, creating confusion on my part. I just tried it again and edited that field to have the debug directory and the .exe extension, its also automatically now using the legacy create process launcher by default, which it wasn't doing before? I am also getting a Error in the Error Log. Error: java.io.IOEXception: Cannot run program "cygpath": Launching failed in org.eclipse.cdt.core, but I can run the Debug As demoDebug application and it stops at the Arduino.cpp file at the inVariant(); line. So I think I am making some progress....It maybe a problem with cygwin instead of MingW? I'm also getting a warning: /cygdrive/c/.......directories in jantje/avr_local and debugDemo directories No such file or directory showing up numerous times in the console , looks like another cygwin compatibility issue? while running the Debug As.... .gdbinit: No such file or directory. Warning: /cygdrive/c/Users/Phil/Arduino1.6.5-r5/hardware/arduino/avr/variants/standard: No such file or directory. Regards, Phil. |
using .ino files will make things harder because the standard build command does not generate/update the .ino.cpp file. It is clear that on your system, for whatever reason the build of debug is not done properly. As the build fails the .exe is not there so the debug doesn't start.
You did seem to get it into debugging. |
Jantje, Do you have a very basic unit test src file for this debugDemo that I could try out? I would like to get some unit tests working this is what attracted me to the your posts in the first place. Is it intended that a unit test configuration gets created, or something I noticed that "Debug or Unit test" dropdown option when setting up the debug configuration with the jantje hardware? Is there a separate Tests folder that gets created where test src files are placed? I want to create some Arduino libraries and would like to have it fully unit tested eventually. I've done a lot of unit testing with Java (junit, mocking etc), and would really value it here., same for my friends. Regards, Phil. |
Jantje, |
It is what the os finds first. As you have cygwin installed I guess you can do which g++ to find out what is used. My agenda is crowded for the moment so I won't have time to explain the unit testing, sorry. |
I'm back alive :-) |
Hi Jantje,
I tried to add a comment to Debugging and unit testing Arduino (Part 3) on you blog but I'm not a registered user.
I have been following parts 1-3 and have had some issues with getting it to work. I've numbered my problems, so its easier to respond to each:
1/ in your refactoring of the original BlinkWithoutDelay code you have lost the setup() routine of the pinMode(LED_BUILTIN, OUTPUT); and as a consequence the UNO led does not flash properly when downloaded to the board.
2/ You added a EDIT Note about setting up the gcc compiler in your path capable of making local executables.
3/ I loaded cygwin64 and set the windows path environment variable, but
4/ the debug build has issues knowing where to get specific headers from and it seems to cause a clash between the arduino, jantje hardware and the cygwin header/libraries.
5/ Or is MingW preferred to be used? ( I saw another person's comments as he was using MingW.)
6/ Maybe some more detail about how to configure each build configuration would be helpful.
7/ Also I assumed that the jantje hardware files needed to be installed in the private library/hardware path.
8/ When will the next installment part 4 be available to show the unit testing with googletest? I noticed that gtest is in your jantje hardware files.
9/ I noticed that eclipse-arduino IDE has the C/C++ unit testing support plugin component/view installed so I'm keen to see some examples of how to use it. I know you are quite busy.
10/ Maybe we could use this project as a test project to the IDE test team, once it works fully?
I'm sure everything will work it's just some of the steps aren't too obvious as to how to control the library usage between the windows compiler, Arduino and your library?
Regards, Phil.
[email protected]
The text was updated successfully, but these errors were encountered: