vector iterator not dereferencable - firmata example

Hi,

I’ve successfully compiled, run and communicated with an Arduino Duemilanove v 0017 using the Examples->Firmata->StandardFirmata a very few times with a code blocks compile. Never with the vc compile. The cb compile often gives the same Debug Assertion Failed error but will occassionally run. When it runs I see tx and rx activity and the LED dims and brightens.

I have set the baud rate the same in the arduino and of. I’m running windows 7 64bit.

VC++ 2008 Express w/sp1 v. 9.0.30729.1. cb v is: wx 2.8.7

of_preRelease_v0.06_win32_cb_FAT and of_preRelease_v0.06_windows_VS2008_FAT

I get: “Debug Assertion Failed” from vc 2008. immage attached. and these lines from the log


‘jHelloWorld_debug.exe’: Unloaded ‘C:\Windows\SysWOW64\atiumdag.dll’
The thread ‘Win32 Thread’ (0x18ec) has exited with code 0 (0x0).
First-chance exception at 0x74f8b727 in jHelloWorld_debug.exe: Microsoft C++ exception: long at memory location 0x0018f158…
First-chance exception at 0x74f8b727 in jHelloWorld_debug.exe: Microsoft C++ exception: long at memory location 0x0018f2ac…
‘jHelloWorld_debug.exe’: Loaded ‘C:\Windows\SysWOW64\oleacc.dll’

I’ve also compiled it as a release version with both compilers which also crashes.

![](http://forum.openframeworks.cc/uploads/default/508/Debug Assertion Failed.png)

Since posting it hasn’t run once wouldn’t you know it - good 'ol murphy. Guess I’ll start on the Themes chapter.

Anyway I thought I should mention that when the program starts it waits for the arduino to become ready then prints 7 or 8 of the PVM counts and then blows off.

  • jeffa

are you using the firmataExample or your own code? it seems like some weird memory issue. if it’s your code can you post it?

with the firmataExample supplied with of.

I just rebuilt the firmataExample before composing this reply (rather than the copied code that I supplied the screen shot of in original post) in vc and got the same error.

Also curious about these link messages:


1>ofStandardFirmata.cpp
1>Generating Code…
1>Compiling manifest to resources…
1>Microsoft ® Windows ® Resource Compiler Version 6.1.6723.1
1>Copyright © Microsoft Corporation. All rights reserved.
1>Linking…
1>LINK : bin\firmataExample_debug.exe not found or not built by the last incremental link; performing full link
1>rtAudioD.lib(RtAudio.obj) : warning LNK4099: PDB ‘vc90.pdb’ was not found with ‘…\libs\rtAudio\libs\vs2008\rtAudioD.lib’ or at ‘c:\Users\jeffa\Development\of_preRelease_v0.06_windows_VS2008_FAT\apps\examples\firmataExample\bin\vc90.pdb’; linking object as if no debug info
1>videoInput.lib(videoInput.obj) : warning LNK4099: PDB ‘vc80.pdb’ was not found with ‘…\libs\videoInput\lib\videoInput.lib’ or at ‘c:\Users\jeffa\Development\of_preRelease_v0.06_windows_VS2008_FAT\apps\examples\firmataExample\bin\vc80.pdb’; linking object as if no debug info
1>PocoFoundationmtd.lib(Bugcheck.obj) : warning LNK4099: PDB ‘vc90.pdb’ was not found with ‘…\libs\Poco\lib\PocoFoundationmtd.lib’ or at ‘c:\Users\jeffa\Development\of_preRelease_v0.06_windows_VS2008_FAT\apps\examples\firmataExample\bin\vc90.pdb’; linking object as if no debug info
1>PocoFoundationmtd.lib(Debugger.obj) : warning LNK4099: PDB ‘vc90.pdb’ was not found with ‘…\libs\Poco\lib\PocoFoundationmtd.lib’ or at ‘c:\Users\jeffa\Development\of_preRelease_v0.06_windows_VS2008_FAT\apps\examples\firmataExample\bin\vc90.pdb’; linking object as if no debug info…

Thanks - jeffa

FYI

I installed code blocks and openFrameworks on another physical machine. This one running 32bit XP. I got the same results with the application crashing once the arduino and firmataExample began their communication.

On the original machine with vc I rememberd I also had a Lilly Pad 328 in addition to the arduino duemilanove mentioned in my original post. So I installed firmata on it, verified com ports and recompiled in vc. Same problem.

  • jeffa

hey, can you debug the app and see what line is it crashing in

Hi what follows is from a friend of mine. I asked him to help me get the line number for you…

It’s working now under vc. But it’s still a bit flakey as it will abend occasionally. Before it wouldn’t run at all in the vc compile.

Hope it helps.

  • jeffa

The problem arises from line 346 of the ofStandardFirmata.cpp file. Upon first run, the list is empty and therefore calling .front will throw an assert error in Visual Studio. The easy fix is to check the size of the list beforehand and if it is empty, add the entry to the list and call the event handler.

  
  
if (_analogHistory[_multiByteChannel].size() == 0)  
{  
_analogHistory[_multiByteChannel].push_front((_storedInputData[0] << 7) | _storedInputData[1]);	  
	ofNotifyEvent(EAnalogPinChanged, _multiByteChannel, this);  
}  
  
else  
  
{  
int previous = _analogHistory[_multiByteChannel].front();  
  
_analogHistory[_multiByteChannel].push_front((_storedInputData[0] << 7) | _storedInputData[1]);  
if((int)_analogHistory[_multiByteChannel].size()>_analogHistoryLength)  
	_analogHistory[_multiByteChannel].pop_back();  
  
// trigger an event if the pin has changed value  
if(_analogHistory[_multiByteChannel].front()!=previous)  
  
	ofNotifyEvent(EAnalogPinChanged, _multiByteChannel, this);  
}  
  
  

Also

I’ve used the pot on a danger shield and a joystick shield both 10k for the firmataExample. Their schematic indicates a configuration as in the test setup for the firmataExample.

I would expect to get a range of 0 - 1023

However on the

dangershield I get around 0 - 1000 at about the last 10% of the pot.

joystick shield i get 0 - 36 in the middle of the range of the pot.

???

My goal in this project where I want to incororate the Arduino into openFrameworks is to get the input from a Parallax ping sensor. I’ve successfully done this in arduino. And from arduino to processing. Now I want to get that distance information into openFrameworks.

Is there any code to do that I might look at before trying to write my own?

Thanks, - jeffa

Also

I’ve used the pot on a danger shield and a joystick shield both 10k for the firmataExample. Their schematic indicates a configuration as in the test setup for the firmataExample.

I would expect to get a range of 0 - 1023

However on the

dangershield I get around 0 - 1000 at about the last 10% of the pot.

joystick shield i get 0 - 36 in the middle of the range of the pot.

I started a thread about firmata and processing over on arduino.cc.

http://www.arduino.cc/cgi-bin/yabb2/YaB-…-61904195/0

I found comments about problems with the firmata version I was using from arduino 0017. This link has a firmata version that fixed the above quoted problem with the analog range input. http://at.or.at/hans/pd/objects.html#firmata

  • jeffa

hey, thanks for the fix!