changeset 91:0500a43b8c22

8071482: Disable open by controllerNumber feature for UART Summary: Java layer: removed dependency on "jdk.dio.uart.port" variable. Native layer: functions for UART ports discovery moved out of the open_jdk repo. Reviewed-by: snazarki Contributed-by: alexey.karaksin@oracle.com
author amironov
date Wed, 28 Jan 2015 15:24:59 +0300
parents ecdc22ce1f87
children 9753293dba56
files src/share/linux/native/com/oracle/dio/uart/serial.c src/share/linux/native/com/oracle/dio/uart/serial.h src/share/native/com/oracle/dio/javacall_serial.h
diffstat 3 files changed, 0 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/linux/native/com/oracle/dio/uart/serial.c	Wed Jan 28 13:32:58 2015 +0300
+++ b/src/share/linux/native/com/oracle/dio/uart/serial.c	Wed Jan 28 15:24:59 2015 +0300
@@ -45,82 +45,6 @@
     }
 }
 
-const char* skipDelimiters(const char* ptr) {
-    char ch = *ptr;
-    // skip Delimiters
-    while (' ' == ch) {
-        ptr++;
-        ch = *ptr;
-     }
-    return ptr;
-}
-
-/** CLDC spec req: only alphabet and digits */
-int checkName(const char* name) {
-    char ch = *name;
-    while (0 != ch) {
-        if (!(('a' <= ch && ch <= 'z') ||
-              ('A' <= ch && ch <= 'Z') ||
-              ('0' <= ch && ch <= '9'))) {
-            return 0;
-        }
-        name++;
-        ch = *name;
-    }
-    return 1;
-}
-
-const char* getNextDelimiterPtr(const char* prefixList) {
-    char ch = *prefixList;
-    while (0 != ch && ' ' != ch ) {
-        prefixList++;
-        ch = *prefixList;
-    }
-    return prefixList;
-}
-
-/* fills provided {@code dst} buffer with file names from {@code /dev} folder that matches prefixes from comma separated {@code prefix} list */
-void getDeviceList(char* dst, size_t dstLen, const char* prefix) {
-    int found = 0;
-    *dst = 0;
-    DIR* dir = opendir("/dev");
-    if (dir) {
-        struct dirent* de;
-        while (NULL != (de = readdir(dir))) {
-            if (!(de->d_type & DT_DIR)) {
-                const char* curPrefix = prefix;
-                // retuns curPrefix if no more templates found
-                const char* nextPrefix = getNextDelimiterPtr(curPrefix);
-
-                while (nextPrefix  != curPrefix) {
-                    // compare file name with prefix: wildcard search
-                    if(!strncmp(de->d_name, curPrefix, nextPrefix - curPrefix - 1)) {
-                        // don't use strncat since we need only full names
-                        size_t len = strlen(de->d_name);
-                        // +2 is for null and ','
-                        if (len+2 < dstLen && checkName(de->d_name)) {
-                            if (found) {
-                                // it is guaranteed that there is place for 0 or ','
-                                *dst = ',';
-                                dst++;
-                                dstLen--;
-                            }
-                            memcpy(dst,de->d_name, len);
-                            dst += len;
-                            dstLen -= len;
-                            found = 1;
-                        }
-                    }
-                    curPrefix = skipDelimiters(nextPrefix);
-                    nextPrefix = getNextDelimiterPtr(curPrefix);
-                }
-                *dst = 0;
-            }
-        }
-        closedir(dir);
-    }
-}
-
 /*
  * get serial config by device name
  *
@@ -151,28 +75,6 @@
     return add_dev_to_list(&_dev_list, &_list_mutex, p);
 }
 
-/**
- * See javacall_serial.h for definition
- */
-javacall_result javacall_serial_list_available_ports(char* buffer,
-        int maxBufLen) {
-
-    int i, len, totalCount;
-    const char *devPrefix;
-    javacall_result res;
-
-    JAVACALL_REPORT_INFO(JC_SERIAL, "Checking what serial ports are available");
-
-    if (JAVACALL_OK != javacall_get_property("deviceaccess.uart.prefix",
-                JAVACALL_INTERNAL_PROPERTY, &devPrefix)) {
-            JAVACALL_REPORT_WARN(JC_SERIAL, "Failed to read property 'deviceaccess.uart.prefix'");
-        devPrefix = DEFAULT_PREFIX;
-    }
-
-    getDeviceList(buffer, maxBufLen, devPrefix);
-
-    return JAVACALL_OK;
-}
 
 javacall_result
 jc_serial_init_buffers_threads(serial_handle p){
--- a/src/share/linux/native/com/oracle/dio/uart/serial.h	Wed Jan 28 13:32:58 2015 +0300
+++ b/src/share/linux/native/com/oracle/dio/uart/serial.h	Wed Jan 28 15:24:59 2015 +0300
@@ -37,11 +37,8 @@
 #include "javacall_properties.h"
 #include "javautil_circular_buffer.h"
 
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <termios.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <poll.h>
@@ -50,14 +47,9 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 
-#include <dirent.h>
-#include <string.h>
-
 #define SERIAL_BUF_SIZE    0x400
 static const char* const SERIAL_BUFFER_SIZE_PROPERTY_NAME = "uart_native_buffer_size";
 
-static const char* const DEFAULT_PREFIX   = "ttyUSB";
-
 typedef void (*asynch_event_cb)(javacall_handle handle, int param, javacall_result res);
 
 typedef struct serial_descr{
--- a/src/share/native/com/oracle/dio/javacall_serial.h	Wed Jan 28 13:32:58 2015 +0300
+++ b/src/share/native/com/oracle/dio/javacall_serial.h	Wed Jan 28 15:24:59 2015 +0300
@@ -145,20 +145,6 @@
   */
 #define FLOWCONTROL_XONXOFF_OUT 8
 
-
-/**
- * Return an string the contains a list of available ports delimited by a comma
- * (COM1,COM2)
- * If there is no available port then buffer will be empty string and return JAVACALL OK.
- *
- * @param buffer lists of available ports.This value must be null terminated.
- * @param maxBufferLen the maximum length of buffer
- * @retval JAVACALL_OK success
- * @retval JAVACALL_FAIL fail or the return length is more than maxBufferLen characters.
- */
-javacall_result /*OPTIONAL*/  javacall_serial_list_available_ports(char* buffer, int maxBufLen);
-
-
 /**
  * Initiates opening serial link according to the given parameters.
  *