OpenECoSys-NetworkViewer Support for Arduino (Scope Demo)

Hello Everybody,

I have made available the Arduino support for the NetworkViewer interface I am working on for the OpenECoSys (Open Embedded Computing Systems) project:

http://www.openecosys.org

This is work in progress, but you can already use it for visualization of internal variables in real-time. This can be useful for viewing ADC values in real-time like a simple oscilloscope for instance. I have made a little tutorial on how to use the system at :

I have tested it on Arduino UNO and it works perfectly for me. It should also work pretty well on ChipKit derivatives.

The idea behind NetworkViewer is that we need to be able to monitor internal states of micro-controllers while they are running to avoid breaking their real-time constraints. My goal is to provide an easy-to-use interface that is cross-platform and versatile. Supporting multiple communication hardware from the same interface is also required. Right now, NetworkViewer supports Ethernet, CAN and serial. They are available as dynamic (loaded at run time) drivers. Over time, other plugins will be created to support other communication devices. My short term goal is to support multiple communication protocols at once to display an unified view of the heterogenous network through the NetworkViewer interface. Scripting and logging is also available as software plugins. More information about NetworkViewer can be found here :

All comments and suggestions are welcomed.

Regards,

Dominic Létourneau
http://www.openecosys.org

Hi Dominic,

Very interesting.

visualization of internal variables in real-time.

How do you gain access to the internal variables? I ask because I have a monitor program

http://arduino.cc/forum/index.php/topic,54005.0.html

that does this to a degree and is very non-intrusive but I'm interested in other approaches.

Another interest I have in NetworkViewer is as a start for a GUI for my debugging tool

http://arduino.cc/forum/index.php/topic,72014.0.html

I planned to write this in .NET but hate the fact that it's bound to Windows and QT seems like a much better option.

Could I use your code as a base for my GUI?


Rob

Graynomad:
Hi Dominic,

Very interesting.

visualization of internal variables in real-time.

How do you gain access to the internal variables? I ask because I have a monitor program

http://arduino.cc/forum/index.php/topic,54005.0.html

that does this to a degree and is very non-intrusive but I'm interested in other approaches.

Another interest I have in NetworkViewer is as a start for a GUI for my debugging tool

http://arduino.cc/forum/index.php/topic,72014.0.html

I planned to write this in .NET but hate the fact that it's bound to Windows and QT seems like a much better option.

Could I use your code as a base for my GUI?


Rob

Hello Rob,

You gain access by defining a shared memory area where the serial / CAN / Ethernet protocol can read and write using the NetworkViewer. The idea is simply to make sure the shared memory is protected (no interrupts can occur) when the protocol accesses it. Be careful, the protection is not yet implemented in the Arduino version since I didn't know how to block interrupts in an "hardware independent" manner (reusable code for PIC32 & Atmel based microcontrollers). So everything runs in the main loop. This would be problematic if you access the shared memory from an interrupt for instance. If you know how to fix that, please tell me!

In your program, you simply use the variables in the shared memory area, so they correspond to the state of the system when they are read by the protocol. I hope this makes sense!

For the GUI, you can use the GPL code of the NetworkViewer. You can also build a plugin for the NetworkViewer that would display the GUI interface you need using all the communication abstraction and plugin mechanism built into the NetworkViewer. I can help you getting started if required.

I agree that Qt is much better suited for portable applications. Using Qt allowed NetworkViewer to run on Linux, Mac, Windows with very little portability problems. However, mono is also interesting if you prefer coding with .NET. http://monodevelop.com/

Dominic

This would be problematic if you access the shared memory from an interrupt for instance. If you know how to fix that, please tell me!

Every access to those variables has to be protected by a mutex of some description, the easiest thing is just disable interrupts I suppose. For a quick read or write that shouldn't cause any drama unless there's some serious time-dependent code running.

block interrupts in an "hardware independent" manner (reusable code for PIC32 & Atmel based microcontrollers).

Can't you just have a macro to set and clear the interrupt flag?

Another way might be to make sure all your network interrupts are atomic, meaning in this case that they do everything that have to do for a given transaction before they exit the ISR. On entering they can check a semaphore and do nothing if it's set. The writing of the semaphore by the application is atomic so the only problem is that NetworkViewer may miss out on some readings.

As I assume the whole process is asynchronous so you can't guarantee to get every different value for "variables" anyway can you?

If you need to get every value with no missed ones the the above is no good and somebody has to block at some point.

I'm reasonably happy to use a .NET derivative like Mono but to be honest would rather work in C/Java.

For the GUI, you can use the GPL code of the NetworkViewer.

How do I get that? I got the exe from sourceforge but that svn link just has links to a 100 files. I assume they are the Qt source files, do I download them separately?

I also grabbed the DMG file but have no idea what it is :slight_smile:


Rob

Every access to those variables has to be protected by a mutex of some description, the easiest thing is just disable interrupts I suppose. For a quick read or write that shouldn't cause any drama unless there's some serious time-dependent code running.

Anyway, the mutex handling will also consume some resources (active polling, etc). Disabling interrupts for a quick "memcpy" should do the job in most cases. But yes, there are some time-dependent code that require more attention.

Can't you just have a macro to set and clear the interrupt flag?

I am hoping for a standardized API from the Arduino stack for interrupt disable/enable. Are you aware of something like this? Otherwise, hardware dependent macros can be written, but I think it is not very elegant for a high level communication library.

As I assume the whole process is asynchronous so you can't guarantee to get every different value for "variables" anyway can you?

The read & write requests from the NetworkViewer are async requests, and based on the (soft real-time) scheduling of variables from the PC. It is true that you cannot guarantee to get every different value for "variables". You sample them at a determined frequency (+ some jitter). However, one module can transmit its state in a periodic manner (based on a timer for instance) or when a change occurs (event based).

Variable update frequency is mostly limited by the bandwidth you have on your communication channel and the MCU performance.

How do I get that? I got the exe from sourceforge but that svn link just has links to a 100 files. I assume they are the Qt source files, do I download them separately?

First, you have to build NetworkViewer from the sources :

Let's hope you can get through the first compilation steps easily so we can start working on your plugin.

Regards,

Dominic

Thanks Dominic,

I'm downloading Qt now, this is the second attempt and at 1.4G I've already blown a large portion of my monthly allowance on the first day of the billing period :frowning:

I'm sorry I just don't get this svn.sourceforge stuff, all I see is a directory listing with dozens of files and folders with more files, am I suppose to right-click on them all the "save as"? There has to be a better way.

I got CMAKE as well, it seems that's required.

The NSIS link is broken but I found it and got that although I'm a long way from needing an installer. At 1.5M I'm not convinced it downloaded the actual install, it may only be an online installer.

WRT the the reading of variables from a target system, as long as you're happy with the occasional non-read I think the semaphore idea is usable. There's almost not overhead on the target code, just set and clear a byte.

My monitor program is only concerned with bytes at present so I don't have to worry about this, but the semaphore is what I'd do when I get back to that project.

standardized API from the Arduino stack for interrupt disable/enable.

sei() and cli(), but they are already macros that just do the assembly instructions of the same name IIRC.

We're hitting the road today and will be between towns for a few days so I won't have much internet but the Qt download just finished so at least I can play with that while I'm out of touch.


Rob

I'm sorry I just don't get this svn.sourceforge stuff, all I see is a directory listing with dozens of files and folders with more files, am I suppose to right-click on them all the "save as"? There has to be a better way.

You have to install an SVN client (Subversion) to get the latest revision of the code :

sei() and cli(), but they are already macros that just do the assembly instructions of the same name IIRC.

Thanks for the info.

We're hitting the road today and will be between towns for a few days so I won't have much internet but the Qt download just finished so at least I can play with that while I'm out of touch

Allright, keep me informed of your progress.

Dominic

We didn't leave today after all, had a slack attach.

Got Qt installed and played with a few demos.

Got TortoiseSVN installed and checked out your code.

Started a new project in Qt Creator and thought I imported all the files because it gave me a huge list, but all I have is a "Hello world" window.

EDIT: I guess hello world is some sort of default it put in because I hadn't added all the files, man I hate learning a new toolchain, but it does look good.

LATER: Slowly getting there, all files included in project but the compiler can't find "QDomDocument", it's in about 30 places but obviously not the right places.


Rob

Rob,

Have you installed the MinGW version of Qt? Also, it is important that you modify your PATH so MinGW & Qt bin directories are included.

Opening the CMakeLists.txt file in the NetworkViewer directory should be straightforward to create the project with QtCreator. Also, make sure you use the CMake MinGW generator when creating the project. You might have generated the project for Visual Studio.

Dominic

Have you installed the MinGW version of Qt?

I only saw a single download option for the main install.

When looking at the libraries section the text says

The edition you download here must match the OS you have your development system on.

No mention of the difference between VS and MinW, they are just talking about the OS.

I did however download the MinGW libraries but that was by mistake as I assumed the VS 2008 libs would be what I use as I already use VS.

I haven't installed the MinGW libraries or Cmake yet, so far other stuff (ie the examples) works and I don't like to install stuff I don't need. I assume things are largely working because I already have VS installed.

So are you saying that your prog is compiled with the MinGW libs and needs them and Cmake as well?

You might have generated the project for Visual Studio.

Given the above I'd say that's what I'm doing.

UPDATE: So I figure what the heck, I'll install the MinGW "Libraries" I downloaded by mistake, except they aren't libraries at all, at least not according to the dialog, it's the open source version of Qt. So if this is the full bottle why did I download 1.4Gs worth of "Qt, the cross-platform application framework" from the top of the downloads page?

No matter, I can install the open source version if it gets me away from a Windows dependancy. But that fails because I don't have MinGW installed of course. Not surprising as I'd never heard of it until yesterday.

To be continued...

:slight_smile:

mingw-get install gcc

That appears to work. So the install of the main package should work because it was objecting to the lack of a G++ install.

"The installer could not find a valid C:\MinGW\include\w32api.h, (Only versions with W32IPI.H 3.13 are supported)"

I check my w32api.h file, looks like it's version 3.17. Sod it I'll install anyway.


Rob

Rob,

The MinGW compiler is distributed with Qt. Use the "Maintain Qt SDK" application to select the components you need. Once you have selected the components, update your PATH variable (everything is under the C:/QtSDK directory) for the compiler and Qt bin directories. I Have attached an image of what's installed on my system.

I ran "Maintain Qt SDK" application and selected everything because basically I have no idea what I need. I didn't get a dialog anything like yours.

It chugged away installing stuff at 0% for about 20 minutes I could see that data was being downloaded but I have a slow link at present and the package gives no indication of how much it plans to download.

At 40Meg I cancelled, for all I know it's got 1G to go.

No matter, i'll try again later, at least I can continue using Creator in the mean time.

Or not...it's deleted the installation I had, Creator has totally disappeared from the disk and in the start menu I have a shit load of "Symbian ^1 xxx" entries.

I'll preserver because I can see what great apps others have done and I assume I can too, but I'm beginning to wonder.

LATER: Creator reinstalled, I'll start again.


Rob