Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Detection of armel/armhf #6

Open
cjaentsch opened this issue May 4, 2020 · 1 comment
Open

Detection of armel/armhf #6

cjaentsch opened this issue May 4, 2020 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@cjaentsch
Copy link

Just a quick question: Right now the respective client library only has to be downloaded and works with it's given filename. But when using an ARMel or ARMhf device the SDK searches for "arm". This is not a problem as we can rename the "armhf" to "arm". I just wanted to ask if this behaviour will stay like that in the future so we'll build an ARM mode detection ourselves which takes the armhf file an renames it.

@cjaentsch
Copy link
Author

cjaentsch commented May 4, 2020

This is how we implemented ARM detection:

private static Boolean fiskalyDetectArmMode(String mode) {
    Boolean detected = false;

    ProcessBuilder processBuilder = new ProcessBuilder();
    processBuilder.command("bash", "-c", "readelf -a /usr/bin/readelf | grep " + mode);

    try {
        Process process = processBuilder.start();
        StringBuilder output = new StringBuilder();
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

        String line;
        while ((line = reader.readLine()) != null) {
            output.append(line + "\n");
        }

        int exitVal = process.waitFor();
        if (exitVal == 0) {
            if (output.toString().contains(mode)) {
                detected = true;
            }
        } else {
            //abnormal...
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    return detected;
}

Called like that:

if (libArchitecture.equals("arm")) {
    if (fiskalyDetectArmMode("armel")) {
        libArchitecture = "armel";
    } else if (fiskalyDetectArmMode("armhf")) {
        libArchitecture = "armhf";
    }
}

@cjaentsch cjaentsch reopened this May 4, 2020
@prempador prempador added enhancement New feature or request question Further information is requested labels May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants