|
hi all , i'am new in java and i have this problem. my prgramm is
import java.io.*; import javax.comm.*;
public class Sarla1 { CommPortIdentifier portId = null; SerialPort asyncPort = null; OutputStream op = null; InputStream ip = null; public void connect() { try { portId = CommPortIdentifier.getPortIdentifier("COM3"); } catch (Exception x) { System.out.println(x); } try { asyncPort = (SerialPort) portId.open("vLab serial port", 4000); } catch (Exception x) { System.out.println(x); } try { asyncPort.setSerialPortParams(57600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (Exception x) { System.out.println(x); } try { asyncPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN & SerialPort. FLOWCONTROL_RTSCTS_OUT); } catch (Exception x) { System.out.println(x); } try { op = asyncPort.getOutputStream(); } catch (Exception x) {} try { ip = asyncPort.getInputStream(); } catch (Exception x) {} String code = "E2231\r"; String message = "atdt2310994186\r"; try { op.write( message.getBytes()); } catch (Exception x) {} String rxMessage=""; for (;;) { try { if (ip.available()>0) { int k=ip.read(); System.out.print((char)k); rxMessage = rxMessage+(char)k; if (rxMessage.indexOf("CONNECT")>0) break; } } catch (Exception x) {} }
try { for (int k=0; k<30; k++) { String code = "E3701\r"; op.write(code.getBytes()); } } catch (Exception x) {}
rxMessage=""; for (;;) { try { if (ip.available()>0) { int k=ip.read(); } } catch (Exception x) {} System.out.print((char)k); rxMessage = rxMessage+(char)k; if (rxMessage.indexOf("STOP")>0) break; } public static void main(String arg[]) { Sarla1 ss = new Sarla1(); ss.connect(); } }
the error message is public static void main(string arg []) in the fifth row from the bottom, and i can not figure it out. thanks!!!
|