title: sending AT commands in java to telecom design modem
body: <p>I am trying to execute the at commands in java, I have done it in matlab, but I found it a bit difficult in java.
  Is there any api for java for the serial communication or at commands?
  I need a help to declare the serial port and then to send at commands to it.
  I found this java code to open the serial port (com12) but it is not opening the serial port.</p>
  
  <pre><code> static Enumeration portList;
   static CommPortIdentifier portId;
  static String messageString = "at \n";
  static SerialPort serialPort;
  static OutputStream outputStream;
  public static void main(String[] args) throws IOException {
      // TODO code application logic here
  portList = CommPortIdentifier.getPortIdentifiers();
  System.out.println("trying");
  
  while (portList.hasMoreElements()) {
  System.out.println("trying");
  portId = (CommPortIdentifier) portList.nextElement();
  if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
  System.out.println("trying");
  
           if (portId.getName().equals("COM12")) {
  System.out.println("found");
              try {
                  serialPort = (SerialPort)
                      portId.open("SimpleWriteApp", 2000);
              } catch (PortInUseException e) {System.out.println("err");}
              try {
                  outputStream = serialPort.getOutputStream();
              } catch (IOException e) {System.out.println("err1");}
              try {
                  serialPort.setSerialPortParams(9600,
                      SerialPort.DATABITS_8,
                      SerialPort.STOPBITS_1,
                      SerialPort.PARITY_NONE);
              } catch (UnsupportedCommOperationException e)                      
              {        
              System.out.println("err2");}
              outputStream.write(messageString.getBytes());
              System.out.println(messageString);
              outputStream.close();
              serialPort.close();
              }
              }
             }
                }
  </code></pre>
  
  <p>I am using the telecom design modem, I have executed commands in tera term terminal, so I am sure there is nothing wrong with modem or the way i am sending the commands. I think I am struggling in opening the serial port, and sending the carriage character.</p>
  
  <p>Thanks in advance</p>