Strange problem with ofSerial

I have a serial device that I need to send a number as a string, i.e. “01” or “13” with the settings:

Baud rate 9600, Data bits 8, Parity None, Stop bits 1, flow control None.

When I send a message, the device doesn’t respond as I’d expect. However, if I use this software with those settings
http://www.windmill.co.uk/serial.html

The device works as planned. However, here is the puzzle. When I run my OFW code and do exactly the same again (after running Windmill comDebug) it works perfectly.

Any ideas?

Its nothing to do with the device I’m using, but something to do with software or libraries.

Thanks

hi chris,

I’ve discovered some weirdness with visual studio / serial connection.

you can download the latest version of the serial code (from the svn) or try changing this part of the setup code for VS (basically, we are avoiding all that “wide char” stuff using BuildCommDCBA)

  
  
#if (_MSC_VER)       // microsoft visual studio  
		// msvc doesn't like BuildCommDCB,   
		//so we need to use this version: BuildCommDCBA  
		if(!BuildCommDCBA(buf,&cfg.dcb)){				  
			printf("ofSerial: unable to build comm dcb; (%s) \n",buf);  
		}  
	#else  
  
  

I noticed in NMM / sweden that this helped one VS user connect better with serial device.

does that help?

-zach

I just downloaded the svn snapshot (link) and when I go to build, it says:

1>…\libs\openFrameworks\sound\ofSoundPlayer.h(70) : error C2146: syntax error : missing ‘;’ before identifier ‘result’
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(70) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(70) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(71) : error C2143: syntax error : missing ‘;’ before ‘*’
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(71) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(71) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(72) : error C2143: syntax error : missing ‘;’ before ‘*’
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(72) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>…\libs\openFrameworks\sound\ofSoundPlayer.h(72) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

What am I missing?

I think perhaps you are not linked against fmodex properly. we’ve switched from fmod to fmodex.

hang tight, I am just fixing linux and we post shortly :slight_smile:

sorry - we did some altering of core libraries (added glu, fmodex, etc) and so it’s not easy to just plug in the svn code. it will be after we get this up.

you can try just the new serial code (on the svn) and see if it helps

take care,
zach

Ah I see. I’ll wait before upgrading to 0.03 :slight_smile:

I restored to the 0.02 openFrameworks lib folder, but just replaced the ofserial .h and .cpp files.

Now when I build I get this output

1>Linking…
1>ofSerial.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetDeviceRegistryPropertyW@28
1>ofSerial.obj : error LNK2001: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4
1>ofSerial.obj : error LNK2001: unresolved external symbol __imp__SetupDiEnumDeviceInfo@12
1>ofSerial.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetClassDevsW@16
1>Release\myCV.exe : fatal error LNK1120: 4 unresolved externals

Thanks

ah !!
you will need to add I think setupapi.lib to the build path… it’s a windows library you can find it with the other window.
sorry, sorry, lots of changes :slight_smile:

zach

I found 3 copies of setupapi.lib on my computer in…

C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib\
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib\AMD64\
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib\IA64\

Which one is best to include? The first one I am guessing.

In the project settings, how should I be including this file?

Many thanks

yep the first one

you can just add into the list of libs that are being linked against.
be careful in VS, you will have to do this one at a time for “debug” and “release” targets, not for “all targets” – if you do it for all targets, you can clobber both list, because these list are actually different for debug/release because of rtAudio… there are description of doing this careful operation in the opencv addon. you don’t need to add that path (the first one) because it’s already set as part of the compiler (one of the steps in setting up VSEE).

hope that helps -
z

I added
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib\

in
Linker > General > Additional Library Directories
(for debug and release separately)

I still get the same build errors as before. Should it auto find setupapi.lib in that folder, or do I need to add setupapi.lib to the project properties somewhere?

Thanks

I don’t think you need to add that (as I said above) because that folder is set when you setup VSEE (see openframeworks.cc/setup)

what you need to do is add:

Properties -> Linker -> Input -> additional dependencies
(add it once for release, once for debug)
add setupapi.lib to that list.

take care!!
zach

or you can hang on for a sec, will upload the whole package in a minute – :slight_smile:

Thanks Zach, I got it to compile in the end and the changes fix my original bug posted above.

cool - now can you let us know if that helps with the arduino interaction? We don’t get alot of chances to test that so feedback is helpful. This new code presents a better interface for querying for ports, opening ports, and interacting with the arduino.

please note that we’ve sometimes seen some arduinos take a pretty long time to sink (from uploading the code to then connecting and running it), so try to patient when you test –

thanks!!
zach