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) Compiler has mind of its own (Read 6820 times)
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Compiler has mind of its own
Feb 28th, 2017 at 4:22am
Print Post  
In my program I can (or should be able to) change the slave the master works with by commenting in or out calls to the function 'purchase' with different slave addresses as parameter:
Code (C++)
Select All
//	purchase(SLAVE_1);
purchase(SLAVE_2);
//purchase(SLAVE_3);  // not useable at the moment
//purchase(SLAVE_4);  // not useable at the moment
//purchase(SLAVE_5);  // not useable at the moment
 


In this case the master is calling up SLAVE_2 at line masterBackChat::400.  In the function purchase the slave actually being called is checked by
Code (C++)
Select All
			if (memcmp(slave, SLAVE_1, 5) == 0)
			{
			  slave1purchased = true;
       if (debug) Serial.println("Purchasing SLAVE_1");
			}
      
			if (memcmp(slave, SLAVE_2, 5) == 0)
			{
			  slave2purchased = true;
       if (debug) Serial.println("Purchasing SLAVE_2");
			}
 


at line masterBackChat::720.

My problem is that on several occasions building and running the program calling SLAVE_2 results in it persisting in calling SLAVE_1 still.  This occurs in VS and also in the Arduino IDE.  It is sporadic, and currently it has corrected itself.

Has anyone ever heard of this trick?
If so, what did you find caused it?

Thanks


  

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


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler has mind of its own
Reply #1 - Feb 28th, 2017 at 6:31am
Print Post  
I am sorry. This forum is to support visual micro configuration and operation.

For code discussion and assistance please visit Arduino.cc or stack overflow.

This forum is too small to help people with code. Visual micro is also mainly free so it's not possible to help people with code. Arduino is a for profit company and hand the resources to help you.


Thanks
  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: Compiler has mind of its own
Reply #2 - Feb 28th, 2017 at 6:33am
Print Post  
Okay.  Fair enough.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler has mind of its own
Reply #3 - Feb 28th, 2017 at 6:34am
Print Post  
Thanks and sorry
  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: Compiler has mind of its own
Reply #4 - Feb 28th, 2017 at 6:40am
Print Post  
It's actually a compiler problem - not code.
https://1drv.ms/i/s!ArMxdUYEh9fKgWlbJ1NxnNIxnmqq

I can't see how you can build something which specifically uses one parameter and it compiles with another.  When I was a kid compilers did not work like that!

The call to 'purchase' is at masterBackChat::408 and the debug output line is at masterBackChat::572.

I have attached the image in case the inclusion does not work.
  

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


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler has mind of its own
Reply #5 - Feb 28th, 2017 at 11:44am
Print Post  
Your image doesn't give any useful information. This is a reason why we need to use arduino.cc

Maybe the source code would help.

If Purchasing  SALVE_2 message is appearing in a different order then you expect to see in the serial monitor then it will only be of value to see what code produces the message.

Maybe the message is only printed when a slave returns a result, in that case we wouldn't expect any specific order.

  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: Compiler has mind of its own
Reply #6 - Feb 28th, 2017 at 11:46pm
Print Post  
Tim@Visual Micro wrote on Feb 28th, 2017 at 11:44am:
Your image doesn't give any useful information.
 

Sorry.  The size of that got a bit out of hand.  Hope this is better.
https://1drv.ms/i/s!ArMxdUYEh9fKgWlbJ1NxnNIxnmqq

line 399 on the left is the call to the function 'purchase' with the parameter SLAVE_1.  On the right you see the COM6 printout showing that the parameter actually compiled was SLAVE_2 !  As I said, in the good old days compilers didn't do that.  To make matters worse, it's sporadic.  Sometimes it happens, sometimes it doesn't.  Huh

Tim@Visual Micro wrote on Feb 28th, 2017 at 11:44am:
Maybe the source code would help.


The source code was attached to the original post as 'backchat.zip'.

Tim@Visual Micro wrote on Feb 28th, 2017 at 11:44am:
If Purchasing  SALVE_2 message is appearing in a different order then you expect to see in the serial monitor then it will only be of value to see what code produces the message.


The relevant code lines are listed in my last post.

Thanks for showing an interest.  I have never seen this sort of behaviour when compiling/building a program.



  

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


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler has mind of its own
Reply #7 - Feb 28th, 2017 at 11:54pm
Print Post  
The compiler is gcc, it doesn't get things wrong. There is some other issue somewhere.

Questions

1)

Do you have two projects with the same name?

2)

Are you sure COM 6 is connected to the unit programmed with SLAVE_1

3)

Are you sure you got a successful upload and not a compiler error

4)

Switch off debug by changing the toolbar from Debug to Release. Then the serial, the the build output won't disappear so we can be sure of good build and upload.

4)

You should switch on vmicro>compiler>verbose and >"show build properties" if you haven't already. then build and upload, then copy the output into a .txt and post here or email to info[at]visualmicro.com

Thanks
  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: Compiler has mind of its own
Reply #8 - Mar 1st, 2017 at 12:26am
Print Post  
Tim@Visual Micro wrote on Feb 28th, 2017 at 11:54pm:
The compiler is gcc, it doesn't get things wrong. There is some other issue somewhere.


I agree with you.  I have been using GCC as a compiler since before we had IDEs.  It's a rock!

Tim@Visual Micro wrote on Feb 28th, 2017 at 11:54pm:
Do you have two projects with the same name?


No

Tim@Visual Micro wrote on Feb 28th, 2017 at 11:54pm:
Are you sure COM 6 is connected to the unit programmed with SLAVE_1


I image was programming the master code and, yes, it is connected to COM6 because the COM6 printout shows what it is trying to do (and the lights on the Adruino UNO flash when it is uploading).


Tim@Visual Micro wrote on Feb 28th, 2017 at 11:54pm:
Are you sure you got a successful upload and not a compiler error


Yes because at least it tried to work and that showed up on the COM6 printout.

Tim@Visual Micro wrote on Feb 28th, 2017 at 11:54pm:
Switch off debug by changing the toolbar from Debug to Release. Then the serial, the the build output won't disappear so we can be sure of good build and upload.


Done

Tim@Visual Micro wrote on Feb 28th, 2017 at 11:54pm:
You should switch on vmicro>compiler>verbose and >"show build properties" if you haven't already. then build and upload, then copy the output into a .txt and post here or email to info[at]visualmicro.com


See attached.  I'll have to do another post to send you the current code.   

I agree that there is something other than the compiler doing this, and my chief suspect is the addresses used.  I can get my master to work with SLAVE_1 but and (sometimes) with SLAVE_2, but trying to get it to work with both creates chaos.  That is why the current code has optional sets of addresses (I comment them in and out as I try things).
  

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


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: Compiler has mind of its own
Reply #9 - Mar 1st, 2017 at 12:27am
Print Post  
Here's the current code.
  

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


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler has mind of its own
Reply #10 - Mar 1st, 2017 at 12:59am
Print Post  
By the way, what do you press to build ad upload?

If there isn't any confusion over which project you are building and upload then I would be looking at memcmp as the culprit. But as I have said arduino.cc are the best people to help with code.

Code
Select All
const uint8_t SLAVE_0[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
const uint8_t SLAVE_1[] = { 0xBB, 0xBB, 0xBB, 0xBB, 0xBB };
const uint8_t SLAVE_2[] = { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC };

void setup()
{
   purchase(SLAVE_2);
}

void purchase(const uint8_t* slave)
{
  if (memcmp(slave, SLAVE_1, 5))
		Serial.println("Purchasing SLAVE_1");

  if (memcmp(slave, SLAVE_2, 5))
		Serial.println("Purchasing SLAVE_2");
} 



other things to look for at times like this. 

make sure you haven't got any stray code files in the project folder that are not included in the project. If you have then remove them or include them in the visual studio project.

look in the build folder that is shown in the verbose build output and see what actual code has been compiled in the project_name.cpp. The project_name.cpp in the build folder should contain a copy of the code from the .ino file(s) of the project. That will be the last code that was compiled. If that matches your expected code then the issue is code.
« Last Edit: Mar 1st, 2017 at 1:12am by Tim@Visual Micro »  
Back to top
IP Logged
 
rick_duley
Junior Member
**
Offline


Posts: 49
Location: Western Australia
Joined: Jan 8th, 2017
Re: Compiler has mind of its own
Reply #11 - Mar 1st, 2017 at 5:50am
Print Post  
Tim@Visual Micro wrote on Mar 1st, 2017 at 12:59am:
By the way, what do you press to build ad upload?


https://1drv.ms/i/s!ArMxdUYEh9fKgWzX0jcZZtQk5m-m


Tim@Visual Micro wrote on Mar 1st, 2017 at 12:59am:
make sure you haven't got any stray code files in the project folder that are not included in the project. If you have then remove them or include them in the visual studio project.


Is any of these a stray code file ?
https://1drv.ms/i/s!ArMxdUYEh9fKgW36N0db-cIUjPhr

Tim@Visual Micro wrote on Mar 1st, 2017 at 12:59am:
look in the build folder that is shown in the verbose build output and see what actual code has been compiled in the project_name.cpp.


I turned Agent Ransack loose looking for CPP files in the project files and this is all he found
https://1drv.ms/i/s!ArMxdUYEh9fKgW7r3j1f-60KQ61E
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12204
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler has mind of its own
Reply #12 - Mar 1st, 2017 at 8:34am
Print Post  
Thanks. I will leave you to study your code. Maybe use a simpler check to compare which slave is current
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint