unclebob
2016-04-19 07:16:27 UTC
I'm attempting to write a tether in Java, but while the new file event is
triggered correctly, I can't seem to get any data back from it, neither the
eventtype nor the eventdata.
Here's what my JNA binding looks like:
int gp_camera_wait_for_event(Camera camera, int timeout, IntBuffer
eventtype, PointerByReference eventdata, Gphoto2Library.GPContext context);
The code using it looks as follows:
PointerByReference eventdata = new PointerByReference();
IntBuffer eventtype = IntBuffer.allocate(1);
int result = gphoto2.gp_camera_wait_for_event(camera, 1000000000,
eventtype, eventdata, context); //result is always 0, OK
int test = eventtype.get(); //just testing what I got back. test is
always 0, with which it was initialised
CameraFilePath filepath = new CameraFilePath(eventdata.getValue());
//filepath never contains anything
And for completeness, the CameraFilePath Structure (which works without a
hitch when used with gp_camera_capture):
public class CameraFilePath extends Structure
{
/**
* < \brief Name of the captured file.<br>
* C type : char[128]
*/
public byte[] name = new byte[128];
/**
* < \brief Name of the folder of the captured file.<br>
* C type : char[1024]
*/
public byte[] folder = new byte[1024];
public CameraFilePath()
{
super();
}
@Override
protected List getFieldOrder()
{
return Arrays.asList(new String[]{"name", "folder"});
};
/**
* @param name < \brief Name of the captured file.<br>
* C type : char[128]<br>
* @param folder < \brief Name of the folder of the captured file.<br>
* C type : char[1024]
*/
public CameraFilePath(byte name[], byte folder[]) {
super();
if (name.length != this.name.length)
throw new IllegalArgumentException("Wrong array size !");
this.name = name;
if (folder.length != this.folder.length)
throw new IllegalArgumentException("Wrong array size !");
this.folder = folder;
}
public CameraFilePath(Pointer pointer)
{
super(pointer);
}
public static class ByReference extends CameraFilePath implements
Structure.ByReference {
};
public static class ByValue extends CameraFilePath implements
Structure.ByValue {
};
}
I'm still somwhat clumsy in JNA, but for all I know, this should work... ?
Test Camera is Nikon D5300, just in case that might have an influence.
--
View this message in context: http://gphoto-software.10949.n7.nabble.com/gp-camera-wait-for-event-and-JNA-no-data-returned-tp16144.html
Sent from the gphoto-devel mailing list archive at Nabble.com.
triggered correctly, I can't seem to get any data back from it, neither the
eventtype nor the eventdata.
Here's what my JNA binding looks like:
int gp_camera_wait_for_event(Camera camera, int timeout, IntBuffer
eventtype, PointerByReference eventdata, Gphoto2Library.GPContext context);
The code using it looks as follows:
PointerByReference eventdata = new PointerByReference();
IntBuffer eventtype = IntBuffer.allocate(1);
int result = gphoto2.gp_camera_wait_for_event(camera, 1000000000,
eventtype, eventdata, context); //result is always 0, OK
int test = eventtype.get(); //just testing what I got back. test is
always 0, with which it was initialised
CameraFilePath filepath = new CameraFilePath(eventdata.getValue());
//filepath never contains anything
And for completeness, the CameraFilePath Structure (which works without a
hitch when used with gp_camera_capture):
public class CameraFilePath extends Structure
{
/**
* < \brief Name of the captured file.<br>
* C type : char[128]
*/
public byte[] name = new byte[128];
/**
* < \brief Name of the folder of the captured file.<br>
* C type : char[1024]
*/
public byte[] folder = new byte[1024];
public CameraFilePath()
{
super();
}
@Override
protected List getFieldOrder()
{
return Arrays.asList(new String[]{"name", "folder"});
};
/**
* @param name < \brief Name of the captured file.<br>
* C type : char[128]<br>
* @param folder < \brief Name of the folder of the captured file.<br>
* C type : char[1024]
*/
public CameraFilePath(byte name[], byte folder[]) {
super();
if (name.length != this.name.length)
throw new IllegalArgumentException("Wrong array size !");
this.name = name;
if (folder.length != this.folder.length)
throw new IllegalArgumentException("Wrong array size !");
this.folder = folder;
}
public CameraFilePath(Pointer pointer)
{
super(pointer);
}
public static class ByReference extends CameraFilePath implements
Structure.ByReference {
};
public static class ByValue extends CameraFilePath implements
Structure.ByValue {
};
}
I'm still somwhat clumsy in JNA, but for all I know, this should work... ?
Test Camera is Nikon D5300, just in case that might have an influence.
--
View this message in context: http://gphoto-software.10949.n7.nabble.com/gp-camera-wait-for-event-and-JNA-no-data-returned-tp16144.html
Sent from the gphoto-devel mailing list archive at Nabble.com.