mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-09 05:10:05 +02:00
150 lines
6.0 KiB
Plaintext
150 lines
6.0 KiB
Plaintext
From 7bebc162b89afe4db9b8253a80441d4a567d9912 Mon Sep 17 00:00:00 2001
|
|
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
|
Date: Tue, 28 Jun 2022 22:32:41 +1000
|
|
Subject: Add haiku support for jssc
|
|
|
|
|
|
diff --git a/src/cpp/_nix_based/jssc.cpp b/src/cpp/_nix_based/jssc.cpp
|
|
index 634b620..362fd9e 100644
|
|
--- a/src/cpp/_nix_based/jssc.cpp
|
|
+++ b/src/cpp/_nix_based/jssc.cpp
|
|
@@ -42,7 +42,9 @@
|
|
#ifdef __APPLE__
|
|
#include <serial/ioss.h>//Needed for IOSSIOSPEED in Mac OS X (Non standard baudrate)
|
|
#endif
|
|
-
|
|
+#ifdef __HAIKU__
|
|
+ #define TIOCM_RNG 0x04
|
|
+#endif
|
|
#include <jni.h>
|
|
#include "../jssc_SerialNativeInterface.h"
|
|
|
|
@@ -560,7 +562,9 @@ JNIEXPORT jintArray JNICALL Java_jssc_SerialNativeInterface_getBuffersBytesCount
|
|
returnValues[1] = -1; //Output buffer
|
|
jintArray returnArray = env->NewIntArray(2);
|
|
ioctl(portHandle, FIONREAD, &returnValues[0]);
|
|
+#ifndef __HAIKU__
|
|
ioctl(portHandle, TIOCOUTQ, &returnValues[1]);
|
|
+#endif
|
|
env->SetIntArrayRegion(returnArray, 0, 2, returnValues);
|
|
return returnArray;
|
|
}
|
|
@@ -692,6 +696,9 @@ const jint INTERRUPT_PARITY = 8192;
|
|
|
|
const jint EV_CTS = 8;
|
|
const jint EV_DSR = 16;
|
|
+#ifdef __HAIKU__
|
|
+#undef EV_RING
|
|
+#endif
|
|
const jint EV_RING = 256;
|
|
const jint EV_RLSD = 32;
|
|
const jint EV_RXCHAR = 1;
|
|
@@ -727,8 +734,9 @@ JNIEXPORT jobjectArray JNICALL Java_jssc_SerialNativeInterface_waitEvents
|
|
|
|
/*Output buffer*/
|
|
jint bytesCountOut = 0;
|
|
+#ifndef __HAIKU__
|
|
ioctl(portHandle, TIOCOUTQ, &bytesCountOut);
|
|
-
|
|
+#endif
|
|
/*Lines status*/
|
|
int statusLines = getLinesStatus(portHandle);
|
|
|
|
diff --git a/src/cpp/jssc_SerialNativeInterface.h b/src/cpp/jssc_SerialNativeInterface.h
|
|
index 7029b1b..fcd7bb2 100644
|
|
--- a/src/cpp/jssc_SerialNativeInterface.h
|
|
+++ b/src/cpp/jssc_SerialNativeInterface.h
|
|
@@ -43,6 +43,8 @@ extern "C" {
|
|
#define jssc_SerialNativeInterface_OS_SOLARIS 2L
|
|
#undef jssc_SerialNativeInterface_OS_MAC_OS_X
|
|
#define jssc_SerialNativeInterface_OS_MAC_OS_X 3L
|
|
+#undef jssc_SerialNativeInterface_OS_HAIKU
|
|
+#define jssc_SerialNativeInterface_OS_HAIKU 4L
|
|
#undef jssc_SerialNativeInterface_ERR_PORT_BUSY
|
|
#define jssc_SerialNativeInterface_ERR_PORT_BUSY -1LL
|
|
#undef jssc_SerialNativeInterface_ERR_PORT_NOT_FOUND
|
|
diff --git a/src/java/jssc/SerialNativeInterface.java b/src/java/jssc/SerialNativeInterface.java
|
|
index c5264f5..8ded600 100644
|
|
--- a/src/java/jssc/SerialNativeInterface.java
|
|
+++ b/src/java/jssc/SerialNativeInterface.java
|
|
@@ -43,6 +43,7 @@ public class SerialNativeInterface {
|
|
public static final int OS_WINDOWS = 1;
|
|
public static final int OS_SOLARIS = 2;//since 0.9.0
|
|
public static final int OS_MAC_OS_X = 3;//since 0.9.0
|
|
+ public static final int OS_HAIKU = 4;//since 0.9.0
|
|
|
|
private static int osType = -1;
|
|
|
|
@@ -87,7 +88,12 @@ public class SerialNativeInterface {
|
|
String tmpFolder = System.getProperty("java.io.tmpdir");
|
|
|
|
//since 2.3.0 ->
|
|
- String libRootFolder = new File(userHome).canWrite() ? userHome : tmpFolder;
|
|
+ String libRootFolder;
|
|
+ if(osName.equals("Haiku")){
|
|
+ libRootFolder = tmpFolder;
|
|
+ } else {
|
|
+ libRootFolder = new File(userHome).canWrite() ? userHome : tmpFolder;
|
|
+ }
|
|
//<- since 2.3.0
|
|
|
|
String javaLibPath = System.getProperty("java.library.path");//since 2.1.0
|
|
@@ -104,6 +110,10 @@ public class SerialNativeInterface {
|
|
osName = "solaris";
|
|
osType = OS_SOLARIS;
|
|
}
|
|
+ else if(osName.equals("Haiku")){
|
|
+ osName = "haiku";
|
|
+ osType = OS_HAIKU;
|
|
+ }
|
|
else if(osName.equals("Mac OS X") || osName.equals("Darwin")){//os.name "Darwin" since 2.6.0
|
|
osName = "mac_os_x";
|
|
osType = OS_MAC_OS_X;
|
|
diff --git a/src/java/jssc/SerialPort.java b/src/java/jssc/SerialPort.java
|
|
index e5f43b4..8a1149e 100644
|
|
--- a/src/java/jssc/SerialPort.java
|
|
+++ b/src/java/jssc/SerialPort.java
|
|
@@ -264,6 +264,7 @@ public class SerialPort {
|
|
checkPortOpened("setEventsMask()");
|
|
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX ||
|
|
SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS ||
|
|
+ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_HAIKU ||
|
|
SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X){//since 0.9.0
|
|
linuxMask = mask;
|
|
if(mask > 0){
|
|
@@ -298,6 +299,7 @@ public class SerialPort {
|
|
checkPortOpened("getEventsMask()");
|
|
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX ||
|
|
SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS ||
|
|
+ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_HAIKU ||
|
|
SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X){//since 0.9.0
|
|
return linuxMask;
|
|
}
|
|
@@ -1041,6 +1043,7 @@ public class SerialPort {
|
|
private EventThread getNewEventThread() {
|
|
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX ||
|
|
SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS ||
|
|
+ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_HAIKU ||
|
|
SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X){//since 0.9.0
|
|
return new LinuxEventThread();
|
|
}
|
|
diff --git a/src/java/jssc/SerialPortList.java b/src/java/jssc/SerialPortList.java
|
|
index 5af9a95..87a7ee4 100644
|
|
--- a/src/java/jssc/SerialPortList.java
|
|
+++ b/src/java/jssc/SerialPortList.java
|
|
@@ -47,6 +47,11 @@ public class SerialPortList {
|
|
PORTNAMES_PATH = "/dev/";
|
|
break;
|
|
}
|
|
+ case SerialNativeInterface.OS_HAIKU: {
|
|
+ PORTNAMES_REGEXP = Pattern.compile("(pc_serial|usb|serial)[0-9]{1,3}");
|
|
+ PORTNAMES_PATH = "/dev/ports";
|
|
+ break;
|
|
+ }
|
|
case SerialNativeInterface.OS_SOLARIS: {
|
|
PORTNAMES_REGEXP = Pattern.compile("[0-9]*|[a-z]*");
|
|
PORTNAMES_PATH = "/dev/term/";
|
|
--
|
|
2.36.1
|
|
|