Package cnadeau.driver.exceptions

Examples of cnadeau.driver.exceptions.CM19AException


  {
    InputStream file = ClassLoader.getSystemResourceAsStream(PROTOCOL_FILE);

    if (file == null)
    {
      throw new CM19AException("Protocol file " + PROTOCOL_FILE + " not found");
    }

    BufferedReader in = null;
    try
    {
View Full Code Here


  {
    UsbHub virtualRootUsbHub = UsbHostManager.getUsbServices().getRootUsbHub();

    if (virtualRootUsbHub == null)
    {
      throw new CM19AException("No virtual root usb hub found");
    }

    /* Find the attached CM19a */
    UsbDevice cm19a = findDevice(virtualRootUsbHub);

    if (cm19a == null)
    {
      throw new CM19AException("No CM19a found; /dev/bus/usb permissions problem?");
    }

    if (logger.isDebugEnabled())
    {
      StringBuilder builder = new StringBuilder("Device found and  configured is ");
      if (!cm19a.isConfigured())
      {
        builder.append("not");
      }
      builder.append(" configured");
      logger.debug(builder.toString());
    }

    UsbConfiguration config = cm19a.getActiveUsbConfiguration();
    if (config == null)
    {
      throw new CM19AException("No active configuration found");
    }

    /* Get the first interface, there should only be one */
    UsbInterface usbInterface = (UsbInterface) config.getUsbInterfaces().get(0);

    logger.debug("Got device; Manufacturer is " + cm19a.getManufacturerString());
    logger.debug("Got interface; Active is " + usbInterface.isActive() + " Claimed is " + usbInterface.isClaimed());

    try
    {
      usbInterface.claim();
      logger.debug("Interface has been claimed");
    }
    catch (UsbException ue)
    {
      throw new CM19AException("Couldn't claim interface. " + "Message is " + ue.getMessage());
    }

    return new UsbInterfaceInfos(usbInterface);
  }
View Full Code Here

      }
    }

    if (getInEndpoint() == null || getOutEndpoint() == null)
    {
      throw new CM19AException("Couldn't find both endpoints");
    }
  }
View Full Code Here

  {

    /* remove any spaces in the command */
    String[] words = command.split("\\s+");
    if (words.length == 0)
      throw new CM19AException("Command is blank or empty");
    String spacelessCommand = words[0].trim();

    /* scrunch the string back together without the spaces */
    if (words.length > 1)
    {
View Full Code Here

    {
      usbInterface.release();
    }
    catch (UsbException e)
    {
      throw new CM19AException("Failed to release device: " + e.getMessage());
    }
  }
View Full Code Here

    {
      try
      {
        endPoint.getUsbPipe().close();
        endPoint.getUsbInterface().release();
        throw new CM19AException("pipe is null; interface released");
      }
      catch (UsbException ue)
      {
        throw new CM19AException("pipe is null; interface not released " + ue.getMessage());
      }
    }
    catch (UsbException ue2)
    {
      try
      {
        endPoint.getUsbPipe().close();
        endPoint.getUsbInterface().release();
        throw new CM19AException("Usb exception on pipe " + ue2.getMessage() + "; interface released");
      }
      catch (UsbException ue)
      {
        throw new CM19AException("Usb exception on pipe " + ue2.getMessage() + "; interface not released " + ue.getMessage());
      }
    }

    return outPipe;
  }
View Full Code Here

TOP

Related Classes of cnadeau.driver.exceptions.CM19AException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.