very questionable code

This commit is contained in:
rusefillc 2024-01-12 22:36:30 -05:00
parent 5bfc8e4c4c
commit 8370f2a253
2 changed files with 23 additions and 15 deletions

View File

@ -0,0 +1,6 @@
package peak.can.basic;
public class HackLoadLibraryFlag {
// control if library should be auto-loaded or not
public static boolean LOAD_LIBRARY = true;
}

View File

@ -2,7 +2,7 @@
/* /*
* $Id: PCANBasic.java 12274 2021-08-30 12:20:04Z Fabrice $ * $Id: PCANBasic.java 12274 2021-08-30 12:20:04Z Fabrice $
* @LastChange $Date: 2021-08-30 14:20:04 +0200 (Mon, 30 Aug 2021) $ * @LastChange $Date: 2021-08-30 14:20:04 +0200 (Mon, 30 Aug 2021) $
* *
* PCANBasic JAVA Interface. * PCANBasic JAVA Interface.
* *
* Copyright (C) 2001-2021 PEAK System-Technik GmbH <www.peak-system.com> * Copyright (C) 2001-2021 PEAK System-Technik GmbH <www.peak-system.com>
@ -156,7 +156,7 @@ public class PCANBasic {
*/ */
public native TPCANStatus Reset( public native TPCANStatus Reset(
TPCANHandle Channel); TPCANHandle Channel);
/** /**
* Gets the current status of a PCAN Channel * Gets the current status of a PCAN Channel
* *
@ -165,7 +165,7 @@ public class PCANBasic {
*/ */
public native TPCANStatus GetStatus( public native TPCANStatus GetStatus(
TPCANHandle Channel); TPCANHandle Channel);
/** /**
* Transmits a CAN message * Transmits a CAN message
* *
@ -180,7 +180,7 @@ public class PCANBasic {
TPCANHandle Channel, TPCANHandle Channel,
TPCANMsg MessageBuffer, TPCANMsg MessageBuffer,
TPCANTimestamp TimestampBuffer); TPCANTimestamp TimestampBuffer);
/** /**
* Reads a CAN message from the receive queue of a FD capable PCAN Channel * Reads a CAN message from the receive queue of a FD capable PCAN Channel
* *
@ -195,7 +195,7 @@ public class PCANBasic {
TPCANHandle Channel, TPCANHandle Channel,
TPCANMsgFD MessageBuffer, TPCANMsgFD MessageBuffer,
TPCANTimestampFD TimestampBuffer); TPCANTimestampFD TimestampBuffer);
/** /**
* Transmits a CAN message * Transmits a CAN message
* *
@ -206,7 +206,7 @@ public class PCANBasic {
public native TPCANStatus Write( public native TPCANStatus Write(
TPCANHandle Channel, TPCANHandle Channel,
TPCANMsg MessageBuffer); TPCANMsg MessageBuffer);
/** /**
* Transmits a CAN message over a FD capable PCAN Channel * Transmits a CAN message over a FD capable PCAN Channel
* *
@ -217,7 +217,7 @@ public class PCANBasic {
public native TPCANStatus WriteFD( public native TPCANStatus WriteFD(
TPCANHandle Channel, TPCANHandle Channel,
TPCANMsgFD MessageBuffer); TPCANMsgFD MessageBuffer);
/** /**
* Configures the reception filter. The message filter will be expanded with * Configures the reception filter. The message filter will be expanded with
* every call to this function. If it is desired to reset the filter, please * every call to this function. If it is desired to reset the filter, please
@ -235,7 +235,7 @@ public class PCANBasic {
int FromID, int FromID,
int ToID, int ToID,
TPCANMode Mode); TPCANMode Mode);
/** /**
* Retrieves a PCAN Channel value Parameters can be present or not according * Retrieves a PCAN Channel value Parameters can be present or not according
* with the kind of Hardware (PCAN Channel) being used. If a parameter is * with the kind of Hardware (PCAN Channel) being used. If a parameter is
@ -252,7 +252,7 @@ public class PCANBasic {
TPCANParameter Parameter, TPCANParameter Parameter,
Object Buffer, Object Buffer,
int BufferLength); int BufferLength);
/** /**
* Configures or sets a PCAN Channel value Parameters can be present or not * Configures or sets a PCAN Channel value Parameters can be present or not
* according with the kind of Hardware (PCAN Channel) being used. If a * according with the kind of Hardware (PCAN Channel) being used. If a
@ -296,7 +296,7 @@ public class PCANBasic {
* @return A TPCANStatus error code * @return A TPCANStatus error code
*/ */
public native TPCANStatus LookUpChannel( public native TPCANStatus LookUpChannel(
StringBuffer Parameters, StringBuffer Parameters,
MutableTPCANHandle FoundChannel); MutableTPCANHandle FoundChannel);
/** /**
@ -325,11 +325,13 @@ public class PCANBasic {
public native boolean initializeAPI(); public native boolean initializeAPI();
static { static {
try { if (HackLoadLibraryFlag.LOAD_LIBRARY) {
System.loadLibrary("pcanbasic_jni"); try {
} catch (UnsatisfiedLinkError e) { System.loadLibrary("pcanbasic_jni");
System.out.println(e.getMessage()); } catch (UnsatisfiedLinkError e) {
System.loadLibrary("PCANBasic_JNI"); System.out.println(e.getMessage());
System.loadLibrary("PCANBasic_JNI");
}
} }
} }
} }