Skip to content

Commit

Permalink
very questionable code
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Jan 13, 2024
1 parent 5bfc8e4 commit 8370f2a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
6 changes: 6 additions & 0 deletions src/main/java/peak/can/basic/HackLoadLibraryFlag.java
@@ -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;
}
32 changes: 17 additions & 15 deletions src/main/java/peak/can/basic/PCANBasic.java
Expand Up @@ -2,7 +2,7 @@
/*
* $Id: PCANBasic.java 12274 2021-08-30 12:20:04Z Fabrice $
* @LastChange $Date: 2021-08-30 14:20:04 +0200 (Mon, 30 Aug 2021) $
*
*
* PCANBasic JAVA Interface.
*
* Copyright (C) 2001-2021 PEAK System-Technik GmbH <www.peak-system.com>
Expand Down Expand Up @@ -156,7 +156,7 @@ public native TPCANStatus InitializeFD(
*/
public native TPCANStatus Reset(
TPCANHandle Channel);

/**
* Gets the current status of a PCAN Channel
*
Expand All @@ -165,7 +165,7 @@ public native TPCANStatus Reset(
*/
public native TPCANStatus GetStatus(
TPCANHandle Channel);

/**
* Transmits a CAN message
*
Expand All @@ -180,7 +180,7 @@ public native TPCANStatus Read(
TPCANHandle Channel,
TPCANMsg MessageBuffer,
TPCANTimestamp TimestampBuffer);

/**
* Reads a CAN message from the receive queue of a FD capable PCAN Channel
*
Expand All @@ -195,7 +195,7 @@ public native TPCANStatus ReadFD(
TPCANHandle Channel,
TPCANMsgFD MessageBuffer,
TPCANTimestampFD TimestampBuffer);

/**
* Transmits a CAN message
*
Expand All @@ -206,7 +206,7 @@ public native TPCANStatus ReadFD(
public native TPCANStatus Write(
TPCANHandle Channel,
TPCANMsg MessageBuffer);

/**
* Transmits a CAN message over a FD capable PCAN Channel
*
Expand All @@ -217,7 +217,7 @@ public native TPCANStatus Write(
public native TPCANStatus WriteFD(
TPCANHandle Channel,
TPCANMsgFD MessageBuffer);

/**
* 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
Expand All @@ -235,7 +235,7 @@ public native TPCANStatus FilterMessages(
int FromID,
int ToID,
TPCANMode Mode);

/**
* 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
Expand All @@ -252,7 +252,7 @@ public native TPCANStatus GetValue(
TPCANParameter Parameter,
Object Buffer,
int BufferLength);

/**
* 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
Expand Down Expand Up @@ -296,7 +296,7 @@ public native TPCANStatus GetErrorText(
* @return A TPCANStatus error code
*/
public native TPCANStatus LookUpChannel(
StringBuffer Parameters,
StringBuffer Parameters,
MutableTPCANHandle FoundChannel);

/**
Expand Down Expand Up @@ -325,11 +325,13 @@ public native TPCANStatus LookUpChannel(
public native boolean initializeAPI();

static {
try {
System.loadLibrary("pcanbasic_jni");
} catch (UnsatisfiedLinkError e) {
System.out.println(e.getMessage());
System.loadLibrary("PCANBasic_JNI");
if (HackLoadLibraryFlag.LOAD_LIBRARY) {
try {
System.loadLibrary("pcanbasic_jni");
} catch (UnsatisfiedLinkError e) {
System.out.println(e.getMessage());
System.loadLibrary("PCANBasic_JNI");
}
}
}
}

0 comments on commit 8370f2a

Please sign in to comment.