|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
||||
|
||||
|
replace WPILib part
In the C programming manual that comes with WPILib, I remember it saying you can replace parts of WPILib by adding the source code to your class, and then just compiling. I was testing a modified Dashboard class (removed all functions, except Printf and Finalize, both renamed Add and Send (and inner code tweaked), and no matter what I tried, It would give either a compiler or linker error. The one tricky thing is I must get my custom dashboard class from ds->GetDashboardPacker() because it needs access to a shared status pointer the dashboard updates. How do I get this to work?
Things I have tried: Dashboard.c & h in project dir copy h to WPILib folder, overwriting original h delete my .h #if trickery (from my c new, else old, and a few other...) h style trickery (forward declarations, etc...) restore my h combine my H and c |
|
#2
|
||||
|
||||
|
Re: replace WPILib part
Could you post the compile errors you get?
|
|
#3
|
||||
|
||||
|
Re: replace WPILib part
hmm, I can't seem to get the compiler errors at home, but they were along the lines of
error: 'class Dashboard' has no member named 'Add' and the linking error was a standard linking error (x was not found,do you want to proceed with launch when I compile it at home, I also get this warning: function `void Dashboard::Add(const char*, const char*)' used but never defined |
|
#4
|
||||
|
||||
|
Re: replace WPILib part
Quote:
Post your modified WPILib files (.cpp and .h). |
|
#5
|
||||
|
||||
|
Re: replace WPILib part
Header:
PHP Code:
PHP Code:
PHP Code:
|
|
#6
|
||||
|
||||
|
Re: replace WPILib part
I'm just glancing at this quick, but IIRC, inline functions need the function body along with the declaration. You can't give a function prototype in a header, mark it as inline, and then go put the actual definition of the function somewhere else. I could be wrong though.
|
|
#7
|
||||
|
||||
|
Re: replace WPILib part
Quote:
http://www.parashift.com/c++-faq-lit...s.html#faq-9.7 http://www.parashift.com/c++-faq-lit...s.html#faq-9.8 http://www.parashift.com/c++-faq-lit...s.html#faq-9.9 |
|
#8
|
||||
|
||||
|
Re: replace WPILib part
Just out of curiosity, why are you making them all inline?
|
|
#9
|
||||
|
||||
|
Re: replace WPILib part
the clones are inline to only (hopefully) incur 1 function call, because they are small, and call the main function
normal: Auto() > var("x",5) > > AddDebugVariable("x",5) > > > AddDebugVariable("x","5") > > > > Add("dbg","x: 5") Inline: Auto() var("x",5) AddDebugVariable("x",5) AddDebugVariable("x","5") > Add("dbg","x: 5") Normal makes 4 function calls, Inline only 1 EDIT: I accidentally put inline on void Add(const char* name, const char* value); instead of void AddDebugVariable(const char* name, const char* value); Last edited by byteit101 : 01-01-2010 at 19:02. |
|
#10
|
||||
|
||||
|
Re: replace WPILib part
I have this issue again on a different file, AxisCamera. I was adding a saving function, and it started doing it. I was editing it, save, compile, add more, etc... and I added one line, and it started doing it, and won't stop. I commented my chages, even completely replaced the files with the default WPILib's, but it does the error now. Rebuilds make no different.
errors: Code:
Build Started in Project 'Breakaway': 2010-02-26 15:17:08 Generation of makefiles started. Generation of makefiles finished (Elapsed Time: 00:00). Platform: Wind River VxWorks 6.3 Command: make --no-print-directory BUILD_SPEC=PPC603gnu DEBUG_MODE=1 TRACE=1 Working Directory: C:/WindRiver/workspace/Breakaway/PPC603gnu if [ ! -d "`dirname "Breakaway_partialImage/Debug/Objects/Breakaway/AxisCamera.o"`" ]; then mkdir -p "`dirname "Breakaway_partialImage/Debug/Objects/Breakaway/AxisCamera.o"`"; fi;echo "building Breakaway_partialImage/Debug/Objects/Breakaway/AxisCamera.o"; ccppc -g -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall -ansi -Wall -MD -MP -mlongcall -IC:/WindRiver/vxworks-6.3/target/h -IC:/WindRiver/vxworks-6.3/target/h/WPILib -IC:/WindRiver/vxworks-6.3/target/h/wrn/coreip -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL -o "Breakaway_partialImage/Debug/Objects/Breakaway/AxisCamera.o" -c "C:/WindRiver/workspace/Breakaway/AxisCamera.cpp" building Breakaway_partialImage/Debug/Objects/Breakaway/AxisCamera.o if [ ! -d "`dirname "Breakaway_partialImage/Debug/Objects/Breakaway/Main.o"`" ]; then mkdir -p "`dirname "Breakaway_partialImage/Debug/Objects/Breakaway/Main.o"`"; fi;echo "building Breakaway_partialImage/Debug/Objects/Breakaway/Main.o"; ccppc -g -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall -ansi -Wall -MD -MP -mlongcall -IC:/WindRiver/vxworks-6.3/target/h -IC:/WindRiver/vxworks-6.3/target/h/WPILib -IC:/WindRiver/vxworks-6.3/target/h/wrn/coreip -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL -o "Breakaway_partialImage/Debug/Objects/Breakaway/Main.o" -c "C:/WindRiver/workspace/Breakaway/Main.cpp" building Breakaway_partialImage/Debug/Objects/Breakaway/Main.o if [ ! -d "`dirname "Breakaway_partialImage/Debug/Objects/Breakaway/PCVideoServer.o"`" ]; then mkdir -p "`dirname "Breakaway_partialImage/Debug/Objects/Breakaway/PCVideoServer.o"`"; fi;echo "building Breakaway_partialImage/Debug/Objects/Breakaway/PCVideoServer.o"; ccppc -g -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall -ansi -Wall -MD -MP -mlongcall -IC:/WindRiver/vxworks-6.3/target/h -IC:/WindRiver/vxworks-6.3/target/h/WPILib -IC:/WindRiver/vxworks-6.3/target/h/wrn/coreip -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL -o "Breakaway_partialImage/Debug/Objects/Breakaway/PCVideoServer.o" -c "C:/WindRiver/workspace/Breakaway/PCVideoServer.cpp" building Breakaway_partialImage/Debug/Objects/Breakaway/PCVideoServer.o if [ ! -d "`dirname "Breakaway_partialImage/Debug/Breakaway_partialImage.o"`" ]; then mkdir -p "`dirname "Breakaway_partialImage/Debug/Breakaway_partialImage.o"`"; fi;echo "building Breakaway_partialImage/Debug/Breakaway_partialImage.o"; ccppc -r -nostdlib -Wl,-X -o "Breakaway_partialImage/Debug/Breakaway_partialImage.o" Breakaway_partialImage/Debug/Objects/Breakaway/Array.o Breakaway_partialImage/Debug/Objects/Breakaway/AxisCamera.o Breakaway_partialImage/Debug/Objects/Breakaway/BTR.o Breakaway_partialImage/Debug/Objects/Breakaway/Main.o Breakaway_partialImage/Debug/Objects/Breakaway/Mechs.o Breakaway_partialImage/Debug/Objects/Breakaway/PCVideoServer.o Breakaway_partialImage/Debug/Objects/Breakaway/Ptr.o Breakaway_partialImage/Debug/Objects/Breakaway/ZDashboard.o && if [ "0" = "1" ]; then plink "Breakaway_partialImage/Debug/Breakaway_partialImage.o";fi building Breakaway_partialImage/Debug/Breakaway_partialImage.o if [ ! -d "`dirname "Breakaway/Debug/Breakaway.out"`" ]; then mkdir -p "`dirname "Breakaway/Debug/Breakaway.out"`"; fi;echo "building Breakaway/Debug/Breakaway.out";rm -f "Breakaway/Debug/Breakaway.out";nmppc Breakaway_partialImage/Debug/Breakaway_partialImage.o C:/WindRiver/vxworks-6.3/target/lib/WPILib.a | tclsh C:/WindRiver/vxworks-6.3/host/resource/hutils/tcl/munch.tcl -c ppc > Breakaway/Debug/ctdt.c; ccppc -g -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall -fdollars-in-identifiers -Wall -IC:/WindRiver/vxworks-6.3/target/h -IC:/WindRiver/vxworks-6.3/target/h/WPILib -IC:/WindRiver/vxworks-6.3/target/h/wrn/coreip -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL -o Breakaway/Debug/ctdt.o -c Breakaway/Debug/ctdt.c; ccppc -r -nostdlib -Wl,-X -T C:/WindRiver/vxworks-6.3/target/h/tool/gnu/ldscripts/link.OUT -o "Breakaway/Debug/Breakaway.out" Breakaway/Debug/ctdt.o Breakaway_partialImage/Debug/Breakaway_partialImage.o C:/WindRiver/vxworks-6.3/target/lib/WPILib.a && if [ "0" = "1" ]; then plink "Breakaway/Debug/Breakaway.out";fi building Breakaway/Debug/Breakaway.out C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.bss+0x0):C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:25: multiple definition of `AxisCamera::m_instance' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.bss+0x4):C:/WindRiver/workspace/Breakaway/Array.cpp:2: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1a7c): In function `AxisCamera::s_ImageStreamTaskFunction(AxisCamera*)': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:183: multiple definition of `AxisCamera::s_ImageStreamTaskFunction(AxisCamera*)' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x1e2c):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:185: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x5b0): In function `AxisCamera::~AxisCamera()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:43: multiple definition of `AxisCamera::~AxisCamera()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x7f4):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:45: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCamera::~AxisCamera()' changed from 992 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 884 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x924): In function `AxisCamera::~AxisCamera()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:43: multiple definition of `AxisCamera::~AxisCamera()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0xbd4):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:45: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCamera::~AxisCamera()' changed from 992 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 884 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0xc98): In function `AxisCamera::~AxisCamera()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:43: multiple definition of `AxisCamera::~AxisCamera()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0xfb4):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:45: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCamera::~AxisCamera()' changed from 992 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 884 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x11f4): In function `AxisCamera::DeleteInstance()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:78: multiple definition of `AxisCamera::DeleteInstance()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x15a0):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:80: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1258): In function `AxisCamera::IsFreshImage()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:87: multiple definition of `AxisCamera::IsFreshImage()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x1604):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:89: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1288): In function `AxisCamera::GetNewImageSem()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:100: multiple definition of `AxisCamera::GetNewImageSem()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x1634):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:102: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x130c): In function `AxisCamera::GetImage(Image_struct*)': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:113: multiple definition of `AxisCamera::GetImage(Image_struct*)' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x16b8):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:115: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1520): In function `AxisCamera::GetImage()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:140: multiple definition of `AxisCamera::GetImage()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x18cc):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:142: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCamera::GetImage()' changed from 356 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 352 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1680): In function `AxisCamera::CopyJPEG(char**, int&, int&)': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:157: multiple definition of `AxisCamera::CopyJPEG(char**, int&, int&)' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x1a30):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:159: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1ac8): In function `AxisCamera::ImageStreamTaskFunction()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:193: multiple definition of `AxisCamera::ImageStreamTaskFunction()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x1e78):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:195: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1b50): In function `AxisCamera::ReadImagesFromCamera()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:218: multiple definition of `AxisCamera::ReadImagesFromCamera()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x1f00):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:220: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x1e90): In function `AxisCamera::UpdatePublicImageFromCamera(char*, int)': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:301: multiple definition of `AxisCamera::UpdatePublicImageFromCamera(char*, int)' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2240):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:303: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x21b0): In function `AxisCamera::RestartCameraTask()': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:336: multiple definition of `AxisCamera::RestartCameraTask()' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2560):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:338: first defined here C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x224c): In function `AxisCameraStart': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:346: multiple definition of `AxisCameraStart' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x25fc):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:348: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraStart' changed from 72 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 60 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2288): In function `AxisCameraGetImage': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:351: multiple definition of `AxisCameraGetImage' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2644):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:353: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetImage' changed from 112 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 100 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x22ec): In function `AxisCameraWriteBrightness': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:356: multiple definition of `AxisCameraWriteBrightness' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x26b4):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:358: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteBrightness' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2348): In function `AxisCameraGetBrightness': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:361: multiple definition of `AxisCameraGetBrightness' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x271c):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:363: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetBrightness' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x23a4): In function `AxisCameraWriteWhiteBalance': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:366: multiple definition of `AxisCameraWriteWhiteBalance' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2784):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:368: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteWhiteBalance' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2400): In function `AxisCameraGetWhiteBalance': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:371: multiple definition of `AxisCameraGetWhiteBalance' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x27ec):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:373: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetWhiteBalance' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x245c): In function `AxisCameraWriteColorLevel': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:376: multiple definition of `AxisCameraWriteColorLevel' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2854):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:378: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteColorLevel' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x24b8): In function `AxisCameraGetColorLevel': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:381: multiple definition of `AxisCameraGetColorLevel' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x28bc):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:383: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetColorLevel' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2514): In function `AxisCameraWriteExposureControl': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:386: multiple definition of `AxisCameraWriteExposureControl' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2924):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:388: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteExposureControl' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2570): In function `AxisCameraGetExposureControl': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:391: multiple definition of `AxisCameraGetExposureControl' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x298c):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:393: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetExposureControl' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x25cc): In function `AxisCameraWriteExposurePriority': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:396: multiple definition of `AxisCameraWriteExposurePriority' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x29f4):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:398: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteExposurePriority' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2628): In function `AxisCameraGetExposurePriority': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:401: multiple definition of `AxisCameraGetExposurePriority' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2a5c):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:403: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetExposurePriority' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2684): In function `AxisCameraWriteMaxFPS': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:406: multiple definition of `AxisCameraWriteMaxFPS' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2ac4):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:408: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteMaxFPS' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x26e0): In function `AxisCameraGetMaxFPS': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:411: multiple definition of `AxisCameraGetMaxFPS' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2b2c):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:413: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetMaxFPS' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x273c): In function `AxisCameraWriteResolution': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:416: multiple definition of `AxisCameraWriteResolution' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2b94):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:418: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteResolution' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2798): In function `AxisCameraGetResolution': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:421: multiple definition of `AxisCameraGetResolution' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2bfc):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:423: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetResolution' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x27f4): In function `AxisCameraWriteCompression': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:426: multiple definition of `AxisCameraWriteCompression' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2c64):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:428: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteCompression' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2850): In function `AxisCameraGetCompression': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:431: multiple definition of `AxisCameraGetCompression' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2ccc):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:433: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetCompression' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x28ac): In function `AxisCameraWriteRotation': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:436: multiple definition of `AxisCameraWriteRotation' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2d34):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:438: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraWriteRotation' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2908): In function `AxisCameraGetRotation': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:441: multiple definition of `AxisCameraGetRotation' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2d9c):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:443: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraGetRotation' changed from 104 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 92 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x2964): In function `AxisCameraDeleteInstance': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:446: multiple definition of `AxisCameraDeleteInstance' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2e04):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:448: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraDeleteInstance' changed from 96 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 84 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o)(.text+0x29b8): In function `AxisCameraFreshImage': C:/WindRiver/workspace/WPILib/Vision/AxisCamera.cpp:451: multiple definition of `AxisCameraFreshImage' Breakaway_partialImage/Debug/Breakaway_partialImage.o(.text+0x2e64):C:/WindRiver/workspace/Breakaway/AxisCamera.cpp:453: first defined here c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/bin/../lib/gcc/powerpc-wrs-vxworks/3.4.4/../../../../../x86-win32/powerpc-wrs-vxworks/bin/ld.exe: Warning: size of symbol `AxisCameraFreshImage' changed from 112 in Breakaway_partialImage/Debug/Breakaway_partialImage.o to 100 in C:/WindRiver/vxworks-6.3/target/lib/WPILib.a(AxisCamera.o) collect2: ld returned 256 exit status make: built targets of C:/WindRiver/workspace/Breakaway/PPC603gnu Build Finished in Project 'Breakaway': 2010-02-26 15:17:16 (Elapsed Time: 00:08) Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef __AXIS_CAMERA_H__
#define __AXIS_CAMERA_H__
#include <taskLib.h>
#include <vxWorks.h>
#include <sockLib.h>
#include <inetLib.h>
#include "Vision/AxisCameraParams.h"
#include "Vision/ColorImage.h"
#include "Vision/HSLImage.h"
#include "nivision.h"
#include <set>
#include "Task.h"
/**
* AxisCamera class.
* This class handles everything about the Axis 206 FRC Camera.
* It starts up 2 tasks each using a different connection to the camera:
* - image reading task that reads images repeatedly from the camera
* - parameter handler task in the base class that monitors for changes to
* parameters and updates the camera
*/
class AxisCamera: public AxisCameraParams
{
AxisCamera(const char *cameraIP = "192.168.0.90",bool filesave=false, const char *fpath="img/");
public:
virtual ~AxisCamera();
static AxisCamera& GetInstance(bool filesave=false, const char *fpath="img/");
void DeleteInstance();
bool IsFreshImage();
SEM_ID GetNewImageSem();
int GetImage(Image *imaqImage);
int GetImage(ImageBase *image);
ImageBase *GetImage();
//Image *GetimaqImage();
int CopyJPEG(char **destImage, int &destImageSize, int &destImageBufferSize);
private:
static int s_ImageStreamTaskFunction(AxisCamera *thisPtr);
int ImageStreamTaskFunction();
int ReadImagesFromCamera();
void UpdatePublicImageFromCamera(char *imgBuffer, int imgSize);
virtual void RestartCameraTask();
static int s_SaveImageFunction(AxisCamera *thisPtr);
int SaveImageFunction();
static AxisCamera *m_instance;
int m_cameraSocket;
typedef std::set<SEM_ID> SemSet_t;
SemSet_t m_newImageSemSet;
char* m_protectedImageBuffer;
int m_protectedImageBufferLength;
int m_protectedImageSize;
SEM_ID m_protectedImageSem;
bool m_freshImage;
Task m_imageStreamTask;
Task m_imageSaveTask;
const char *fpathSave;
};
extern "C" {
void AxisCameraStart();
int AxisCameraGetImage(Image *image);
void AxisCameraDeleteInstance();
int AxisCameraFreshImage();
// Mid-stream gets & writes
void AxisCameraWriteBrightness(int brightness);
int AxisCameraGetBrightness();
void AxisCameraWriteWhiteBalance(AxisCameraParams::WhiteBalance_t whiteBalance);
AxisCameraParams::WhiteBalance_t AxisCameraGetWhiteBalance();
void AxisCameraWriteColorLevel(int colorLevel);
int AxisCameraGetColorLevel();
void AxisCameraWriteExposureControl(AxisCameraParams::Exposure_t exposure);
AxisCameraParams::Exposure_t AxisCameraGetExposureControl();
void AxisCameraWriteExposurePriority(int exposurePriority);
int AxisCameraGetExposurePriority();
void AxisCameraWriteMaxFPS(int maxFPS);
int AxisCameraGetMaxFPS();
// New-Stream gets & writes
void AxisCameraWriteResolution(AxisCameraParams::Resolution_t resolution);
AxisCameraParams::Resolution_t AxisCameraGetResolution();
void AxisCameraWriteCompression(int compression);
int AxisCameraGetCompression();
void AxisCameraWriteRotation(AxisCameraParams::Rotation_t rotation);
AxisCameraParams::Rotation_t AxisCameraGetRotation();
}
#endif
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include <string.h>
#include "Synchronized.h"
#include "AxisCamera.h"
#include "PCVideoServer.h"
/** Private NI function to decode JPEG */
IMAQ_FUNC int Priv_ReadJPEGString_C(Image* _image, const unsigned char* _string, UINT32 _stringLength);
// Max packet without jumbo frames is 1500... add 36 because??
#define kMaxPacketSize 1536
#define kImageBufferAllocationIncrement 1000
AxisCamera* AxisCamera::m_instance = NULL;
/**
* AxisCamera constructor
*/
AxisCamera::AxisCamera(const char *ipAddress,bool filesave, const char *fpath)
: AxisCameraParams(ipAddress)
, m_cameraSocket (0)
, m_protectedImageBuffer(NULL)
, m_protectedImageBufferLength (0)
, m_protectedImageSize (0)
, m_protectedImageSem (NULL)
, m_freshImage (false)
, m_imageStreamTask("cameraTask", (FUNCPTR)s_ImageStreamTaskFunction)
, m_imageSaveTask("cameraSaveTask", (FUNCPTR)s_SaveImageFunction)
{
m_protectedImageSem = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
m_imageStreamTask.Start((int)this);
//fpathSave=fpath;
}
/**
* Destructor
*/
AxisCamera::~AxisCamera()
{
m_imageStreamTask.Stop();
close(m_cameraSocket);
SemSet_t::iterator it = m_newImageSemSet.begin();
SemSet_t::iterator end = m_newImageSemSet.end();
for (;it != end; it++)
{
semDelete(*it);
}
m_newImageSemSet.clear();
semDelete(m_protectedImageSem);
m_instance = NULL;
}
/**
* Get a pointer to the AxisCamera object, if the object does not exist, create it
* @return reference to AxisCamera object
*/
AxisCamera& AxisCamera::GetInstance(bool filesave, const char *fpath)
{
if (NULL == m_instance) {
// Since this is a singleton for now, just use the default IP address.
m_instance = new AxisCamera("192.168.0.90",filesave,fpath);
// TODO: Keep track of this so it can be shut down!
new PCVideoServer();
}
return *m_instance;
}
/**
* Called by Java to delete the camera... how thoughtful
*/
void AxisCamera::DeleteInstance()
{
delete m_instance;
}
/**
* Return true if the latest image from the camera has not been retrieved by calling GetImage() yet.
* @return true if the image has not been retrieved yet.
*/
bool AxisCamera::IsFreshImage()
{
return m_freshImage;
}
/**
* Get the semaphore to be used to synchronize image access with camera acquisition
*
* Call semTake on the returned semaphore to block until a new image is acquired.
*
* The semaphore is owned by the AxisCamera class and will be deleted when the class is destroyed.
* @return A semaphore to notify when new image is received
*/
SEM_ID AxisCamera::GetNewImageSem()
{
SEM_ID sem = semBCreate (SEM_Q_PRIORITY, SEM_EMPTY);
m_newImageSemSet.insert(sem);
return sem;
}
/**
* Get an image from the camera and store it in the provided image.
* @param image The imaq image to store the result in. This must be an HSL or RGB image
* This function is called by Java.
* @return 1 upon success, zero on a failure
*/
int AxisCamera::GetImage(Image* imaqImage)
{
if (m_protectedImageBuffer == NULL)
return 0;
Synchronized sync(m_protectedImageSem);
Priv_ReadJPEGString_C(imaqImage,
(unsigned char*)m_protectedImageBuffer, m_protectedImageSize);
m_freshImage = false;
return 1;
}
/**
* Get an image from the camera and store it in the provided image.
* @param image The image to store the result in. This must be an HSL or RGB image
* @return 1 upon success, zero on a failure
*/
int AxisCamera::GetImage(ImageBase* image)
{
return GetImage(image->GetImaqImage());
}
/**
* Instantiate a new image object and fill it with the latest image from the camera.
*
* The returned pointer is owned by the caller and is their responsibility to delete.
* @return a pointer to an HSLImage object
*/
ImageBase* AxisCamera::GetImage()
{
ImageBase *image = new ImageBase(IMAQ_IMAGE_RGB);
GetImage(image);
return image;
}
/**
* Copy an image into an existing buffer.
* This copies an image into an existing buffer rather than creating a new image
* in memory. That way a new image is only allocated when the image being copied is
* larger than the destination.
* This method is called by the PCVideoServer class.
* @param imageData The destination image.
* @param numBytes The size of the destination image.
* @return 0 if failed (no source image or no memory), 1 if success.
*/
int AxisCamera::CopyJPEG(char **destImage, int &destImageSize, int &destImageBufferSize)
{
Synchronized sync(m_protectedImageSem);
wpi_assert(destImage != NULL);
if (m_protectedImageBuffer == NULL) return 0; // if no source image
if (destImageBufferSize < m_protectedImageSize) // if current destination buffer too small
{
if (*destImage != NULL) delete [] *destImage;
destImageBufferSize = m_protectedImageSize + kImageBufferAllocationIncrement;
*destImage = new char[destImageBufferSize];
if (*destImage == NULL) return 0;
}
// copy this image into destination buffer
wpi_assert(*destImage != NULL);
wpi_assert(m_protectedImageBuffer != NULL);
wpi_assert(m_protectedImageSize > 0);
// TODO: Is this copy realy necessary... perhaps we can simply transmit while holding the protected buffer
memcpy(*destImage, m_protectedImageBuffer, m_protectedImageSize);
destImageSize = m_protectedImageSize;
return 1;
}
/**
* Static interface that will cause an instantiation if necessary.
* This static stub is directly spawned as a task to read images from the camera.
*/
int AxisCamera::s_ImageStreamTaskFunction(AxisCamera *thisPtr)
{
return thisPtr->ImageStreamTaskFunction();
}
/**
* Task spawned by AxisCamera constructor to receive images from cam
* If setNewImageSem has been called, this function does a semGive on each new image
* Images can be accessed by calling getImage()
*/
int AxisCamera::ImageStreamTaskFunction()
{
// Loop on trying to setup the camera connection. This happens in a background
// thread so it shouldn't effect the operation of user programs.
while (1)
{
char * requestString = "GET /mjpg/video.mjpg HTTP/1.1\n\
User-Agent: HTTPStreamClient\n\
Connection: Keep-Alive\n\
Cache-Control: no-cache\n\
Authorization: Basic RlJDOkZSQw==\n\n";
m_cameraSocket = CreateCameraSocket(requestString);
if (m_cameraSocket == 0)
{
// Don't hammer the camera if it isn't ready.
taskDelay(1000);
continue;
}
ReadImagesFromCamera();
}
}
/**
* This function actually reads the images from the camera.
*/
int AxisCamera::ReadImagesFromCamera()
{
char *imgBuffer = NULL;
int imgBufferLength = 0;
//Infinite loop, task deletion handled by taskDeleteHook
// Socket cleanup handled by destructor
// TODO: these recv calls must be non-blocking. Otherwise if the camera
// fails during a read, the code hangs and never retries when the camera comes
// back up.
int counter = 2;
while (1)
{
char initialReadBuffer[kMaxPacketSize] = "";
char intermediateBuffer[1];
char *trailingPtr = initialReadBuffer;
int trailingCounter = 0;
while (counter)
{
// TODO: fix me... this cannot be the most efficient way to approach this, reading one byte at a time.
if(recv(m_cameraSocket, intermediateBuffer, 1, 0) == ERROR)
{
perror ("AxisCamera: Failed to read image header");
close (m_cameraSocket);
return (ERROR);
}
strncat(initialReadBuffer, intermediateBuffer, 1);
// trailingCounter ensures that we start looking for the 4 byte string after
// there is at least 4 bytes total. Kind of obscure.
// look for 2 blank lines (\r\n)
if (NULL != strstr(trailingPtr, "\r\n\r\n"))
{
--counter;
}
if (++trailingCounter >= 4)
{
trailingPtr++;
}
}
counter = 1;
char *contentLength = strstr(initialReadBuffer, "Content-Length: ");
if (contentLength == NULL)
{
perror("AxisCamera: No content-length token found in packet");
close(m_cameraSocket);
return(ERROR);
}
contentLength = contentLength + 16; // skip past "content length"
int readLength = atol(contentLength); // get the image byte count
// Make sure buffer is large enough
if (imgBufferLength < readLength)
{
if (imgBuffer) delete[] imgBuffer;
imgBufferLength = readLength + kImageBufferAllocationIncrement;
imgBuffer = new char[imgBufferLength];
if (imgBuffer == NULL)
{
imgBufferLength = 0;
continue;
}
}
// Read the image data for "Content-Length" bytes
int bytesRead = 0;
int remaining = readLength;
while(bytesRead < readLength)
{
int bytesThisRecv = recv(m_cameraSocket, &imgBuffer[bytesRead], remaining, 0);
bytesRead += bytesThisRecv;
remaining -= bytesThisRecv;
}
// Update image
UpdatePublicImageFromCamera(imgBuffer, readLength);
}
}
/**
* Copy the image from private buffer to shared buffer.
* @param imgBuffer The buffer containing the image
* @param bufLength The length of the image
*/
void AxisCamera::UpdatePublicImageFromCamera(char *imgBuffer, int imgSize)
{
{
Synchronized sync(m_protectedImageSem);
// Adjust the buffer size if current destination buffer is too small.
if (m_protectedImageBufferLength < imgSize)
{
if (m_protectedImageBuffer != NULL) delete [] m_protectedImageBuffer;
m_protectedImageBufferLength = imgSize + kImageBufferAllocationIncrement;
m_protectedImageBuffer = new char[m_protectedImageBufferLength];
if (m_protectedImageBuffer == NULL)
{
m_protectedImageBufferLength = 0;
return;
}
}
memcpy(m_protectedImageBuffer, imgBuffer, imgSize);
m_protectedImageSize = imgSize;
}
m_freshImage = true;
// Notify everyone who is interested.
SemSet_t::iterator it = m_newImageSemSet.begin();
SemSet_t::iterator end = m_newImageSemSet.end();
for (;it != end; it++)
{
semGive(*it);
}
}
/**
* Implement the pure virtual interface so that when parameter changes require a restart, the image task can be bounced.
*/
void AxisCamera::RestartCameraTask()
{
m_imageStreamTask.Stop();
m_imageStreamTask.Start((int)this);
}
// C bindings used by Java
// These need to stay as is or Java has to change
void AxisCameraStart()
{
AxisCamera::GetInstance();
}
int AxisCameraGetImage (Image* image)
{
return AxisCamera::GetInstance().GetImage(image);
}
void AxisCameraWriteBrightness(int brightness)
{
AxisCamera::GetInstance().WriteBrightness(brightness);
}
int AxisCameraGetBrightness()
{
return AxisCamera::GetInstance().GetBrightness();
}
void AxisCameraWriteWhiteBalance(AxisCameraParams::WhiteBalance_t whiteBalance)
{
AxisCamera::GetInstance().WriteWhiteBalance(whiteBalance);
}
AxisCameraParams::WhiteBalance_t AxisCameraGetWhiteBalance()
{
return AxisCamera::GetInstance().GetWhiteBalance();
}
void AxisCameraWriteColorLevel(int colorLevel)
{
AxisCamera::GetInstance().WriteColorLevel(colorLevel);
}
int AxisCameraGetColorLevel()
{
return AxisCamera::GetInstance().GetColorLevel();
}
void AxisCameraWriteExposureControl(AxisCameraParams::Exposure_t exposure)
{
AxisCamera::GetInstance().WriteExposureControl(exposure);
}
AxisCameraParams::Exposure_t AxisCameraGetExposureControl()
{
return AxisCamera::GetInstance().GetExposureControl();
}
void AxisCameraWriteExposurePriority(int exposure)
{
AxisCamera::GetInstance().WriteExposurePriority(exposure);
}
int AxisCameraGetExposurePriority()
{
return AxisCamera::GetInstance().GetExposurePriority();
}
void AxisCameraWriteMaxFPS(int maxFPS)
{
AxisCamera::GetInstance().WriteMaxFPS(maxFPS);
}
int AxisCameraGetMaxFPS()
{
return AxisCamera::GetInstance().GetMaxFPS();
}
void AxisCameraWriteResolution(AxisCameraParams::Resolution_t resolution)
{
AxisCamera::GetInstance().WriteResolution(resolution);
}
AxisCameraParams::Resolution_t AxisCameraGetResolution()
{
return AxisCamera::GetInstance().GetResolution();
}
void AxisCameraWriteCompression(int compression)
{
AxisCamera::GetInstance().WriteCompression(compression);
}
int AxisCameraGetCompression()
{
return AxisCamera::GetInstance().GetCompression();
}
void AxisCameraWriteRotation(AxisCameraParams::Rotation_t rotation)
{
AxisCamera::GetInstance().WriteRotation(rotation);
}
AxisCameraParams::Rotation_t AxisCameraGetRotation()
{
return AxisCamera::GetInstance().GetRotation();
}
void AxisCameraDeleteInstance()
{
AxisCamera::GetInstance().DeleteInstance();
}
int AxisCameraFreshImage()
{
return AxisCamera::GetInstance().IsFreshImage();
}
Edit2: Array.cpp is all comments Last edited by byteit101 : 26-02-2010 at 15:23. |
|
#11
|
|||
|
|||
|
Re: replace WPILib part
try a make clean. the writers of WPILib have been having compiler troubles too apparently and a clean seemed to help it
|
|
#12
|
||||
|
||||
|
Re: replace WPILib part
rebuild is a clean, build all in one. I tried multiple times, but no luck. I did get it working by commenting out AxisCamera.h in the includes, but this is sub-optimal because it effects all the projects. I have not had any issues with PCVideoServer, although I have not made any changes to the API/H file. I did change the API for AxixCamera, but it compiled for a while before dying
|
|
#13
|
|||
|
|||
|
Re: replace WPILib part
To answer the original question: when you pull the source for a library file into your project, DON"T DELETE ANYTHING. What happens when you delete something is this: somewhere (doesn't have to be in anything you did) there is likely to be a reference to the thing(s) you delete. The linker notices the references to your new stuff and pulls your new object file in. Then it notices that there is a reference to this something that is satisfied by the original object file in the library and pulls it in too. You get double definitions for the things that appear in both.
The bit about being somewhat correct about inline functions is a dig. It is absolutely correct that you can't just add inline to function declarations - you have to move the body of the function to where it is declared. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| can we replace the joystick with a steering? | mahmosh | Technical Discussion | 2 | 25-01-2009 19:08 |
| Could this replace the Segway? | Wayne Doenges | Chit-Chat | 1 | 01-05-2008 11:01 |
| A warning regarding MPLAB and find/replace | Tom Line | Programming | 0 | 24-01-2008 17:35 |
| REPLACE VEX with us | bill mc gowan | General Forum | 20 | 23-03-2006 11:12 |
| Call me Steve Irwin... 'cept replace the crocs with bats... | Mini-D67 | Chit-Chat | 7 | 14-12-2004 21:52 |