libusb crash!

Supporting Java SE version 7 and up
szahran
Phidgetsian
Posts: 13
Joined: Thu Aug 08, 2013 12:54 am
Contact:

libusb crash!

Postby szahran » Wed Mar 26, 2014 3:50 am

Hello,

I'm using the Java phidget API on linux and I've encountered the following problem in my application.

Code: Select all


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xa8a65f64, pid=2485, tid=2811229296
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) Client VM (24.0-b56 mixed mode linux-arm )
# Problematic frame:
# C  [libusb-1.0.so.0+0x6f64]  libusb_interrupt_transfer+0xa30
#
# 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/happy_plant/hs_err_pid2485.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#



Please advice on the possible causes, and how it can be fixed.

Thanks,
szahran

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: libusb crash!

Postby burley » Wed Mar 26, 2014 7:19 am

What were you running, what specifically was happening when it crashed, did you have logging enabled, can we see your code? We need more information before we can help you.
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

szahran
Phidgetsian
Posts: 13
Joined: Thu Aug 08, 2013 12:54 am
Contact:

Re: libusb crash!

Postby szahran » Wed Mar 26, 2014 7:31 am

Core dumps were disabled at that moment.

My application mainly collects sensor data every one minute.

Code: Select all

package sensors.phidget;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArrayList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import sensors.Sensor;

import com.phidgets.InterfaceKitPhidget;
import com.phidgets.PhidgetException;
import com.phidgets.event.SensorChangeEvent;
import com.phidgets.event.SensorChangeListener;

import config.SensorSrvConfig;

public class SensorController extends TimerTask implements SensorChangeListener {
   static Logger logger = LoggerFactory.getLogger(SensorController.class);

   private InterfaceKitPhidget sensorBoard = null;
   private static SensorController instance = null;

   private List<SensorListener> listeners = null;

   static Timer timer;

   private SensorController() {
      logger.info("Starting sensors' board ...");
      try {
         sensorBoard = new InterfaceKitPhidget();
         sensorBoard.open(SensorSrvConfig.board_ID);
         sensorBoard.waitForAttachment();
         for (int i = 0; i < SensorSrvConfig.sensors.size(); i++) {
            sensorBoard.setSensorChangeTrigger(i,
                  SensorSrvConfig.board_sensitivity);
            logger.info("Expecting sensor at socket {} ", i);
         }
         logger.info("Starting sensors' board was started");

         listeners = new CopyOnWriteArrayList<SensorListener>();

      } catch (PhidgetException e) {
         logger.error(e.getMessage());
      }
   }

   public static synchronized void start() {
      if (instance == null) {
         instance = new SensorController();

         if (SensorSrvConfig.pull_enabled) {
            logger.debug("Scheduling sensors' values' pulling timer");
            timer = new Timer("SENSOR_TIMER");

            timer.schedule(instance, 0, SensorSrvConfig.pull_interval);

         } else {
            instance.sensorBoard.addSensorChangeListener(instance);
         }
      } else {
         logger.warn("Already started!");
      }

   }

   public static synchronized void shutdown() {
      if (instance != null) {
         if (timer != null) {
            logger.debug("Canceling timer & timer task");
            instance.cancel();
            timer.cancel();
         }
         if (!SensorSrvConfig.pull_enabled) {
            instance.sensorBoard.removeSensorChangeListener(instance);
         }
         instance.listeners.removeAll(instance.listeners);
         instance.shutdownInstance();
      }
   }

   public static synchronized void registerListener(SensorListener listener) {
      if (instance != null) {
         instance.listeners.add(listener);
      }
   }

   public static synchronized void deregisterListener(SensorListener listener) {
      if (instance != null) {
         instance.listeners.remove(listener);
      }
   }

   private void shutdownInstance() {
      logger.info("Shutting down sensors' board");
      try {
         sensorBoard.close();
         logger.info("Sensors' board was shutdown");
      } catch (PhidgetException e) {
         logger.error(e.getMessage());
      }
   }

   public void sensorChanged(SensorChangeEvent event) {

      List<SensorEvent> events = new ArrayList<SensorEvent>();

      Sensor sensor = SensorSrvConfig.sensors.get(event.getIndex());

      SensorEvent n_event = new SensorEvent(sensor, event.getValue());

      events.add(n_event);

      for (SensorListener listener : listeners) {
         listener.sensorChanged(events);
      }
   }

   @Override
   public void run() {
      logger.debug("{}", Thread.currentThread().getName());
      List<SensorEvent> events = new ArrayList<SensorEvent>();
      for (Sensor sensor : SensorSrvConfig.sensors.values()) {
         try {
            SensorEvent n_event = new SensorEvent(sensor,
                  sensorBoard.getSensorValue(sensor.getSocket()));
            events.add(n_event);
         } catch (PhidgetException e) {
            logger.error(e.getMessage());
         }
      }
      for (SensorListener listener : listeners) {
         listener.sensorChanged(events);
      }
   }
}


So basically I call

Code: Select all

sensorBoard.getSensorValue(sensor.getSocket()));
every one minute and I store the value somewhere.

szahran
Phidgetsian
Posts: 13
Joined: Thu Aug 08, 2013 12:54 am
Contact:

Re: libusb crash!

Postby szahran » Sun Apr 13, 2014 2:54 am

Hello,

The same problem occurred again and stopped my application from working.

I'm attaching the phidget logs this time.

Please advice!

szahran
Attachments
phidget.txt
(11.48 KiB) Downloaded 233 times


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest