- redirect before creating other classes
git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@85 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
BIN
JNIdll/BDI.dll
BIN
JNIdll/BDI.dll
Binary file not shown.
@@ -196,7 +196,29 @@ EXPORT int createJVM(char *classpath)
|
|||||||
}
|
}
|
||||||
jvm_created = TRUE;
|
jvm_created = TRUE;
|
||||||
} else {
|
} else {
|
||||||
fprintf_flush(stdout, "JVM already created -> creating class pointers\n");
|
fprintf_flush(stdout, "JVM already created -> trying to redirect ouput streams\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jvm_redirection_done) {
|
||||||
|
cls_Redirect = env->FindClass(Redirect_Class);
|
||||||
|
if (cls_Redirect == 0) {
|
||||||
|
fprintf_flush(stderr, "Can't find %s class\n", Redirect_Class);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect Class
|
||||||
|
mid_Redirect_redirect = env->GetStaticMethodID(cls_Redirect, "redirect", "()V");
|
||||||
|
if (mid_Redirect_redirect == 0) {
|
||||||
|
fprintf_flush(stderr, "Can't find Redirect.redirect\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call redirect
|
||||||
|
env->CallStaticVoidMethod(cls_Redirect, mid_Redirect_redirect);
|
||||||
|
|
||||||
|
jvm_redirection_done = TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf_flush(stdout, "Redirection already done -> creating class pointers\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jvm_classPtrs_done) {
|
if (!jvm_classPtrs_done) {
|
||||||
@@ -219,12 +241,6 @@ EXPORT int createJVM(char *classpath)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cls_Redirect = env->FindClass(Redirect_Class);
|
|
||||||
if (cls_Redirect == 0) {
|
|
||||||
fprintf_flush(stderr, "Can't find %s class\n", Redirect_Class);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cls_Uart0 = env->FindClass(Uart0_Class);
|
cls_Uart0 = env->FindClass(Uart0_Class);
|
||||||
if (cls_Uart0 == 0) {
|
if (cls_Uart0 == 0) {
|
||||||
fprintf_flush(stderr, "Can't find %s class\n", Uart0_Class);
|
fprintf_flush(stderr, "Can't find %s class\n", Uart0_Class);
|
||||||
@@ -464,13 +480,6 @@ EXPORT int createJVM(char *classpath)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect Class
|
|
||||||
mid_Redirect_redirect = env->GetStaticMethodID(cls_Redirect, "redirect", "()V");
|
|
||||||
if (mid_Redirect_redirect == 0) {
|
|
||||||
fprintf_flush(stderr, "Can't find Redirect.redirect\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uart0 Class
|
// Uart0 Class
|
||||||
mid_Uart0_write = env->GetStaticMethodID(cls_Uart0, "write", "([BI)Z");
|
mid_Uart0_write = env->GetStaticMethodID(cls_Uart0, "write", "([BI)Z");
|
||||||
if (mid_Uart0_write == 0) {
|
if (mid_Uart0_write == 0) {
|
||||||
@@ -485,16 +494,7 @@ EXPORT int createJVM(char *classpath)
|
|||||||
|
|
||||||
jvm_mIDs_done = TRUE;
|
jvm_mIDs_done = TRUE;
|
||||||
} else {
|
} else {
|
||||||
fprintf_flush(stdout, "Method IDs already created -> trying to redirect ouput streams\n");
|
fprintf_flush(stdout, "Method IDs already created -> everything successfully set up!\n");
|
||||||
}
|
|
||||||
|
|
||||||
if (!jvm_redirection_done) {
|
|
||||||
// Call redirect
|
|
||||||
env->CallStaticVoidMethod(cls_Redirect, mid_Redirect_redirect);
|
|
||||||
|
|
||||||
jvm_redirection_done = TRUE;
|
|
||||||
} else {
|
|
||||||
fprintf_flush(stdout, "Redirection already done -> everything successfully set up!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -517,7 +517,7 @@ EXPORT int checkForExceptions() {
|
|||||||
|
|
||||||
/* USB_Device methods
|
/* USB_Device methods
|
||||||
*
|
*
|
||||||
* For documentatione see the java doc.
|
* For documentation see the java doc.
|
||||||
*/
|
*/
|
||||||
EXPORT void USB_Device_open()
|
EXPORT void USB_Device_open()
|
||||||
{
|
{
|
||||||
@@ -536,7 +536,7 @@ EXPORT void USB_Device_reset()
|
|||||||
|
|
||||||
/* BDI 555 methods
|
/* BDI 555 methods
|
||||||
*
|
*
|
||||||
* For documentatione see the java doc.
|
* For documentation see the java doc.
|
||||||
*/
|
*/
|
||||||
EXPORT void BDI555_break_()
|
EXPORT void BDI555_break_()
|
||||||
{
|
{
|
||||||
@@ -684,7 +684,7 @@ EXPORT void BDI555_setGpr31(int gpr31)
|
|||||||
|
|
||||||
/* BDI 332 methods
|
/* BDI 332 methods
|
||||||
*
|
*
|
||||||
* For documentatione see the java doc.
|
* For documentation see the java doc.
|
||||||
*/
|
*/
|
||||||
EXPORT void BDI332_nopsToLegalCmd()
|
EXPORT void BDI332_nopsToLegalCmd()
|
||||||
{
|
{
|
||||||
@@ -797,7 +797,7 @@ EXPORT BOOL BDI332_isTargetInDebugMode()
|
|||||||
/*
|
/*
|
||||||
* UART functions
|
* UART functions
|
||||||
*
|
*
|
||||||
* For documentatione see the java doc.
|
* For documentation see the java doc.
|
||||||
*/
|
*/
|
||||||
EXPORT int UART0_read(char result[])
|
EXPORT int UART0_read(char result[])
|
||||||
{
|
{
|
||||||
@@ -830,9 +830,6 @@ EXPORT int UART0_write(char data[], int dataLength)
|
|||||||
env->ThrowNew(excCls, "UART0_write: not enough memory");
|
env->ThrowNew(excCls, "UART0_write: not enough memory");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// for (int i = 0; i < dataLength; ++i) {
|
|
||||||
// fprintf_flush(stdout, ("data %d: %x\n", i, data[i]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
env->SetByteArrayRegion(jdata, 0, dataLength, (jbyte*) data);
|
env->SetByteArrayRegion(jdata, 0, dataLength, (jbyte*) data);
|
||||||
result = env->CallStaticBooleanMethod(cls_Uart0, mid_Uart0_write, jdata, dataLength);
|
result = env->CallStaticBooleanMethod(cls_Uart0, mid_Uart0_write, jdata, dataLength);
|
||||||
|
|||||||
Reference in New Issue
Block a user