Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Local Files Override Library Files not being honored? (Read 397 times)
FrankP
Member
***
Offline



Posts: 130
Local Files Override Library Files not being honored?
Mar 25th, 2020 at 3:28pm
 
Hi,

I have a VS2019 project with 12C_Anything.h in the local folder, but the compiler keeps insisting on using the version in my Library folder.  I have another identical (with respect to includes) project with 12C_Anything.h in the local folder and this one compiles file, using (I think) the local version.  Both projects have 'deep search' and 'Local Files Override Library Files' checked.  I have included the verbose compile output for both.

What am I missing here?

TIA,

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10653
United Kingdom
Re: Local Files Override Library Files not being honored?
Reply #1 - Mar 25th, 2020 at 5:10pm
 
If the file included in the project/solution?

If it included in the sketch code?

What syntax used to include?

Is "vMicro>Compiler>Add Include Path for Project" enabled?
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #2 - Mar 25th, 2020 at 7:07pm
 
Tim,

Here's the 'local file honored' code:

Code (C++):
/*
    Name:       I2C_Master_Tut_Mod2.ino
    Created:	3/25/2020 8:54:55 AM
    Author:     FRANKNEWXPS15\Frank
*/


/*
    Name:       I2C_Master_Tutorial.ino
    Created:	3/23/2020 1:20:08 PM
    Author:     FRANKNEWXPS15\Frank
*/
/*
  I2C Master Demo
  i2c-master-demo.ino
  Demonstrate use of I2C bus
  Master sends character and gets reply from Slave
  DroneBot Workshop 2019
  https://dronebotworkshop.com
*/

// Include Arduino Wire library for I2C
#include <Wire.h>
#include "PrintEx.h"
#include "I2C_Anything.h"
// Define Slave I2C Address
#define SLAVE_ADDR 9
StreamEx mySerial = Serial; //added 03/18/18 for printf-style printing

// Define Slave answer size
#define ANSWERSIZE 5
const float myfloat = 3.14159;

void setup() {

    // Initialize I2C communications as Master
    Wire.begin();

    // Setup serial monitor
    Serial.begin(115200);
    Serial.println("I2C Master Demonstration");
}

void loop() {
    delay(50);
    //Serial.println("Write data to slave");
    mySerial.printf("Write data to slave\n");

    // Write a charatre to the Slave
    Wire.beginTransmission(SLAVE_ADDR);
    //Wire.write(0);
    I2C_writeAnything(myfloat);
    Wire.endTransmission();

    Serial.println("Receive data");

    // Read response from Slave
    // Read back 5 characters
    Wire.requestFrom(SLAVE_ADDR, ANSWERSIZE);

    // Add characters to string
    String response = "";
    while (Wire.available()) {
        char b = Wire.read();
        response += b;
    }

    // Print to Serial Monitor
    Serial.println(response);
} 



And the 'not honored' code

Code (C++):
/*
    Name:       I2C_Master_Tut_Mod1.ino
    Created:	3/24/2020 12:31:34 PM
    Author:     FRANKNEWXPS15\Frank

    Add
*/


/*
    Name:       I2C_Master_Tutorial.ino
    Created:	3/23/2020 1:20:08 PM
    Author:     FRANKNEWXPS15\Frank
*/
/*
  I2C Master Demo
  i2c-master-demo.ino
  Demonstrate use of I2C bus
  Master sends character and gets reply from Slave
  DroneBot Workshop 2019
  https://dronebotworkshop.com
*/

// Include Arduino Wire library for I2C
#include <Wire.h>
#include <PrintEx.h> //allows printf-style printout syntax
#include <I2C_Anything.h>
StreamEx mySerial = Serial; //added 03/18/18 for printf-style printing

// Define Slave I2C Address
#define SLAVE_ADDR 9

// Define Slave answer size
#define ANSWERSIZE 5

const float floatval = 3.14159;

void setup() {

    // Initialize I2C communications as Master
    Wire.begin();

    // Setup serial monitor
    Serial.begin(115200);
    mySerial.printf("I2C Master Demonstration\n");
}

void loop() {
    delay(50);
    mySerial.printf("Write data to slave\n");

    // Write a charatre to the Slave
    Wire.beginTransmission(SLAVE_ADDR);
    //Wire.write(0);
    //I2C_writeAnything(floatval);
    Wire.endTransmission();

    mySerial.printf("Receive data\n");

    // Read response from Slave
    // Read back 5 characters
    Wire.requestFrom(SLAVE_ADDR, ANSWERSIZE);

    // Add characters to string
    String response = "";
    while (Wire.available()) {
        char b = Wire.read();
        response += b;
    }

    // Print to Serial Monitor
    Serial.println(response);
} 



The 'I2C_Anything.h' file is in the local directory in both cases, and it is NOT included as a header file resource in either VS project.

In both cases, 'Local Files Override...' is checked in VMicro->Compile options.

Hope this helps.

Frank


Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10653
United Kingdom
Re: Local Files Override Library Files not being honored?
Reply #3 - Mar 25th, 2020 at 11:06pm
 
The "local files override ..."  only applies to files that are compiled (.cpp, .c, .S) to object files.

Header files are discovered based on include paths when needed by the compiler.

The compiler output will show the include paths.

It is important to ensure files are included correctly in the vs project.
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #4 - Mar 26th, 2020 at 2:07am
 
Tim,

I didn't understand about headers vs .cpp files, so thanks.  However, that doesn't explain why the local file IS used in one VS project, and not in the other, since it isn't included as a resource in either project.

And, IIRC, I actually DID include the the I2C_Anything.h file in the VS project at one point, but it didn't change the outcome.

Hmm, maybe I have to include that header file in the SOURCE FILE section rather than the header file section?

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10653
United Kingdom
Re: Local Files Override Library Files not being honored?
Reply #5 - Mar 26th, 2020 at 2:28pm
 
I think you should click the little "show all files" button above the solution explorer so that you can see where your files really are.

If you are looking at the view that shows "header files" and "source files" seperately that is "virtual mode" which just presents the files in a grouping.

An arduino project has only the main project folder and \src folder or unlimited levels of folders below the \src. There will not be "Source Files" or "Headers Files" folders.

The F4 properties on a file or folder will also show you clearly if a virtual filtered folder of (*.h or *.cpp) files or a physical location.

Visual Micro does not need to and should not take into account the virtual mode display except that it does clearly show which files are included in the project.

The files that are included in a project can be important for intellisense and also in some cases for compilation. It's true that generally for arduino everything in the allowed folders is copied to temp folder and then compiled but the vs project system does give opportunity to include/exclude certain files from te build. It is an area of difference between what VS users would expect and what Arduino users expect.

If I recall correctly, Visual Micro has settings to control this but generally files in the project folder are copied to the build folder and compiled. Files in \src and below are only copied and compiled if included in the project.

It is generally a good idea to include in the project what is considered to be all of the poject code. Regardess of vMicro source control and intellisense would require it.
Back to top
« Last Edit: Mar 26th, 2020 at 2:35pm by Visual Micro »  
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #6 - Mar 26th, 2020 at 5:40pm
 
I used the 'Show all Files' option to display all the files for both the 'Mod1' and 'Mod2' projects. As the attached images show, the two project setups are identical (at least as far as files, I guess), and both locally held I2C_Anything.h files are identical.

So, then I renamed the VMBuilds folder for Mod1 (so that it would be regenerated from scratch) and tried to compile Mod1 again - same errors as before, but now I see that there is a SBWire folder in the VMbuilds folder for Mod1 that isn't in Mod2.  So it appears that somehow the Mod1 project is still insisting on using the version of I2C_Anything that references SBWire, and this is what is causing the compile for Mod1 to fail.

Any ideas what is causing this?

Frank

Back to top
 

 
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #7 - Mar 26th, 2020 at 6:02pm
 
Tim,

BTW, I was also able to confirm that both the Mod1 & Mod2 projects are actually compiling their local copies of I2C_Anything.h. To do this I made an obviously non-compiling edit to each project's local version of  I2C_Anything.h and confirmed that subsequent compiles failed at the edit point.  Then I removed the edit error and both projects now compiled past the point of the error.  However, the Mod2 project compiles to completion (as before) while the Mod1 project compile still dies with bunches of SBWire-generated errors.

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10653
United Kingdom
Re: Local Files Override Library Files not being honored?
Reply #8 - Mar 26th, 2020 at 8:39pm
 
click build > clean solution on both. then build both and capture the output with the settings in yellow above enabled. also submit your code because it is not clear what code you have were. I suggest also deleting the __vm folder below each project then reopening the project (s)
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #9 - Mar 27th, 2020 at 3:18pm
 
Tim,

Attached.  Thank you for looking at this, and please let me know if there is anything else you need.  I'm sure its just something stupid that I'm doing, but I sure can't figure it out! Wink.

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10653
United Kingdom
Re: Local Files Override Library Files not being honored?
Reply #10 - Mar 27th, 2020 at 4:18pm
 
please zip the entire project folder with all sources. just the .ino file doesn't really show what we need
Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #11 - Mar 27th, 2020 at 6:09pm
 
Tim,

here you go Wink

Frank
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10653
United Kingdom
Re: Local Files Override Library Files not being honored?
Reply #12 - Mar 27th, 2020 at 6:20pm
 
In one source code you #include using <> in the other you use "".

Code 1 - #include <I2C_Anything.h>
Code (C++):
#include <Wire.h>
#include <PrintEx.h> //allows printf-style printout syntax
#include <I2C_Anything.h>
StreamEx mySerial = Serial; //added 03/18/18 for printf-style printing

// Define Slave I2C Address
#define SLAVE_ADDR 9

// Define Slave answer size
#define ANSWERSIZE 5

const float floatval = 3.14159;

void setup() {

    // Initialize I2C communications as Master
    Wire.begin();

    // Setup serial monitor
    Serial.begin(115200);
    mySerial.printf("I2C Master Demonstration\n");
}

void loop() {
    delay(50);
    mySerial.printf("Write data to slave\n");

    // Write a charatre to the Slave
    Wire.beginTransmission(SLAVE_ADDR);
    //Wire.write(0);
    //I2C_writeAnything(floatval);
    Wire.endTransmission();

    mySerial.printf("Receive data\n");

    // Read response from Slave
    // Read back 5 characters
    Wire.requestFrom(SLAVE_ADDR, ANSWERSIZE);

    // Add characters to string
    String response = "";
    while (Wire.available()) {
        char b = Wire.read();
        response += b;
    }

    // Print to Serial Monitor
    Serial.println(response);
} 



Code 2 - #include "I2C_Anything.h"
Code (C++):
#include <Wire.h>
#include "PrintEx.h"
#include "I2C_Anything.h"
// Define Slave I2C Address
#define SLAVE_ADDR 9
StreamEx mySerial = Serial; //added 03/18/18 for printf-style printing

// Define Slave answer size
#define ANSWERSIZE 5
const float sendval = 3.14159f;
float rcvval = 0;

void setup() {

    // Initialize I2C communications as Master
    Wire.begin();

    // Setup serial monitor
    Serial.begin(115200);
    Serial.println("I2C Master Demonstration");
}

void loop() {
    delay(50);
    //Serial.println("Write data to slave");
    mySerial.printf("Sent %3.5f: ",sendval);

    // Write a charatre to the Slave
    Wire.beginTransmission(SLAVE_ADDR);
    //Wire.write(0);
    I2C_writeAnything(sendval);
    Wire.endTransmission();

      //03/26/2020 gfp rev to retrieve float value
    Wire.requestFrom(SLAVE_ADDR, sizeof(float));
    I2C_readAnything(rcvval);
    mySerial.printf("Received %4.1f\n",rcvval);
} 

Back to top
 
WWW  
IP Logged
 
FrankP
Member
***
Offline



Posts: 130
Re: Local Files Override Library Files not being honored?
Reply #13 - Mar 27th, 2020 at 7:13pm
 
Code 1 - #include <I2C_Anything.h>
Code 2 - #include "I2C_Anything.h"

Well, that was embarrassing!

That did he trick.  Thanks for taking the time from your full-time job of supporting Visual Micro to teach me basic programming Wink

Frank
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print