arm.patch

ARM patch - ms_sitec_systems, 08/27/2014 01:05 PM

Download (120 KB)

View differences:

src/main/java/de/root1/rxtxrebundled/LibLoader.java Locally Modified (Based On LOCAL)
18 18
--------------------------------------------------------------------------*/
19 19
package de.root1.rxtxrebundled;
20 20

  
21
import java.io.BufferedReader;
21 22
import java.io.File;
22 23
import java.io.FileOutputStream;
23 24
import java.io.IOException;
24 25
import java.io.InputStream;
26
import java.io.InputStreamReader;
25 27
import java.util.HashMap;
26 28
import java.util.Map;
27
import java.util.logging.Level;
28
import java.util.logging.Logger;
29 29

  
30 30
/**
31 31
 * Helper Class used by rxtx implementation to load native libs without having 
......
33 33
 * Native libs will be extracted and loaded automatically, if possible
34 34
 * 
35 35
 * @author achr
36
 * @author sitec systems GmbH
36 37
 */
37 38
public class LibLoader {
38 39
    
39
    private static final String LIBLOADER_VERSION_NAME = "rxtx-rebundled-2.1-7r2";
40
    private static final String LIBLOADER_VERSION_NAME = "rxtx-rebundled-2.1-7r3";
41
    private static final String HF_ABI_SUPPORT = "Tag_ABI_VFP_args: VFP registers";
40 42
    
41 43
    /**
42 44
     * <code>Map&lt;Name of lib i.e. 'rxtxSerial', path to extracted lib&gt;</code><br>
......
53 55
        
54 56
        // check for linux platform ..
55 57
        if (osName.toLowerCase().contains("linux")) {
56
            
58
            // check for architecture arm
59
            if (osArch.toLowerCase().contains("arm")) {
60
                try {
61
                    // check for hard float or soft float abi
62
                    if (isHardFloatAbi()) {
63
                        logStdOut("Float ABI=Hard Float (armhf)");
64
                        // armhf libs from Debian project (https://packages.debian.org/wheezy/librxtx-java)
65
                        extractedLibs.put("rxtxSerial", extractLib("/jni/Linux/armhf-unknown-linux-gnu/", "librxtxSerial.so"));
66
                    } else {
67
                        logStdOut("Float ABI=Soft Float (armel)");
68
                        // armel libs from Debian project (https://packages.debian.org/wheezy/librxtx-java)
69
                        extractedLibs.put("rxtxSerial", extractLib("/jni/Linux/armel-unknown-linux-gnu/", "librxtxSerial.so"));
70
                    }
71
                } catch (final IOException ex) {
72
                    logStdOut("The check for arm float ABI has failed: " + ex.getMessage());
73
                }
74
            }
57 75
            // check for architecture 64bit
58
            if (osArch.toLowerCase().contains("amd64") || osArch.toLowerCase().contains("x86_64")) {
76
            else if (osArch.toLowerCase().contains("amd64") || osArch.toLowerCase().contains("x86_64")) {
59 77
                extractedLibs.put("rxtxSerial", extractLib("/jni/Linux/x86_64-unknown-linux-gnu/", "librxtxSerial.so"));
60 78
            } 
61 79
            // else 32bit
......
111 129
    }
112 130
    
113 131
    /**
132
     * Checks the platform for hard float abi support.
133
     * @return <code>true<code> - The hard float abi is supported / <code>false</code>
134
     *         - Only soft float abi is supported
135
     * @throws IOException The reading of abi from ELF header has failed
136
     */
137
    private static boolean isHardFloatAbi() throws IOException {
138
        final ProcessBuilder pb = new ProcessBuilder("readelf", "-A", "/proc/self/exe");
139
        final Process p = pb.start();
140
        try {
141
            p.waitFor();
142
        } catch (final InterruptedException ex) {
143
            logStdErr("The ABI request was interrupted");
144
        }
145

  
146
        if(p.exitValue() != 0) {
147
            throw new IOException("The ABI request has failed");
148
        }
149
		
150
        BufferedReader br = null;
151
        try {
152
            br = new BufferedReader(new InputStreamReader(p.getInputStream()));
153
            
154
            String line;
155
            boolean result = false;
156
            
157
            while((line = br.readLine()) != null) {
158
                if(line.contains(HF_ABI_SUPPORT)) {
159
                    result = true;
160
                    break;
161
                }
162
            }
163
            
164
            return result;
165
        } finally {
166
            if(br != null) {
167
                br.close();
168
            }
169
        }
170
    }
171
    
172
    /**
114 173
     * Extracts the specified library from resource dir to a temp folder 
115 174
     * and returns the path to the extracted file
116 175
     *
src/main/resources/jni/Linux/armel-unknown-linux-gnu/readme.txt Locally New
1
armel so file from Debian project (https://packages.debian.org/wheezy/librxtx-java )
... This diff was truncated because it exceeds the maximum size that can be displayed.