Integerated debugger with arduino simulator

Trying to debug with println statements is slow and a real pain in the arse!

Wouldn't it be wonderful, if simply for the purpose of debugging algorithms rather total sketch behavior on an arduino, if we had a Visual studio like integrated debugger with series of simulated digital pins that you could set to on or off and indicate if they are on or off.

And perhaps some edit fields corresponding to serial ports your sketch is using, e.g. Serial , Serial1, I2c, SPI, where you could enter a data stream or specify a text file containing a data stream that the sketch could consume.

How feasible would this be with the Arduino IDE, or perhaps a separate stand alone one with the simulator + integrated debugger?

As I understand it at present it would require a special version of the libraries wire.h, spi.h, hardwareserial.h and softwareserial.h and the functions digitalWrite(...), digitalRead.h, analogRead(...), analogWrite(...) and pinMode(...)

I would guess they would have to transmit their data to some sort of software buffer rather to arduino ports.

I reckon it would be a very difficult program to write and to debug. But if you feel like doing it can I request that you do it with a programming system that works on Linux and Mac as well as Windows?

...R

Robin2: I reckon it would be a very difficult program to write and to debug. But if you feel like doing it can I request that you do it with a programming system that works on Linux and Mac as well as Windows?

...R

Unfortunately, should I choose to have a crack at it, I don't have easy access to Linux and Mac computers plus software in order to do it.

The best I might be able to do is to try an separate the arduino simulator from the Windows UI stuff with some sort of standardized interface into the simulator. And that would theoretically make it easier for others to port it over to other operating systems.

Also I would really need to work with others who have a far more in depth knowledge of how the Arduino IDE architecture works. I am unlikely to succeed on my own with my very limited knowledge in this area. Or if I did it might take 20 years on my own. I strongly suspect that such an undertaking is not really a one man show.

On the up side Windows MFC makes it really easy to setup a basic text editor. In fact there some ready made example projects that could be adapted.

I have been working on an enhanced PString class (I have renamed it to CString) class. You declare the variables like you do with PString but it contains most of the functionality of String, plus a bit extra.

I have had a bitch of a time trying to debug some of the functions with println statements and got sick to death of it. So I ported the class over to Visual Studio 2015 and debugged them there - much easier. It did not take all that many code changes to get the class to compile in Visual Studio. I just set up a basic dialog box base app and called my string functions in an initialisation function (OnInitDialog(...)

Visual Studio 2015 Community is free if you want to try it.

All I had to do is swap my strcat functions for strcat_s, my strcpy functions for strcpy_s and make some typedefs e.g.

typedef uint8_t byte; typefef uint32_t DWORD;

etc

And that was about it to make my archuino class compile in Visual Studio.

If you don't use the types then you will have even less work because all the standard C types in arduino are the same in visual studio.

boylesg: Unfortunately, should I choose to have a crack at it, I don't have easy access to Linux and Mac computers plus software in order to do it.

I fully understand that. But you are not obliged to use Microsoft specific programming tools on a Windows PC.

Java based programs (Java itself, Processing and JRuby, for example) generally transfer painlessly between OSs and a lot of Python stuff will also do so.

...R

Robin2: I fully understand that. But you are not obliged to use Microsoft specific programming tools on a Windows PC.

Java based programs (Java itself, Processing and JRuby, for example) generally transfer painlessly between OSs and a lot of Python stuff will also do so.

...R

My only experience of python is with my raspberry pi and it is very limited. How easy an quick and easy is it to build a UI with python? Because the UI required in the case of an arduino simulator would be fairly complex.

Regardless of that it would take perhaps a day to build such a UI in Visual Studio. Essentially you put it together in much the same way as you arrange drawing objects in Microsoft Word. And then you just put the code behind the user controls.

Visual Studio does have options for cross platform apps, including android apps. I have tried building an android app briefly but that is about it. They might be worth investigating further to see how many platforms you can practically cover.

I don't see how I could use JRuby. The idea would be to compile an run your arduino sketch in a debugging environment that simulates the presence of an arduino similar to the Arduino IDE itself. And C++ code is not going to compile or interpret in a Java environment.

boylesg: Unfortunately, should I choose to have a crack at it, I don't have easy access to Linux and Mac computers plus software in order to do it.

Screw apple, but you always have access to Linux. Just download it, it's free, and install it. If you don't want to install it on your system, install it on a USB stick and boot it from there. Or dual boot it. You can do whatever you want with it. But you can't say you don't have access to it unless you live in a Faraday cage with no access to the internet. That's obviously not the case since you're here.

I recommend starting with something easy like Ubuntu. It won't take you long before you'll vow to never ever ever pay money for Windows again.

boylesg: And C++ code is not going to compile or interpret in a Java environment.

JRuby can do anything that Python can do - but I had assumed you were planning a simulator - not something that would run raw C++ code.

And I do agree that Microsoft seems to have a better system for creating GUI apps. It's just that I won't be able to use the finished product.

...R

Robin2: JRuby can do anything that Python can do - but I had assumed you were planning a simulator - not something that would run raw C++ code.

And I do agree that Microsoft seems to have a better system for creating GUI apps. It's just that I won't be able to use the finished product.

...R

I meant a compiler with an arduino simulator so that you can debug your code.

Instead of uploading the compiled sketch to an actual arduino board it would start a simulator that would interact with with your compiled sketch through editable UI components, e.g. a text field for the serial ports.

It would require implementing the same sort of debugging features that Visual Studio has.

It would be a BIG job requiring a small team.

I just realized I got myself mixed up about this

planning a simulator - not something that would run raw C++ code.

You can easily call the Arduino IDE from another program (I do it from Python) to do the compiling. It will produce the hex code that is uploaded to the Arduino.

Your simulator would have to be able to simulate the much simpler Atmega assembler code based on the output from the compiler.

Of course "much simpler" does not mean simple :)

...R