// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
//   String res;
//   try {
//     res = i18n.getString(s);
//   } catch (MissingResourceException e) {
//     res = s;
//   }
// 
//   // The single % is the arguments selector in .PO files.
//   // We must put double %% inside the translations to avoid
//   // getting .PO processing in the way.
//   res = res.replace("%%", "%");
// 
//   return res;
// }


import java.io.*;
import java.util.*;
import processing.app.debug.MessageConsumer;
import static processing.app.I18n._;
import gnu.io.*;
  public Serial(String iname, int irate) throws SerialException {
    this(iname, irate, Preferences.get("serial.parity").charAt(0),
    Preferences.getInteger("serial.databits"), 
    new Float(Preferences.get("serial.stopbits")).floatValue());
  }

  public Serial(String iname) throws SerialException {
    this(iname, Preferences.getInteger("serial.debug_rate"),
      Preferences.get("serial.parity").charAt(0),
      Preferences.getInteger("serial.databits"),
      new Float(Preferences.get("serial.stopbits")).floatValue());
  }

  public static boolean touchPort(String iname, int irate) throws SerialException {
    SerialPort port;
    boolean result = false;
    try {
      @SuppressWarnings("unchecked")
      Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
      while (portList.hasMoreElements()) {
        CommPortIdentifier portId = portList.nextElement();
        if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
          port = (SerialPort) portId.open("tap", 2000);
          port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
          port.close();				
          result = true;
        }
      }
    } catch (PortInUseException e) {
      throw new SerialException(
// Path: app/src/processing/app/I18n.java
// public static String _(String s) {
//   String res;
//   try {
//     res = i18n.getString(s);
//   } catch (MissingResourceException e) {
//     res = s;
//   }
// 
//   // The single % is the arguments selector in .PO files.
//   // We must put double %% inside the translations to avoid
//   // getting .PO processing in the way.
//   res = res.replace("%%", "%");
// 
//   return res;
// }


// Path: app/src/processing/app/Serial.java
import java.io.*;
import java.util.*;
import processing.app.debug.MessageConsumer;
import static processing.app.I18n._;
import gnu.io.*;

  public Serial(String iname, int irate) throws SerialException {
    this(iname, irate, Preferences.get("serial.parity").charAt(0),
    Preferences.getInteger("serial.databits"), 
    new Float(Preferences.get("serial.stopbits")).floatValue());
  }

  public Serial(String iname) throws SerialException {
    this(iname, Preferences.getInteger("serial.debug_rate"),
      Preferences.get("serial.parity").charAt(0),
      Preferences.getInteger("serial.databits"),
      new Float(Preferences.get("serial.stopbits")).floatValue());
  }

  public static boolean touchPort(String iname, int irate) throws SerialException {
    SerialPort port;
    boolean result = false;
    try {
      @SuppressWarnings("unchecked")
      Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
      while (portList.hasMoreElements()) {
        CommPortIdentifier portId = portList.nextElement();
        if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
          port = (SerialPort) portId.open("tap", 2000);
          port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
          port.close();				
          result = true;
        }
      }
    } catch (PortInUseException e) {
      throw new SerialException(
        I18n.format(_("Serial port ''{0}'' already in use. Try quitting any programs that may be using it."), iname)