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
Arduino IDE works but VisualMicro does not (Read 321 times)
557Torino
Junior Member
**
Offline



Posts: 11
Arduino IDE works but VisualMicro does not
Aug 31st, 2019 at 6:48pm
 
The C++ code runs under the Arduino IDE (1.8.9), but execution appears stops on the line of code

Udp.begin(localPort);

when the code is run under Visual Studio 2017 with the VisualMicro add on.  I have tried reloading Visual Studio and VisualMicro with no change.  Any ideas?

Code (C++):
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xCA, 0x26 };
IPAddress lclIp(192, 168, 2, 173);
unsigned int localPort = 8889;

IPAddress rmtIp(192, 168, 2, 177);
unsigned int remotePort = 8888;

char message[] = "Yippy!";
EthernetUDP Udp;//new instance of UDP

void setup() {
	Serial.begin(9600);  // start the serial port for output and Ethernet/UDP:
	Serial.println("running ArduinoTestUPDSend");
	Ethernet.begin(mac, lclIp);
	Serial.println("running ArduinoTestUPDSend1");
	Udp.begin(localPort);
	Serial.print("My IP address: ");//make sure the IP address is correct
	Serial.println(Ethernet.localIP());
}

// the loop function runs over and over again forever
void loop() {
	for (int i = 0; i < sizeof(message); i++)//print message to make sure its correct
	{
		Serial.print(message[i]);
	}
	Serial.println("\r");
	Udp.beginPacket(rmtIp, remotePort);//start packet
	Udp.write(message);//sending message
	Udp.endPacket();//Close packet
	delay(100);
} 

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



Posts: 10395
United Kingdom
Re: Arduino IDE works but VisualMicro does not
Reply #1 - Aug 31st, 2019 at 7:12pm
 
Please follow the guide in the yellow box above so we can see your config.

Thanks
Back to top
 
WWW  
IP Logged
 
557Torino
Junior Member
**
Offline



Posts: 11
Re: Arduino IDE works but VisualMicro does not
Reply #2 - Sep 1st, 2019 at 3:18pm
 
See attached for the ouput from Micro Build.  I tried attaching the output from Micro build.  That file just produces a blank page when I click on it from my post.  I will reattach it again.
Back to top
« Last Edit: Sep 2nd, 2019 at 3:30am by 557Torino »  

 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino IDE works but VisualMicro does not
Reply #3 - Sep 2nd, 2019 at 11:34am
 
The file you emailed shows compile and upload OK

What is the problem you believe you are having?
Back to top
« Last Edit: Sep 2nd, 2019 at 11:34am by Visual Micro »  
WWW  
IP Logged
 
557Torino
Junior Member
**
Offline



Posts: 11
Re: Arduino IDE works but VisualMicro does not
Reply #4 - Sep 3rd, 2019 at 4:02pm
 
When the program is compiled by visual studio the line of code:

Udp.begin(localPort);

Stops execution, i.e.  Nothing happens after that.

When the same code is compiled and executed by the Arduino IDE, it works fine and sends the message across the ethernet connection to the receiving Arduino.

I am guessing it something to do with the way Visual Studio/MicroVisual are incorporating the ethernet/SPI libraries.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino IDE works but VisualMicro does not
Reply #5 - Sep 3rd, 2019 at 4:19pm
 
Oh yes sorry you did say. Well it should be easily resolved. I would certainly switch to Release mode for any testing so we have same as arduino ide.

We can see from the build output that these two libs are being used. If you compile in arduino ide with "file>preferences>compile verbose" then you will see where it is getting the libraries it is using.

I would also delete the following folder so that your AVR is the one installed with your arduino ide and not board manager which might be older.  Click recsan or restart the ide after making external config changes. C:/Users/miker/AppData/Local/arduino15/packages/arduino/

Code (C++):
Using library SPI version 1.0 in folder "file:///C:/Users/miker/AppData/Local/arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI"
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\SPI\SPI.cpp.o

Using library Ethernet version 1.1.2 in folder "file:///C:/Program%20Files/Arduino/arduino-1.8.5/libraries/Ethernet"
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\Dhcp.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\Dns.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\Ethernet.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\EthernetClient.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\EthernetServer.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\EthernetUdp.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\utility\socket.cpp.o
  Using previously compiled file: C:\Users\miker\AppData\Local\Temp\VMBuilds\Arduino_TestUDPSend\mega_atmega2560\Debug\Ethernet\utility\w5100.cpp.o 

Back to top
« Last Edit: Sep 3rd, 2019 at 4:21pm by Visual Micro »  
WWW  
IP Logged
 
557Torino
Junior Member
**
Offline



Posts: 11
Re: Arduino IDE works but VisualMicro does not
Reply #6 - Sep 3rd, 2019 at 6:37pm
 
I deleted:

C:/Users/miker/AppData/Local/arduino15/packages/arduino/

and

changed to "release" mode from "debug"

Now the port opens, but there is no serial output at all.

I am going to reinstall both Visual Studio and Visual Micro again, in an attempt to start clean.  Any suggestions on ensuring a clean reinstallation?
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino IDE works but VisualMicro does not
Reply #7 - Sep 3rd, 2019 at 6:41pm
 
Reinstall will not help in any way.

No serial normally means the baud rate on the monitor is wrong. What speed is your code using and what speed is the monitor set to?

Back to top
 
WWW  
IP Logged
 
557Torino
Junior Member
**
Offline



Posts: 11
Re: Arduino IDE works but VisualMicro does not
Reply #8 - Sep 4th, 2019 at 8:27pm
 
I ran this program on my lap top and after updating the Arduino files it ran.

I have updated both VS2017 and VisualMicro on the desktop computer (several times) to no avail.  There is no serial output at all.  Changing the baud rate to 9600 did not help.  If I run it with debug on the serial connection works, since the first line of text is printed to the serial port, but the program hangs on the Upd.begin statement.  I have sent you and email with the build info from both machines.  Maybe you can figure out what is different between the two machines.

Code (C++):
// Visual Micro is in vMicro>General>Tutorial Mode
//
/*
    Name:       Arduino_Dash2.1VS.ino
    Created:	9/3/2019 10:29:00 AM
    Author:     CORE2QUAD\Mike Blankenship1
*/
//Pins 10, 50, 51 and 52 are used by the Ethernet board
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xCA, 0x26 };
IPAddress lclIp(192, 168, 2, 172);
unsigned int localPort = 8889;
IPAddress rmtIp(192, 168, 2, 177);
unsigned int remotePort = 8888;
char message[] = "t";
EthernetUDP Udp;//new instance of UDP
void setup() {
	Serial.begin(9600);  // start the serial port for output and Ethernet/UDP:
	Serial.println("running Arduino_Dash2.1VS");
	Ethernet.begin(mac, lclIp);
	Udp.begin(localPort);
	Serial.print("My IP address: ");//make sure the IP address is correct
	Serial.println(Ethernet.localIP());
}
// the loop function runs over and over again forever
void loop() {
	if (message[0] == 'r')
	{
		message[0] = 'R';
	}
	else
	{
		message[0] = 'r';
	}
	Serial.print(message[0]);
	//for (int i = 0; i < sizeof(message); i++)//print message to make sure its correct
	//{
	//  Serial.print(message[i]);
	//}
	Serial.println("\r");
	Udp.beginPacket(rmtIp, remotePort);//start packet
	Udp.write(message);//sending message
	Udp.endPacket();//Close packet
	delay(1000);
}

 

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



Posts: 10395
United Kingdom
Re: Arduino IDE works but VisualMicro does not
Reply #9 - Sep 5th, 2019 at 2:39pm
 
The one that runs is using a different version of arduino. we can see this by the enternet library version. The one that runs has a final program size of 9k the one that fails is 8k

Runs OK

Code:
Using library Ethernet version 2.0.0 in folder "file:///C:/Program%20Files%20(x86)/Arduino/libraries/Ethernet"
 



Fails

Code:
Using library Ethernet version 1.1.2 in folder "file:///C:/Program%20Files/Arduino/arduino-1.8.5/libraries/Ethernet"
 




side note:  If the DTR on the serial monitor on or off? It should be On so that the chip reboots and setup runs when you open the serial monitor. The arduino ide has it on by default.

Back to top
« Last Edit: Sep 5th, 2019 at 2:51pm by Visual Micro »  
WWW  
IP Logged
 
557Torino
Junior Member
**
Offline



Posts: 11
Re: Arduino IDE works but VisualMicro does not
Reply #10 - Sep 7th, 2019 at 2:14pm
 
It is fixed!  Your were right, I had an older version of the Arduino IDE still installed.  Visual Micro was still pointing at the older version.
   I changed the location in Visual Studio by going to:

vMicro, General, configure Arduino IDE location(s)

and changed:


C:\Program Files\Arduino\arduino-1.8.5

to:

C:\Program Files (x86)\Arduino

  I assumed that loading new versions of all the software would take care of that(wrong).  Comparing the micro build dumps, that you made me aware of, was key in figuring out what had to be done.

  Thanks for your help and hope this helps others as well.  Visual Studio and Visual Micro are nice tools for programming the Arduino.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino IDE works but VisualMicro does not
Reply #11 - Sep 7th, 2019 at 4:47pm
 
Great, thanks for the update.
Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print