Есть вот такие строки в моей програмке:
| Код | BufferedReader BR = new BufferedReader(new InputStreamReader (port.getInputStream())); if(BR.ready()==false) { int timer = 1; while(BR.ready()==false) { if(timer ==10) { history.Write("Waiting, stream not ready","GSMTerminal"); } this.wait(100); if((BR.ready())&(timer>=10)) { timer = 1; history.Write("Stream ready=true, GSMTerminal works.","GSMTerminal"); } if(timer==30) { history.Write("Stream closed, try to replay command ","GSMTerminal"); timeToQuit = true; port.close(); this.Inicialization(); BR.close(); break; } timer++; } } if(timeToQuit!=true) { str = BR.readLine(); history.Write(str,"GSMTerminal"); }
|
вот метод Inicialization:
| Код | public void Inicialization() { errorWriter = new ErrorWriter(); history = new HistoryWriter(); String defaultPort=properties.Load("defaultPort"); portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { history.Write("Found port "+defaultPort+" , try to open...","GSMTerminal"); try { port = (SerialPort) portId.open("Server",2000); portOpen=true; history.Write("Port "+defaultPort+" open!","GSMTerminal"); this.setInputStream(port.getInputStream()); } catch (PortInUseException e) { history.Write("Port "+defaultPort+" is already in use, can not use this port ","GSMTerminal"); errorWriter.WriteError("Error in Inicialization ComPort "+e); portOpen = false; } catch(IOException IOE) { errorWriter.WriteError("Error in GSMModem in Inicilize "+IOE); } } } } }
|
А вот кусок лога:
| Код | 03.06.2008 01:23:32 --------------------------------------- 03.06.2008 01:23:32 at+cmgl=ALL 03.06.2008 01:23:33 Waiting, stream not ready 03.06.2008 01:23:35 Stream closed, try to replay command 03.06.2008 01:23:35 Found port /dev/ttyS0 , try to open... 03.06.2008 01:23:35 Port /dev/ttyS0 open! 03.06.2008 01:25:30 --------------------------------------- 03.06.2008 01:25:30 at+cmgl=ALL 03.06.2008 01:25:31 Waiting, stream not ready 03.06.2008 01:25:33 Stream closed, try to replay command 03.06.2008 01:25:33 Found port /dev/ttyS0 , try to open... 03.06.2008 01:25:33 Port /dev/ttyS0 open! 03.06.2008 01:27:28 --------------------------------------- 03.06.2008 01:27:28 at+cmgl=ALL 03.06.2008 01:27:29 Waiting, stream not ready 03.06.2008 01:27:31 Stream closed, try to replay command 03.06.2008 01:27:31 Found port /dev/ttyS0 , try to open... 03.06.2008 01:27:31 Port /dev/ttyS0 open! 03.06.2008 01:29:26 --------------------------------------- 03.06.2008 01:29:26 at+cmgl=ALL 03.06.2008 01:29:27 Waiting, stream not ready 03.06.2008 01:29:29 Stream closed, try to replay command 03.06.2008 01:29:29 Found port /dev/ttyS0 , try to open... 03.06.2008 01:29:29 Port /dev/ttyS0 open! 03.06.2008 01:31:24 --------------------------------------- 03.06.2008 01:31:24 at+cmgl=ALL
|
Могу сразу сказать к ком порту ничаго отвечающего не было подключенно , тобишь я постоянно перестартовывал ком порт.. а в какой то момент он сказал , что готов передать байты.. и повесилась программка.. в чем дело,? Може кому еще надо что выложить.. просто не умею я толком вопросы задавать. |