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) Local Files Override Library Files not being honored? (Read 2735 times)
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Local Files Override Library Files not being honored?
Mar 25th, 2020 at 3:28pm
Print Post  
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
  

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: Local Files Override Library Files not being honored?
Reply #1 - Mar 25th, 2020 at 5:10pm
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #2 - Mar 25th, 2020 at 7:07pm
Print Post  
Tim,

Here's the 'local file honored' code:

Code (C++)
Select All
/*
    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++)
Select All
/*
    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
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Local Files Override Library Files not being honored?
Reply #3 - Mar 25th, 2020 at 11:06pm
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #4 - Mar 26th, 2020 at 2:07am
Print Post  
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
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Local Files Override Library Files not being honored?
Reply #5 - Mar 26th, 2020 at 2:28pm
Print Post  
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.
« Last Edit: Mar 26th, 2020 at 2:35pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #6 - Mar 26th, 2020 at 5:40pm
Print Post  
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

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #7 - Mar 26th, 2020 at 6:02pm
Print Post  
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
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Local Files Override Library Files not being honored?
Reply #8 - Mar 26th, 2020 at 8:39pm
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #9 - Mar 27th, 2020 at 3:18pm
Print Post  
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
  

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: Local Files Override Library Files not being honored?
Reply #10 - Mar 27th, 2020 at 4:18pm
Print Post  
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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #11 - Mar 27th, 2020 at 6:09pm
Print Post  
Tim,

here you go Wink

Frank
  

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: Local Files Override Library Files not being honored?
Reply #12 - Mar 27th, 2020 at 6:20pm
Print Post  
In one source code you #include using <> in the other you use "".

Code 1 - #include <I2C_Anything.h>
Code (C++)
Select All
#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++)
Select All
#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
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Local Files Override Library Files not being honored?
Reply #13 - Mar 27th, 2020 at 7:13pm
Print Post  
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 TopicPrint