Package it.baeyens.arduino.arduino

Examples of it.baeyens.arduino.arduino.Serial


     * @param bautrate
     *            The baud rate to set
     * @return true is successful otherwise false
     */
    public static boolean reset_Arduino_by_baud_rate(String ComPort, int baudrate, long openTime) {
  Serial serialPort;
  try {
      serialPort = new Serial(ComPort, baudrate);
  } catch (Exception e) {
      e.printStackTrace();
      Common.log(new Status(IStatus.WARNING, ArduinoConst.CORE_PLUGIN_ID, "Unable to open Serial port " + ComPort, e));
      return false;
  }

  try {
      Thread.sleep(openTime);
  } catch (InterruptedException e) {// Jaba is not going to write this
            // code
  }
  serialPort.dispose();
  return true;
    }
View Full Code Here


    return wait_for_com_Port_to_appear(OriginalPorts, ComPort);
      }
  }

  // connect to the serial port
  Serial serialPort;
  try {
      serialPort = new Serial(ComPort, 9600);
  } catch (Exception e) {
      e.printStackTrace();
      Common.log(new Status(IStatus.WARNING, ArduinoConst.CORE_PLUGIN_ID, "Unable to open Serial port " + ComPort, e));
      return ComPort;
      // throw new RunnerException(e.getMessage());
  }
  if (!serialPort.IsConnected()) {
      Common.log(new Status(IStatus.WARNING, ArduinoConst.CORE_PLUGIN_ID, "Unable to open Serial port " + ComPort, null));
      return ComPort;
  }

  if (!bDisableFlushing) {
      // Cleanup the serial buffer
      flushSerialBuffer(serialPort);// I wonder is this code on the right
            // place (I mean before the reset?;
            // shouldn't it be after?)
  }
  // reset arduino
  ToggleDTR(serialPort, 100);

  serialPort.dispose();
  return ComPort;

    }
View Full Code Here

    @Override
    public void dispose() {
  // As we have a listener we need to remove the listener
  if ((myScopelistener != null) && (mySerial != null)) {
      Serial tempSerial = mySerial;
      mySerial = null;
      tempSerial.removeListener(myScopelistener);
      myScopelistener.dispose();
      myScopelistener = null;
      myScope.dispose();
      myScope = null;
  }
View Full Code Here

  myConnectToSerialPort.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ADD)); // IMG_OBJS_INFO_TSK));

  myDisconnectSerialPort = new Action() {
      @Override
      public void run() {
    Serial newSerial = GetSelectedSerial();
    if (newSerial != null) {
        SerialListener theListener = mySerialConnections.get(newSerial);
        mySerialConnections.remove(newSerial);
        newSerial.removeListener(theListener);
        newSerial.dispose();
        theListener.dispose();
        SerialPortsUpdated();
    }
      }
  };
View Full Code Here

    /**
     * methoid to make sure the visualisation is correct
     */
    void SerialPortsUpdated() {
  myDisconnectSerialPort.setEnabled(mySerialConnections.size() != 0);
  Serial CurSelection = GetSelectedSerial();
  mySerialPorts.setInput(mySerialConnections);
  if (mySerialConnections.size() == 0) {
      mySendButton.setEnabled(false);
      myresetButton.setEnabled(false);
  } else {

      if (mySerialPorts.getSelection().isEmpty()) // nothing is selected
      {
    if (CurSelection == null) // nothing was selected
    {
        CurSelection = (Serial) mySerialConnections.keySet().toArray()[0];
    }
    mySerialPorts.getCombo().setText(CurSelection.toString());
    ComboSerialChanged();
      }
  }
    }
View Full Code Here

     *            the bautrate to connect to the com port
     */
    public void connectSerial(String ComPort, int BaudRate) {
  if (mySerialConnections.size() < myMaxSerialPorts) {
      int colorindex = mySerialConnections.size();
      Serial newSerial = new Serial(ComPort, BaudRate);
      if (newSerial.IsConnected()) {
    newSerial.registerService();
    SerialListener theListener = new SerialListener(this, colorindex);
    newSerial.addListener(theListener);
    theListener.event(System.getProperty("line.separator") + "Connected to " + ComPort + " at " + BaudRate
      + System.getProperty("line.separator"));
    mySerialConnections.put(newSerial, theListener);
    return;
      }
View Full Code Here

     * PauzePort is called when the monitor needs to disconnect from a port for a short while. For instance when a upload is started to a com port the
     * serial monitor will get a pauzeport for this com port. When the upload is done ResumePort will be called
     */
    @Override
    public boolean PauzePort(String PortName) {
  Serial TheSerial = GetSerial(PortName);
  if (TheSerial != null) {
      TheSerial.disconnect();
      return true;
  }
  return false;
    }
View Full Code Here

    /**
     * see PauzePort
     */
    @Override
    public void ResumePort(String PortName) {
  Serial TheSerial = GetSerial(PortName);
  if (TheSerial != null) {
      TheSerial.connect();
  }
    }
View Full Code Here

TOP

Related Classes of it.baeyens.arduino.arduino.Serial

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.