Commit 6a9060b9 authored by Don Gagne's avatar Don Gagne

parent ea63d012
......@@ -69,7 +69,7 @@ public class QGCActivity extends QtActivity
private static UsbManager _usbManager = null;
private static List<UsbSerialDriver> _drivers;
private static HashMap<Integer, UsbIoManager> m_ioManager;
private static HashMap<Integer, Integer> _userDataHashByDeviceId;
private static HashMap<Integer, Long> _userDataHashByDeviceId;
private static final String TAG = "QGC_QGCActivity";
private static PowerManager.WakeLock _wakeLock;
private static final String ACTION_USB_PERMISSION = "org.mavlink.qgroundcontrol.action.USB_PERMISSION";
......@@ -85,14 +85,14 @@ public class QGCActivity extends QtActivity
new UsbIoManager.Listener()
{
@Override
public void onRunError(Exception eA, int userData)
public void onRunError(Exception eA, long userData)
{
Log.e(TAG, "onRunError Exception");
nativeDeviceException(userData, eA.getMessage());
}
@Override
public void onNewData(final byte[] dataA, int userData)
public void onNewData(final byte[] dataA, long userData)
{
nativeDeviceNewData(userData, dataA);
}
......@@ -174,9 +174,9 @@ public class QGCActivity extends QtActivity
};
// Native C++ functions which connect back to QSerialPort code
private static native void nativeDeviceHasDisconnected(int userData);
private static native void nativeDeviceException(int userData, String messageA);
private static native void nativeDeviceNewData(int userData, byte[] dataA);
private static native void nativeDeviceHasDisconnected(long userData);
private static native void nativeDeviceException(long userData, String messageA);
private static native void nativeDeviceNewData(long userData, byte[] dataA);
private static native void nativeUpdateAvailableJoysticks();
// Native C++ functions called to log output
......@@ -190,7 +190,7 @@ public class QGCActivity extends QtActivity
{
_instance = this;
_drivers = new ArrayList<UsbSerialDriver>();
_userDataHashByDeviceId = new HashMap<Integer, Integer>();
_userDataHashByDeviceId = new HashMap<Integer, Long>();
m_ioManager = new HashMap<Integer, UsbIoManager>();
}
......@@ -375,7 +375,7 @@ public class QGCActivity extends QtActivity
/// Open the specified device
/// @param userData Data to associate with device and pass back through to native calls.
/// @return Device id
public static int open(Context parentContext, String deviceName, int userData)
public static int open(Context parentContext, String deviceName, long userData)
{
int deviceId = BAD_DEVICE_ID;
......
......@@ -40,7 +40,7 @@ public class UsbIoManager implements Runnable {
private static final String TAG = "QGC_UsbIoManager";
private final UsbSerialDriver mDriver;
private int mUserData;
private long mUserData;
private final ByteBuffer mReadBuffer = ByteBuffer.allocate(BUFSIZ);
private final ByteBuffer mWriteBuffer = ByteBuffer.allocate(BUFSIZ);
......@@ -62,13 +62,13 @@ public class UsbIoManager implements Runnable {
/**
* Called when new incoming data is available.
*/
public void onNewData(byte[] data, int userData);
public void onNewData(byte[] data, long userData);
/**
* Called when {@link SerialInputOutputManager#run()} aborts due to an
* error.
*/
public void onRunError(Exception e, int userData);
public void onRunError(Exception e, long userData);
}
......@@ -87,7 +87,7 @@ public class UsbIoManager implements Runnable {
/**
* Creates a new instance with the provided listener.
*/
public UsbIoManager(UsbSerialDriver driver, Listener listener, int userData)
public UsbIoManager(UsbSerialDriver driver, Listener listener, long userData)
{
mDriver = driver;
mListener = listener;
......
......@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
static const char kJniClassName[] {"org/mavlink/qgroundcontrol/QGCActivity"};
static void jniDeviceHasDisconnected(JNIEnv *envA, jobject thizA, jint userDataA)
static void jniDeviceHasDisconnected(JNIEnv *envA, jobject thizA, jlong userDataA)
{
Q_UNUSED(envA);
Q_UNUSED(thizA);
......@@ -64,7 +64,7 @@ static void jniDeviceHasDisconnected(JNIEnv *envA, jobject thizA, jint userDataA
(reinterpret_cast<QSerialPortPrivate*>(userDataA))->q_ptr->close();
}
static void jniDeviceNewData(JNIEnv *envA, jobject thizA, jint userDataA, jbyteArray dataA)
static void jniDeviceNewData(JNIEnv *envA, jobject thizA, jlong userDataA, jbyteArray dataA)
{
Q_UNUSED(thizA);
if (userDataA != 0)
......@@ -76,7 +76,7 @@ static void jniDeviceNewData(JNIEnv *envA, jobject thizA, jint userDataA, jbyteA
}
}
static void jniDeviceException(JNIEnv *envA, jobject thizA, jint userDataA, jstring messageA)
static void jniDeviceException(JNIEnv *envA, jobject thizA, jlong userDataA, jstring messageA)
{
Q_UNUSED(thizA);
if(userDataA != 0)
......@@ -143,9 +143,9 @@ void QSerialPortPrivate::setNativeMethods(void)
// REGISTER THE C++ FUNCTION WITH JNI
JNINativeMethod javaMethods[] {
{"nativeDeviceHasDisconnected", "(I)V", reinterpret_cast<void *>(jniDeviceHasDisconnected)},
{"nativeDeviceNewData", "(I[B)V", reinterpret_cast<void *>(jniDeviceNewData)},
{"nativeDeviceException", "(ILjava/lang/String;)V", reinterpret_cast<void *>(jniDeviceException)},
{"nativeDeviceHasDisconnected", "(J)V", reinterpret_cast<void *>(jniDeviceHasDisconnected)},
{"nativeDeviceNewData", "(J[B)V", reinterpret_cast<void *>(jniDeviceNewData)},
{"nativeDeviceException", "(JLjava/lang/String;)V", reinterpret_cast<void *>(jniDeviceException)},
{"qgcLogDebug", "(Ljava/lang/String;)V", reinterpret_cast<void *>(jniLogDebug)},
{"qgcLogWarning", "(Ljava/lang/String;)V", reinterpret_cast<void *>(jniLogWarning)}
};
......@@ -186,10 +186,10 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
deviceId = QAndroidJniObject::callStaticMethod<jint>(
kJniClassName,
"open",
"(Landroid/content/Context;Ljava/lang/String;I)I",
"(Landroid/content/Context;Ljava/lang/String;J)I",
QtAndroid::androidActivity().object(),
jnameL.object<jstring>(),
reinterpret_cast<jint>(this));
reinterpret_cast<jlong>(this));
cleanJavaException();
isReadStopped = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment