View Single Post
  #3   Spotlight this post!  
Unread 28-12-2010, 11:22
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Native C string (char*) to java String

Quote:
Originally Posted by derekwhite View Post
I don't see a killer bug, but there is one thing to clean up.

1) Each call to Pointer.createStringBuffer() essentially "mallocs" a new C string buffer, so you typically need to free it after calling the C function (unless the C code stashes the value somewhere to use later). To fix this, create a local Pointer variable, say "ptr", and call ptr.free() after the call out to C.

Also, I'm not sure what died, and what the symptoms are. Something on the cRIO or the driver station?

And I couldn't find the C code for ZomBDashboardGetString(), etc. Is it in the svn somewhere?

Good luck!
I'm not sure about what died either (Netbeans won't connect and send me print statements), but I do know that this code (in teleop code):
Code:
zombinstance.Send("taco", joystick.GetY());
works, and any controls hooked up to taco work, but this code
Code:
zombinstance.Send("taco", joystick.GetY());
zombinstance.Send("value", zombinstance.GetString("invalue"));
does not, and all controls are dead, which leads me to assume that it kills Java somehow (but the DS still says Enabled and code) (and If I only execute the GetString function if a button is pressed, it dies when the button is pressed)

The h file should be in C:\Program files\ZomB\Bindings\ (or Start>Programs>ZomB>Bindings) and the cpp file is compiled into ZomB.out, but you can see it in svn (\releasefiles\bindings\source), but I've attached both
Attached Files
File Type: cpp ZDashboard.cpp (22.8 KB, 17 views)
File Type: h ZDashboard.h (8.2 KB, 11 views)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote