Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) How to use Arduino libraries and how to use VS shared projects? (Read 48268 times)
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
How to use Arduino libraries and how to use VS shared projects?
Mar 2nd, 2018 at 3:11am
Print Post  
Hi

I am sorry to sound arrogant but my intentions are good. I would honestly consider doing these if Visual Micro was my own company and I am not writing this as a user point of view.


Business Related:
1) I would treat Visual Micro as a brand. Based on current website it is very unclear if this is Arduino extension or actually a stand alone extension. When you read the cool features, all of the sudden this is not anything close to what Arduino is considering the philosophy behind products/brands. 
I can even see the day that Visual Micro has an option to "export" a normal C++ project as an Arduino sketch/library and I do see that things are going towards that direction even if it was not your intention.
The reason I think Visual Micro should become a brand is mainly because this is nothing a typical Arduino user should come across. Arduino IDE made things simple so anyone can use it with an easy learning curve, where as visual micro running on Visual Studio is totally different. The learning curve for Visual Studio is unbearable for typical Arduino user, unless that user is going to be an Engineer/Programmer or an employee who has to develop for Arduino or the compatible boards.
I think any attempt to make this Arduino will fail because the philosophy is very different behind the 2 products and I think Visual Micro should be a brand for its niche market.

2) I would focus fully on my niche market.
Knowing the niche market is very important, I do not have access to your data but I think I can predict what your current paid customers are:
i) hobbyist who use Arduino like boards. This group should have few different sub categories:
a) Users who have seen outside arduino IDE and look for a better IDE.
b) Users who just want to try new things and mainly for learning, but they fall in love with visual micro and end up paying for it.
c) Users who are familiar with VS (or other proper IDEs) and when they started looking at Arduino they came across 
ii) Companies which develop for Arduino like boards.
iii) Using this as an educational tool. (I do not think this has been done officially but I do see the potential and I am not sure if it has happened already)

I cannot think of any other possible case. But Also I do not think this is a small niche. I just think that knowing the niche, Visual Micro must focus everything towards these customers and everything should be done for them. For instance the current documentation is not coherent. I know you have spent a lot of time for it but it lacks in consistency. 
For the documentation I would create 2 different sets of documentations. First I would create documentation for i)a) and i)c and ii. then I would focus on documentation for i)b and iii. The reason is that the first group are easier to write for and they may help significantly as the online community. All they need to know is how to actually develop code in Visual Studio environment. This group know what .cpp and .h file is. They know what .ino is and they understand where library directory is. 
But there is one thing they do not know and it does not seem apparent. How do I combine my version control with Arduino like file structure and Visual Micro. To give you on neat example, If I am developing libraries but they are not tested yet how can I make sure I can use the debugging features in them? If I make them arduino library (in library directory) then debugging won't work. Should I use Arduino Shared Project or Arduino Project? What would be the different if I add a Arduino Project as a reference to a solution or Arduino Shared Project? The answer to these question may exist but please read the later parts on why it is very hard to find it. So I would actually provide them a guide on how to develop with best practices. These best practices are very needed considering all the file inclusion magics by Arduino. Also, clearly explain what file structure is accepted in Arduino and how Visual Micro differ. For instance 'src' related stuff. A clear guide + best practices on how to take the under development project to become a library. (considering the file structure and so on). So I would say a guide on how to develop efficiently is very needed because you have the big picture better than anyone else.
Then you can focus on writing guides for i)b and iii. Remember you do not need to do Arduino's job but you can tell how to follow any Arduino tutorial by just teaching them how the basic stuff in Arduino IDE happens in Visual Micro and Visual Studio. Since most tutorials for arduino have very little to do with IDE, I think this should be relatively easy. 
You may also consider linking a visual studio guide that does not focus too much on things we do not need in Arduino level. I could not find one, because I do not have the big picture view that you have yet.
After making enough money you may consider making tutorials to teach Arduino + Visual Studio + Visual Micro all together for maybe engineering/computer science students in their first/second year of university. The quality of your guides can justify the price. If you can get unis on board then that would be fantastic.


Online Appearance:
1) Currently your website and Forum does not rank in Google search. I think you need to look at Search Engine Optimization (SEO). It is not hard but once you learn the basic every content you generate have higher chances of getting ranked. I do not know what platform you have used for the website otherwise I could help you choosing a plugin that helps with SEO. Also Google search console can help you with SEO.

2) your Forum is loads very slowly and the search function is not that great. I think if you just use stack overflow with tag for Visual Micro and just maintain things in there, there will be 2 benefits:
1) amazing SEO
2) amazing search features

3) Get SSL certification for your website. It cost less $150 but it helps your website rank higher in google search.


These are things I would to for Visual Micro and I think you guys are up to something very cool specially considering the debugging tool. I work with many students and we used to use Sublime and Stinno plugin. I was never convinced to purchase Sublime but I have been using your product for one week and I think it is very easy to sell this product if the right marketing plus what I said above is done. I am not as experienced on the marketing side so cannot provide any significant help. But I understand and see the value of visual micro.

BTW I am going to purchase your product very soon, as soon as I figure out a proper method to combine project + version control + visual studio tricks and then creating libraries out of it. I am sure I will find an easy way with my current level of understanding from everything but still I am digging for an easier integration. If you happen to have any answers written for the above issue, my purchase happen faster and I am sure I will not be the only one.

(Have to rush for a meeting now, sorry if there are typos and errors)
« Last Edit: Mar 5th, 2018 at 7:48pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #1 - Mar 2nd, 2018 at 2:26pm
Print Post  
Thank you very much for the post. It's not arrogant in any way shape or form.

You have hit many hot topics of great interest to me. Visual Micro is a big job in all respects and unfortunately there isn't a team behind it, just myself.

There is need for assistance in all the areas you have mentioned and I am actively looking someone with the right frame of mind to help and possibly become a part of the product.

To answer this question the question about libraries and shared projects.

To debug an arduino library is must be a shared library project but it can exist anywhere. So there is no reason why you can not use the main arduino library location and therefore develop and debug along side arduino ide usage.

One issue can be with permissions if you have installed arduino using the windows installer. In that case I suggest installing arduino using the .zip option into a folder such as "c:\Arduino\Arduino-Ide-Ver". I find this solution allows for multiple arduino ide versions and makes testing/moving between versions easier. This also avoids installer/overwrite issues if you have edited a core arduino library and subsequently upgrade the arduino ide.

Using the sketchbook/libraries folder is a good suggestion for your libs because arduino and visual micro will see them and they will be unaffected by arduino ide updates.

When you have a shared library project you can clone or create a copy in another folder. This would allow two different versions of the same lib to exist. for example:-

note: In this "versioned" example there is no place for the arduino ide to also work but it's an option to consider.
  myDocuments\arduino\libraries\myLibProjects\v1\MyLib
  myDocuments\arduino\libraries\myLibProjects\v2\MyLib


In theory each project is an isolated version controlled item which should be handled by standard visual studio version control tools. I have not had time to test or document a way to work with version control and you are right I have left that to users to discover for themselves.

With so many free users and users of different levels there is so much that could be done it is hard to see the wood for the trees. Therefore your post is especially interesting  Smiley

My email is info[at]visualmicro.com if you have time for discussion at any point.
« Last Edit: Mar 5th, 2018 at 7:48pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #2 - Mar 2nd, 2018 at 9:01pm
Print Post  
I am glad you take in the positive way.

I would like to show you my highest level of respect for keeping this project alive while being a one man army. I have been and pretty much am in similar condition right now and I can understand how tough it is. It takes huge amount of dedication.

I will surely drop you an email so we can keep in touch specially because if things go well on our side, we might be able to use (as paid customer) + promote your program in new communities and hopefully help you with paid customer. I will write more in the email about this.


please let me know if I understood shared projects correctly.
Your debugging feature was not working on libraries because libraries are pre-compiled. So you wanted a quick way for users to create a "local" version of the library so that the debugging feature can be applied in that local library and changes would not affect the main library (if files are created under the project). Also if the user just add files as existing files by creating the link he can technically change the library files straight away without the need to copy past anything (The only issue may be file permission but we already know the work around for that). If I understood this correctly, this is a very smart solution.


Regarding the version control side of the stuff, there is something to consider also. Should a user use something like SVN/Git to only take care of .h .cpp .ino files or should he/she use Visual Studio built in. There are both advantages and disadvantages if you consider each case and to be honest I am not familiar with Visual Studio's version control and I am not a version control guru yet. So I might have be very wrong on this one. But from my point of view I can see both advantages and disadvantages for each solution. I would love to break down the advantages and disadvantages but I think I still need more time to think about this.


I am still trying my very best to integrate everything together to make it as neat as possible and I definitely let you know the result to receive your suggestions and fine tune and maybe later we can make a guide out of it.

I would like to thank you once again for keeping this product alive and I hope it becomes a financially sustainable project so that you hard work over the years finally pay off.
« Last Edit: Mar 5th, 2018 at 7:48pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #3 - Mar 5th, 2018 at 3:25am
Print Post  
I spent the whole weekend on finding a nice solutions.

So let's restate the problem. There is a developer who works with big libraries and his libraries are dependent on each other and he wants the ability to test the libraries independent from higher level libraries. He also wants to use debugging tool and version control. The developer then wants to release his library in Arduino format for other people to use. I happen to be that guy.

1) The neatest solution considering all the Arduino compiling magic is:
1) Having debugging feature available in library folder. (not possible with visual micro currently)
2) The developer develop in library folder under Arduino, the includes all stay as the released version and he can easily add reference to other libraries.
3) He can add a .ino file in examples folder and test the library without a need for so much work and the example file remain with the project so the version control can track the project as well.
4) The libraries under development can easily include each other.
5) Nested file format is all good.
6) Version control is awesomely easy because you just need to take care of one folder and everything happens in that on folder.
7) You do not need to create multi copy of the project.

That all seems like a dream come true but visual micro does not support debugging in libraries. I cannot tell if there will be side effect because I could not try this.



The Solutions that do not work:
2) using shared project:
It won't work because the shared project cannot include each other as reference. Also the project cannot be compiled unless it is presented next to an ino file (through reference). Version control become terrible since the project cannot compile on its own and you end up with files all over the place.


3) Using shared Library
Same problem as #2

Note on shared projects: The shared project should be able to use each other once they are referenced in the same project based on what I read online, however I tested and it did not happen. I found only one person who had this problem on stackoverflow and he answered his own question after sometime and I left a comment to make sure I did not do anything wrong, so far no reply has been received. https://stackoverflow.com/questions/26391523/shared-projects-is-it-possible-to-r...


4) Editing the include directory of one sketch to include another sketch:
Long story short it did not work no matter how I played with it. It could not include files in the .ino file. .h and .cpp file could access the other sketches through relative path and if I remember correctly by adding the include directory. I tried so many tricks but the final conclusion was that there is no way to use another sketch's .h and.cpp in another sketch .ino file. Take note that you could use the .h and .cpp from another sketch in any sketch's .cpp and .h files if you provide correct relative path and turn of the deep search. Anyways this solution is not possible.


5) An ugly solution which works and after all is not that ugly
I am not sure how this works on other setups so I am going to provide as much as information as possible.
I am running on windows 7, Visual Studio 2017 Community installed, SVN Tortoise for windows, Visual Micro Extension  installed, VisualSVN extension installed. All works independently without an issue.

Some important stuff to consider:
1) The Arduino project cannot contain abc.ino, abc.cpp and abc.h all at the same time. The .h files and .cpp file should have a different name from .ino file.
2) In libraries used in Arduino, you can have a folder named src to keep all .h and .cpp files in a nested folder system without an issue.
3) In Arduino Sketch you can have .h and .cpp file under a folder named "src". Nested structure is supported too.


Now lets say you want to make a library and it is called "Apple". That means your library will have Apple.h and Apple.cpp. As stated the .ino should be something else. So, you can create a standard. I decided to add "_Testing" to my library name because it is easy to detect and kind of make sense with the rest of the file naming rules that I have set.

So in visual studio I create a new arduino sketch and call it "Apple_Testing". The IDE generates a Apple_Testing.ino and all files with Apple_Testing name to make it a project.
Next in solution explorer, click on "show all files". Then right click on the project and add a folder. Call the folder "src".
right click on folder and click on "Add empty arduino .cpp and .Header". Name it "Apple".
For some reasons Apple.h and Appler.cpp fall under project and not in the "src" folder. But it is not a big deal. Select them both and drag them inside "src". It will end up there nicely, a pop up message is generated but it is not important.

note: In "Apple_Testing.ino" you can include "Apple.h" by writing your include line like: 
Code (C++)
Select All
#include "src/Apple.h" 



You then develop your Apple Library till the point that it is Commit worthy in your version control.

Now you have everything sorted out for Apple library.

Now you need to use VisualSVN. I am not going to write about the detail of SVN because it would be better if you learn that from another place and continue read the rest of this. The VisualSVN is based on SVN Tortoise for windows so you do not need worry much if you are familiar with SVN Tortoise.

You go VisualSVN menu and click on "add Solution to Subversion". There are things you have to fill up but those are typical stuff with the process.

Now you project is under subversion. 
You have to commit to apply the changes you have made to bare folder in your repository. 


Now it is time to see how we can use this project elsewhere.
To make it easier to understand, our next library is called "Fruit". As you might have guessed we use "Apple" in "Fruit" library. So "Fruit"Library needs access to Apple.h.

Well, first we clear "Fruit" in the same way as we did "Apple".

So you make a sketch and Name it "Fruit_Testing". Then you add a folder and name it "src". Then you go ahead and create "Fruit.h" and "Fruit.cpp". You start working with "Fruit" and when you are ready to add "Apple.h"

In order to add "apple.h" make sure Solution Explorer is showing all files. Then left click on src and open VisualSVN menu and click on "Get Solution from SVN". The naming is important. You want to keep it as simple as possible and you want includes to be as close as possible to library includes later when these sketches become actual libraries. So it is best to call the folder where Solution is going to be loaded, "Apple". (Note: if you name the Folder Apple_Testing, it will not be a good idea. Because if you keep the deep search on, you will have Apple_testing. Although this only happens if you have nested structure inside Fruit src. In this example we do not but this solution is supposed to keep you safe from future problems (hopefully Cheesy) )

After doing that the IDE may open Apple solution. You can just save all and close the Apple solution and open "Fruit" Sketch.

Now from "Fruit.ino" you can include "Apple.h":
Code (C++)
Select All
#include "src/Apple/src/Apple.h"
 



From Fruit.h you can include "Apple.h"
Code (C++)
Select All
#include "Apple/src/apple.h 



You can now right the code you want and once your are done "Fruit" goes to SVN the same way as Apple.

To be continued....
« Last Edit: Mar 5th, 2018 at 7:49pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How I Think Visual Micro Can Make More Money
Reply #4 - Mar 5th, 2018 at 3:44am
Print Post  
Now one may argue that I have 2 Apple library folders, one under Apple_Testing and one under Fruit. You are right we have two versions but since they are both under subversion with no changes you can easily commit/update changes from either place. The only down side is that you have to keep the folders updated to latest version from SVN from all src sub folders to have the latest version. The other problem is that making very large project still need you to do couple of get solution from SVN for each level of the library. It may be time consuming but at least you have to do it only once when you start the project.

Also take note SVN does not include Apple in Fruit and this help with a lot of mess but the down side is that you have to recursively add to get a big project working or change the include path to avoid multiple copy of the same project. I am not sure which one is better at the moment but will let you know.

Also when I include files I use the following format to make it easier for the future.
Code (C++)
Select All
////////// Internal Includes //////////
Files that belong to this library
///////// END: Internal Includes //////////

////////// External Includes //////////
Files that supposed to be external libraries later in released version
////////// END: External Includes ////////// 



I guess this can save you a little bit of time.


Now, am I happy with this solution? In a way. I spend one week and played around and learned some stuff in visual studio news feature and also decided if I go atmel or visual studio, so in a way I am happy. If there is a neater way to do this, I would love to hear about it. 
If Debugging feature is added to libraries, this guide becomes 2 miles shorter in length  Cheesy But I think Tim is already doing so much work for Visual Micro so i will patiently wait and use the method above.

Now one thing can help with the above procedure and I tried to do it but it did not work. Tim this may be a 30 minutes problem for you, but I have spent 12 hours and so far no success and in a way I gave up because I cannot think of a way to solve the problem. I was trying to make a template for Visual Studio to create the .ino file and src folder with .h and .cpp files in it, but it did not work. I got to the point where pretty much things worked but the .h and .cpp file are always missing from the project but exist in solution explorer. It was my first time making Templates and I noticed you should have done a lot of work for current templates specially I found it very difficult to continuously extract and compress the template file. Maybe I was doing it wrong but it was tedious.

I am sorry for the very long posts but I hope I either help others or someone come and tell me there is an easier way,  Grin
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #5 - Mar 5th, 2018 at 1:57pm
Print Post  
Hi,

Thanks for all the info.

It is better that you make a new thread for each question and try to keep the thread to just asking the question.

It is useful to hear your experience because it gives some idea of what documents might be useful for more advanced team users. However much of what you are asking is now related to Visual Studio and whichever source code repository you have chosen.

Visual Micro leaves all ide file management and intellisense to Visual Studio. Visual Micro just gives visual studio search paths and defines for intellisense so your questions are mainly now for generic VS C++ projects. In that case you should ask your questions about source control on the source control plugin site.

The shared project system in VS is fairly new and maturing all the time so they will want to hear your feedback. Again wth shared projects, this is 100% standard visual studio. Visual Micro has no control over it.

There should not be any #include paths to change. Your code will reference libraries without path qualifier as per normal arduino code usage.
« Last Edit: Mar 5th, 2018 at 7:49pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #6 - Mar 5th, 2018 at 2:22pm
Print Post  
Hi

Actually this is not Visual Studio issue. The mess explained above is due to the following reasons:
#1) Arduino does not allow a sketch .ino file to include header from other directories.
#2) Debugging does not work in library sub folder. (this would be no issue if #1 did not exist)

In a typical Visual Studio case:
1) You can add any project from anywhere to the your solution as a reference and use the files.
2) Debugging works every where. (This does not really matter if any file can be included)

Also the issue with version control exist only due to Arduino treatment of .ino file as stated in #1. If debug was supported in library folder, this would not be an issue since library folder is treated normally by arduino. So by solving either #1 or #2, the problem would disappear.

Regarding the shared project you are correct about it being new, But it was actually supposed to solve a different problem.

Regarding the include path changes. It must be changed when the "sketch" is released as library. I actually suggest you try developing 2 libraries (1 depending on the other one) while having the debug feature working. Then make an .ino file for the higher level library which calls the lower level entities.
I am sure as soon as you start doing that, you will see the problem. The reason I spent 1 week for this is because so many things that you think they work as a typical Visual Studio projects, they actually do not. (this is not Visual micro file, this is Arduino file management related as stated in #1)

If you want I can do the example above with one Visual Studio project and one Visual Micro project to clarify the issue.
« Last Edit: Mar 5th, 2018 at 7:49pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #7 - Mar 5th, 2018 at 4:20pm
Print Post  
Okay thanks for the clarity. Lets discuss the following alone and leave all other discussion for now.

Let's understand your solution config to ensure you have your library debug setup correctly.

"Debugging does not work in library sub folder."

   Have you made the library a shared project?
   Have you added a reference to it in your master project?
   What is the folder structure of your library? libName/src?
   Does your library have a library.properties file in the root?

Thanks
« Last Edit: Mar 5th, 2018 at 7:47pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #8 - Mar 5th, 2018 at 6:34pm
Print Post  
Case 1:
Have you made the library a shared project? Yes. 
Have you added a reference to it in your master project? Yes
What is the folder structure of your library? libName/src? Presented in case 1
Does your library have a library.properties file in the root? yes
We call this Case 1 and the files are attached. Problem is Shared project library fruit cannot use Shared project lib apple.
The sketch project attached named "testingFruit" is located in my sketch directory. You may have to add the reference projects again because the path will be different in your machine.

When you build the project you get the following error:
(deep search off)
Severity      Code      Description      Project      File      Line      Suppression State
Error            13:20: error: 'getNApples' was not declared in this scope            C:\Users\alireza\source\repos\Fruit\src\Fruit.cpp      13      
(deep search On)
it complains about deep search.


Case 2:
Have you made the library a shared project? No. it is a library located in library of arduino.
Have you added a reference to it in your master project? Yes
What is the folder structure of your library? libName/src? yes
Does your library have a library.properties file in the root? yes

based on this http://www.visualmicro.com/forums/YaBB.pl?num=1455225504 Debugging cannot happen on this library, unless another shared project is made from the library. Then by doing that case 1 occurs.


PS: I was asleep (1:30 AM) but after seeing your replay, I came back to office to make sure what I said is correct about shared projects not being able to include each other. I was sure it won't work because I tried it extensively but wanted to make sure I am not wasting your time.
« Last Edit: Mar 5th, 2018 at 7:48pm by Tim@Visual Micro »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #9 - Mar 5th, 2018 at 7:43pm
Print Post  
Hi,

1) When you #include an Arduino library you should not specify the \src sub folder.
2) In Fruit.cpp you are missing #include "Apple.h"
3) Visual Micro rebuilds lib paths when projects open if required
4) Visual Studio shared project paths are stored as relative path not absolute.

//The .ino code should be this
//
#include "Apple.h"
#include "Fruit.h"

void setup()
{
     Serial.begin(9600);
     Serial.println( getNFruits() );
  /* add setup code here */

}

void loop()
{

  /* add main program code here */

}
« Last Edit: Mar 5th, 2018 at 7:48pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #10 - Mar 5th, 2018 at 11:32pm
Print Post  
Hi

1) When you #include an Arduino library you should not specify the \src sub folder.
There are too things to consider in here.
a) It is Visual Studio shared project, which is supposed to be an Arduino library, but we add it as an Arduino library and not Visual Studio shared project. (It is not bad but it is good to have it said explicitly)
b) Before you compile the code, intellisense finds everything to be wrong add draw a led line under it. (this could be the reason I have not noticed it in my personal time. Also when you want to include the shared library projects intellisense only suggest the "src/Apple.h" and does not suggest "Apple.h". I guess this is also another factor why I treated the shared project like Visual Studio entity). Again I do not think this is bad, It is just good to know.



2) In Fruit.cpp you are missing #include "Apple.h"
I tried adding "src/Apple.h" as suggested by intellisense  and it did not work. So I just removed it. Again the fact that intellisense before the first compile find everything wrong in a way convince me that this is the Visual Studio entity. Again nothing wrong with that, I guess it is all good.


3) Visual Micro rebuilds lib paths when projects open if required
Okay. I think that is an expected behavior.

4) Visual Studio shared project paths are stored as relative path not absolute.
thank you for information on that.



Actually the experience above makes so many things easier. The long post I have describe a (now) stupid workaround for achieving what is achieved above. I guess this is pretty solid, I just have to test with nested files in src to make sure we are all good and probably few debugging points so that I can start porting my code. Just one concern to think about is that in a big project you have to individually open and reference library projects (referencing can happen all at once). That means even if .ino is not accessing that library directly, you still need to add it to the project for the use of other libraries. But honestly I can live with that all fine.

After my initial test and code porting (to make sure I have everything sorted), I would love to pay back for your time and effort by a crash course video presentation or article but I let you decide for that. On top of that you have a new loyal customer. If anything needed just let me know.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #11 - Mar 6th, 2018 at 12:15pm
Print Post  
1)
Yes you should ignore the vs intellisense prompt for paths. It doesn't understand the simplicity of arduino. Arduino libraries are always specified without path.

2)
Yes, Visual Micro does perform additional include path resolution when you compile. However if you always #include all your required libraries in the master .ino file and save it then includes should also be correct without compile.

3)
I have moved your debug question to a new thread

http://www.visualmicro.com/forums/YaBB.pl?num=1520314146/0#0



Thanks for the effort. Twitter and small snippets on the web that point back to this site are always appreciated.
« Last Edit: Mar 6th, 2018 at 12:20pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #12 - Mar 7th, 2018 at 2:04am
Print Post  
Hi tim

Thank you for the reply and separating the threads. I am sure it will help the future user.

Just to clarify something, I am just looking for a way to develop libraries for Arduino using visual micro while the debugging is available in under development libraries and I wish for minimum file changes when releasing the under developed library as official Arduino library. (as stated in my first post)

I have done extensive testing over the last 15 days to find what seems to be the best solution to replace Arduino IDE. I did a lot of testing between Atmel Studio and Visual Studio to pick a winner. Then I have spent all my time figuring out a solution for the paragraph above. I have already found some interesting information regarding the debugging that I will post on the other thread since it is focused on debugging in shared projects. But in summary, you can debug a shared project but not a shared library for more info check the other thread.


Interesting stuff start here

One of my initial finding was that shared libraries cannot be debugged and that is why I just used shared projects instead because shared projects can be debugged (evidence provided in other thread). Now the interesting thing is that shared project cannot include each other under some circumstance. 
1) shared projects can include each other however a nested shared project cannot include other shared projects which are not nested.
2) Non-nested shared projects can access the shared project with nested files.

After receiving Tim's suggestion to use, shared libraries, I thought maybe I have done something wrong with the debugging stuff and probably I should spend more time on it. So I tested so many different file structure to make sure shared libraries are working without an issue. Today after realizing that shared libraries are new and debugging has not been tested on them, I realized that shared libraries for sure are not going to work in the current version. I had no doubt that my debugging is set correctly, because it was running on other parts of the code fine. So I was back at the problem and started to play around with shared project and accidentally discovered something interesting, I did not discover this initially because intelisense consider it as an error (I had so much respect for it back then  Grin) but it compiles just fine.
I have attached the files, if you want to test them.
The file structure is like this:
shared Project 1:
Red/Red/src/RedNested/RedNested.h
Red/Red/src/RedNested/RedNested.cpp

shared Project 2:
Blue/Blue/src/Blue.h
Blue/Blue/src/Blue.cpp
Blue/Blue/src/BlueNested/BlueNested.h
Blue/Blue/src/BlueNested/BlueNested.cpp

lastly a sketch in Arduino sketch folder named: ColorTesting.ino

In ColorTesting.ino includes are:
Code (C++)
Select All
#include "src\Blue.h"
#include "src\BlueNested\BlueNested.h"

#include "src\RedNested\RedNested.h" 



In RedNested.h I decided to add BlueNested.h, the include is:
Code (C++)
Select All
#include "../../src/BlueNested/BlueNested.h" 




In Blue.h I wanted to include RedNested.h, the include is:
Code (C++)
Select All
#include "../src/RedNested/RedNested.h" 




In BlueNested.h I add Blue.h, no brainier there but just to be clear the include goes as:
Code (C++)
Select All
#include "../Blue.h" 




It was initially very surprising because even after the compile the intelisense still consider it as an error. Good news is that the drop down suggestion still does its job correctly and suggest you the functions from shared project nested files.

I actually understood why this works eventually. Shared project content is copied to project location, I knew that but never looked at it from the correct point of view. Since the files are copied that means that the shared project are going to all sit next to each other. The only trick is that they are copied without the root folder. That is why only one of "../" is needed in include line and we do not mention the root folder name.

Now if I use this method to develop Arduino library the code can then be released as an Arduino library easily and only one change is needed, the include paths have to be modified. all of "../" should be removed for including external files, since they also become library in Arduino and they can be accessed without the "../"s

The debugging features are also working! You can check it out in the test project attached. I have already added breaking points and "complicated" (proof of concept) function calls.
Just make sure the Folders are not placed next to each other so that the relative paths do not produce the same result as our include lines. (even if they end up same, it should work. I have tested loosely)

I can now die in peace. Thank you Tim for the awesome work. Without you this would not be possible.


Edit1: Attached file were correct but the structure I typed was wrong and I added "src/" to them.
Edit2: Take note your shared project must have all its files in src, otherwise whatever explained above won't work.
Edit3: Includes can become simpler. I am currently porting my old code and once I am done with that, I can probably show you the most efficient way. Although with description above you should know it already.
« Last Edit: Mar 9th, 2018 at 8:32am by Ali »  
Back to top
 
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #13 - Mar 12th, 2018 at 12:21pm
Print Post  
It has taken me 20 days so far to port my stuff from sublime stino to VS VM and I think this is to much. After finding a solution to have both debug and development in place, I found a new issue with my solution. 
The references should be added with correct order or it won't work. This would not be an issue if shared project could have references (which they do not have by VS definition).
Anyways Tim please let me know what you suggest me to do:
a) carry on with my solution till issues get sorted and benefit from debug but manually taking care of references (I can add them using .vcxproj directly to make life easier)
b) Use shared library and wait for when debugging is enabled. (I won't get the debugging feature but hopefully other things work without an issue)
  
Back to top
 
IP Logged
 
Ali
Junior Member
**
Offline


Posts: 13
Joined: Mar 2nd, 2018
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #14 - Mar 23rd, 2018 at 12:46pm
Print Post  
31 days till I can confidently say that I have a grip on the tool chain. I think it should have not taken so long and I wish there was more feedback on my proposed solution. However it pays back very well, specially considering how awesome Visual Studio is. I have not used debugging much because I had to port 30,000 lines of code but the visual studio features make life easier on so many levels. I have ported my libraries and have 2~3 under development now and the it is considerably faster than using the Arduino IDE or Sublime + Stino. (I was not using any additional extension on my sublime and this could be the reason why Visual Studio seem to make a huge difference for me)
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to use Arduino libraries and how to use VS shared projects?
Reply #15 - May 21st, 2018 at 8:27pm
Print Post  
Hi,

Thanks for the update and sorry for the delay.

What did you have to do to port your libraries? Your code should work the same in both the arduino ide and visual micro??

update

I forgot to mention that you can put libraries in a local project under "[project]\_micro-api\libraries" folder. Then debug will probably work.

In the latest release there is a new project example in "file>new>project>c++>arduino project with local library"

There is also a new menu item called "Publish Library" (right click library.properties) which copies the library to sketchbook/libraries so it can be used in other projects and/or arduino ide.

These features might not be useful to you but though them worth a mention.

You need visual micro 1805.20.1 or above. A download link is currently in the Work in Progress thread

+ There is a new menu item "vMicro>Compiler>Local Files Override Library Files". This option allows you to copy any .cpp from a current library into the project. The compiler will then ignore the copy in the library folder and compile/link the 
version in the current project. 

+ This same system should also work for "Core" allowing you to, for example, temporarily copy main.cpp into your project then debug/override it.
« Last Edit: May 21st, 2018 at 8:30pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint