intel-iot-devkit / tinyb

TinyB exposes the BLE GATT API for C++, Java and other languages, using BlueZ over DBus.
MIT License
255 stars 114 forks source link

When i order 'sudo reboot now' in java, after reboot, the ble cause problems. #151

Open aectarine opened 6 years ago

aectarine commented 6 years ago

First, execute a program. java -jar XXX.jar Second, In java program, run ble and run 'sudo reboot now' third, after boot, execute a program. java -jar XXX.jar

1) In case faster execute - core dump

A fatal error has been detected by the Java Runtime Environment:

#

SIGSEGV (0xb) at pc=0x641cf170, pid=899, tid=1659528304

#

JRE version: Java(TM) SE Runtime Environment (8.0_65-b17) (build 1.8.0_65-b17)

Java VM: Java HotSpot(TM) Client VM (25.65-b01 mixed mode linux-arm )

Problematic frame:

C [libstdc++.so.6+0x83170] std::__detail::_List_node_base::_M_unhook()+0x8

#

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

#

An error report file with more information is saved as:

/home/pi/hs_err_pid899.log

#

If you would like to submit a bug report, please visit:

http://bugreport.java.com/bugreport/crash.jsp

# Aborted

2) very slowly execution - core dump or normal execution.

Q) what is the problem? linux system cause problem? or tinyB.jar cause problem? or do not close many resource in java code?

source )

--- previous work ---

Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { running = false; alpsData.disableValueNotifications(); alpsData.close(); alpsControl.close(); alpsReadResponse.close(); alpsService.close(); sensor.disconnect(); sensor.close(); } });

    alpsData.enableValueNotifications(new BluetoothNotification<byte[]>() {

        @Override
        public void run(byte[] tempRaw) {

            System.out.print("Temp raw = {");
            for (byte b : tempRaw) {
                System.out.print(String.format("%02x,", b));
            }
            System.out.print("}");

            Formula formula = new Formula();
            formula.Sensor(tempRaw);

        }

    });

    boolean running = true;
    int count = 20;

    while (running) {
        Thread.sleep(1000);
        count--;
        if (count == 0) {
            Reboot.Rebooting();
        }
    }

    sensor.disconnect();

------------------------ rebooting ----------------------

public class Reboot {

public static void Rebooting() {

    Process p = null;
    BufferedReader br = null;
    String[] cmd = { "sudo", "reboot", "now" };

    try {

        p = Runtime.getRuntime().exec(cmd);

        br = new BufferedReader(new InputStreamReader(p.getInputStream()));

        String line = null;

        while ((line = br.readLine()) != null) {

            System.out.println(line);

        }

    } catch (Exception e) {

        System.out.println("[알림] " + e.getMessage());

    } finally {

        System.out.println("[알림] 리눅스 명령어 처리를 위한 스트림 CLOSE");

        try {

            if (br != null) {
                br.close();
            }

            if (p != null) {
                p.destroy();
            }

        } catch (Exception e) {
            // TODO: handle exception
            System.out.println("[알림] " + e.getMessage());
        }

    }

}

}