Package cnadeau.driver.threads

Examples of cnadeau.driver.threads.TransmitterThread


  public TransmitterThread createTransmitterThread(UsbInterfaceInfos cm19aDeviceInfos) throws CM19AException
  {
    logger.info("Starting transmitter thread... ");
    UsbPipe outPipe = openPipe(cm19aDeviceInfos.getOutEndpoint());
    TransmitterThread transmitter = new TransmitterThread(this, outPipe);
    return transmitter;
  }
View Full Code Here


    {
      logger.info("Starting driver... ");

      UsbInterfaceInfos cm19aDeviceInfos = getUsbDeviceInfos();
      ReceiverThread receiverThread = createReceiverThread(cm19aDeviceInfos);
      TransmitterThread transmitterThread = createTransmitterThread(cm19aDeviceInfos);

      logger.info("Driver started!");
      try
      {
        receiverThread.start();
        transmitterThread.start();
        while (running)
        {
          byte[] buffer = new byte[16];

          int readCount = cm19aInputReader.read(buffer);
          if (readCount > 0)
          {
            String string = new String(buffer);

            if (send(string.trim()))
            {
              // explicitly closing the driver
              running = false;
            }
          }
          else
          {
            Thread.sleep(250);
          }
        }
      }
      catch (Exception e)
      {
        logger.error(e);
      }
      finally
      {
        if (receiverThread != null)
        {
          receiverThread.quit();
        }
        if (transmitterThread != null)
        {
          transmitterThread.quit();
        }
        logger.info("Driver stopped");
      }
    }
  }
View Full Code Here

TOP

Related Classes of cnadeau.driver.threads.TransmitterThread

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.