From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0001.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0001.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0001.bin From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0003.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0003.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0002.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0002.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0004.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0004.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0003.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0003.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0005.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0005.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0004.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0004.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0006.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0006.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0005.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0005.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0007.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0007.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0006.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0006.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0008.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0008.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0007.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0007.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0009.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0009.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0008.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0008.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0010.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0010.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0009.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0009.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0011.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0011.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0010.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0010.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0012.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0012.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0011.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0011.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From support at kartmanager.de Mon May 14 08:43:08 2007 From: support at kartmanager.de (Andre Geisler) Date: Mon, 14 May 2007 16:43:08 +0200 Subject: [Rxtx] Problem on closing Ports Message-ID: <4648757C.8080601@kartmanager.de> Hello, i have got a small problem on closing serail ports. The following class manages the my serials connection an is handeled by an object calles kbn which lays in a java swin gui: public class Serial implements SerialPortEventListener{ private static CommPortIdentifier portId; private static Enumeration portList; private InputStream inputStream; private OutputStream outputStream; private SerialPort serialPort; private AmbHandler ambh = new AmbHandler(); private String defaultPort = "/dev/ttyS0"; private Kartbahnnutzung kbn; public Serial() {} public void connect(){ boolean portFound = false; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals(defaultPort)) { System.out.println("Found port: "+defaultPort); portFound = true; } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } try { serialPort = (SerialPort) portId.open("Kartman Read Thread", 2000); } catch (PortInUseException e) {} try { inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } catch (IOException e) {} try { serialPort.addEventListener(this); } catch (TooManyListenersException e) {} serialPort.notifyOnDataAvailable(true); try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e){} } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer =new byte[25]; int numBytes=0; try { while (inputStream.available() > 0) { numBytes = inputStream.read(readBuffer); System.out.println("String: "+ new String(readBuffer,0,numBytes)); System.out.println("Anzahl der bytes: "+numBytes); ambh.newMessage(new String(readBuffer,0,numBytes)); readBuffer = new byte[25]; } if(ambh.isPacketComplete()){ System.out.println("Complete packet? "+ambh.isPacketComplete()); kbn.addErgebnis(ambh.getLastPacket()); System.out.println("Letzte Nachricht:"+ambh.getLastPacket().getMessage()); } } catch (IOException e) {System.out.println("Ups!");} break; } } public void simpleWrite(char c){ try{ this.outputStream.write(c); }catch ( IOException e ){ e.printStackTrace(); } } public void disconnect(){ serialPort.removeEventListener(); serialPort.close(); System.out.println(defaultPort+" is closed!"); } public ArrayList getAmbArray(){ return ambh.getPacketarr(); } public void setKartbahnnutzung(Kartbahnnutzung kbn){ this.kbn=kbn; } } I have got a button called which closes the connection. Everything is ok, it is calling an method from kbn which calls serialcon.disconnect(); But there is also the possibility that the kbn object closes the connection it self. It uses the same function "serial.disconnect()". The function itself is startetd, but it does not close the connection. Nothing els happens, no exception, no ... The program stops, and else happens. Is there a better way to close this connection??? regards -- Mit freundlichen Gr??en Andr? Geisler http://www.kartmanager.de support at kartmanager.de From rithy8 at gmail.com Mon May 14 12:16:39 2007 From: rithy8 at gmail.com (rithy roth) Date: Mon, 14 May 2007 11:16:39 -0700 Subject: [Rxtx] please help on when read time out occurs Message-ID: <79e2547b0705141116q6138850sdb937a6fe74b5eb3@mail.gmail.com> Hi, I've been looking for some doc regarding what enableReceiveTimeout() is doing( which event is generated) when a read time out occurs. Also, I am not sure myself what to do in my code when a timeout happens. Could someone please help? Thanks ======================================== Here is a portion of my code: After opening my serial port, I issued the following: ... try { sPort.enableReceiveTimeout(30); } catch (UnsupportedCommOperationException e) { throw new SerialConnectionException("Enable Receive Timeout not supported"); } ... Then, on my read I just have a listener on event notification: public void serialEvent(SerialPortEvent e) { // Create a StringBuffer and int to receive input data. StringBuffer inputBuffer = new StringBuffer(); int newData = 0; // Determine type of event. switch (e.getEventType()) { // Read data until -1 is returned. If \r is received substitute // \n for correct newline handling. case SerialPortEvent.DATA_AVAILABLE: // System.out.println("data available"); while (newData != -1) { try { newData = is.read(); if (newData == -1) { break; } inputBuffer.append((char) newData); } catch (IOException ex) { System.err.println(ex); return; } } break; // If break event append BREAK RECEIVED message. case SerialPortEvent.BI: // messageAreaIn.append("\n--- BREAK RECEIVED ---\n"); Utils.debugprint("\n--- BREAK RECEIVED ---\n"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070514/e5d9a4a8/attachment-0013.html From info at haberkamp.com Tue May 15 04:27:10 2007 From: info at haberkamp.com (Guido Haberkamp IT-Beratung) Date: Tue, 15 May 2007 12:27:10 +0200 Subject: [Rxtx] CommPortIdentifier "hangs" Message-ID: <46498AFE.7050307@haberkamp.com> Hello, I couldn't find a solution to my problem or even anybody else mentioning this problem on the net, so I'm asking you all for help. I'm trying to use rxtx2.1.7 But when I try to get the portId from CommPortIdentifier.getPortIdentifier("COM1") It takes 3min50sec for the method to return the value. After that everything works fine. Connecting via Hyperterminal to the same port shows no noticable delay I'll include my code at the end of this posting Thanks for your help. Guido Here some details to my programming environment: Windows 2000 Prof. IBM T23 with one built-in Comport ("COM1"), another one via USB-Serial Adapter (ATEN, COM5 or COM8) COM10-17 are assigned because of a VS Netcom Device that connects 8 Serial ports over one tcp/ip link Eclipse 3.2.2 Java 1.5.0 rxtx-2.1-7r2 I'm new to Java programming in general and serial port communication in particular, so I'd really appreciate also some hints if I use rxtx completely the wrong way. at Captain.at there's a code example that iterates through all available ports (including parallel ports), but that code gave me many strange exceptions, so I changed it to opening the required port directly. Here's my code: import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.NoSuchPortException; import gnu.io.PortInUseException; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; import java.io.BufferedReader; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.Date; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.prefs.Preferences; import logic.Parser; /** * TODO Add comment here * @author $Author: $ * @version $Revision: $, $Date: $ UTC */ public class SerialCommunicator implements SerialPortEventListener { static CommPortIdentifier portId = null; static Enumeration portList = null; String appName = null; private int baudRate = 0; private String device = null; // InputStream in = null; BufferedReader in = null; private String lineRead = null; OutputStream out = null; private Parser parser = null; private String portName = null; private Preferences prefs = null; public Thread readerThread = null; private SerialPort serialPort = null; int timeout = 0; public Thread writerThread = null; public SerialCommunicator(Parser p, Preferences pr, String dev) { super(); this.parser = p; this.prefs = pr; this.device = dev; // TODO: assertions p, pr, d != null Preferences node = prefs.node("General"); this.timeout = node.getInt("timeout", 0); node = prefs.node(device); this.portName = node.get("portName", null); this.baudRate = node.getInt("baudRate", 0); this.appName = node.get("appName", null); System.out.println("Trying to connect to port "+portName); Date date = new Date(); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); if (foundPort(portName)){ try { connect(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } date = new Date(); System.out.println("Connected to port "+portName); System.out.println("at: "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); } else { System.out.println("Could not connect"); } } boolean foundPort (String port){ boolean portFound = false; try { // portId = CommPortIdentifier.getPortIdentifier(port); portId = CommPortIdentifier.getPortIdentifier("COM5"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ( portId.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { portFound = true; } return portFound; } void connect () throws Exception { this.openPort(portName); this.setInputStream(); this.setParameters(); } void openPort (String port){ try { serialPort = (SerialPort) portId.open(appName, timeout); } catch (PortInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setInputStream (){ try { this.in = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.notifyOnDataAvailable(true); try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { // TODO Auto-generated catch block e.printStackTrace(); } } void setParameters(){ try { this.serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: try { this.lineRead = this.in.readLine(); System.out.println("Read: "+lineRead); } catch (IOException e) {} break; } } } -------------- next part -------------- A non-text attachment was scrubbed... Name: info.vcf Type: text/x-vcard Size: 317 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070515/810b538b/info-0013.vcf From murato at mobiliz.com.tr Wed May 16 06:58:50 2007 From: murato at mobiliz.com.tr (Murat Ozdemir) Date: Wed, 16 May 2007 15:58:50 +0300 Subject: [Rxtx] java.io.IOException: No error in nativeDrain Message-ID: Hello all, i'm using RXTX 2.1 with JSmsLib 2.1.0 When i'm trying to run that framework, i'm getting exceptions from RXTX Library as; java.io.IOException: No error in nativeDrain at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) at org.smslib.CSerialDriver.send(CSerialDriver.java:206) at org.smslib.handler.CATHandler.sync(CATHandler.java:43) at org.smslib.CService.connect(CService.java:539) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.doIt(ReadMessagesAsync.java:92) at tr.com.mobiliz.commserver.blo.handler.serial.rs232.sms.examples.ReadMessages Async.main(ReadMessagesAsync.java:140) Also, when i've read the README for rxtxSerial.dll faced that; Wed Mar 1 12:01:05 MST 2006 rxtxSerial.dll had to be recomopiled to link in missing native methods. what should i do? How can i recompile the dll? --------------- Murat OZDEMiR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/attachment-0012.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3736 bytes Desc: not available Url : http://mailman.qbang.org/pipermail/rxtx/attachments/20070516/938793aa/smime-0012.bin From Alec.Cawley at quantel.com Thu May 17 06:14:45 2007 From: Alec.Cawley at quantel.com (Alec.Cawley@quantel.com) Date: Thu, 17 May 2007 13:14:45 +0100 Subject: [Rxtx] Source or javadox for javax.comm API Message-ID: I want to access serial ports on Windows from Java. I get think I understand how to compile and run - put RXTXcomm.jar in my classpath, put the appropriate DLLs in the DLL search path. But what about me? How do I lean how to use it? There is no javax.comm in the api Javadoc with the JAVA SDK 6.1, and I can only find on-line javadoc for it. I would prefer not to be dependant on on-line resources *all* the time. Is there somewhere I can download javax.comm.java or a bundle of the Javadocs generated from it? Alec Cawley -- This e-mail is intended for the named addressees only. Its contents may be privileged or confidential and should be treated as such. If you are not an intended recipient please notify the sender immediately and then delete it; do not copy, distribute, or take any action based on this e-mail. In the pursuit of its legitimate business activities and its conformance with relevant legislation, Quantel may access any e-mail (including attachments) it originates or receives, for potential scrutiny. Quantel is the trade name used by Quantel Holdings Limited and its subsidiaries. Quantel Holdings Limited is registered in England & Wales. Registration No: 4004913 Contact details for all Quantel Offices and Companies can be found on our website www.quantel.com or by writing to the holding company. Registered address: Turnpike Road, Newbury, Berkshire, RG14 2NX, United Kingdom From h.mayer at inode.at Sat May 19 10:01:39 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 18:01:39 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter Message-ID: <464F1F63.4020302@inode.at> Hi all! I was testing my new USB-to-Serial converter with the SimpleRead.java application, but it hangs with 100% cpu. I also have an own app, which sends a string and tries to receive it. I use a null-modem - while sending works (I can see the string with "cat /dev/ttyUSB0"), the serialEvent is not fired and 100% cpu is the result. Doing the same (sending a string and receiving) with some C code works. Has anyone see the same behaviour and is there a fix somewhere ? Thanks! Cheers, Hannes. From h.mayer at inode.at Sat May 19 12:36:57 2007 From: h.mayer at inode.at (Hannes Mayer) Date: Sat, 19 May 2007 20:36:57 +0200 Subject: [Rxtx] RXTX hangs (100% cpu) when using USB-to-Serial converter In-Reply-To: <464F1F63.4020302@inode.at> References: <464F1F63.4020302@inode.at> Message-ID: <464F43C9.2000003@inode.at> Hannes Mayer wrote: > Hi all! > > I was testing my new USB-to-Serial converter with the > SimpleRead.java application, but it hangs with 100% > cpu. Found the problem! Removing serialPort.notifyOnOutputEmpty(true); resolves this issue. It seems that the usbserial driver doesn't support this. Cheers, Hannes. From lists at iDIAcomputing.com Sun May 20 17:59:11 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 19:59:11 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes Message-ID: <4650E0CF.8040900@iDIAcomputing.com> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which has no data available, I get java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) This is using code that worked fine with Sun's javax.comm API (the old 2.0 version) until a JVM upgrade broke it. Any suggestions on what's wrong? I'd dig into it deeper, but I don't have a C compiler on this box. As near as I can tell from reading the Java source, this means the open() call didn't grab a file descriptor. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From tjarvi at qbang.org Sun May 20 18:08:39 2007 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 20 May 2007 18:08:39 -0600 (MDT) Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: <4650E0CF.8040900@iDIAcomputing.com> References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: On Sun, 20 May 2007, George Dinwiddie wrote: > Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which > has no data available, I get > java.io.IOException: Underlying input stream returned zero bytes > at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) > > This is using code that worked fine with Sun's javax.comm API (the old > 2.0 version) until a JVM upgrade broke it. > > Any suggestions on what's wrong? I'd dig into it deeper, but I don't > have a C compiler on this box. As near as I can tell from reading the > Java source, this means the open() call didn't grab a file descriptor. > > - George > > Hi George, Perhaps changing the threshold and or timeout may result in the behavior you expect. -- Trent Jarvi tjarvi at qbang.org From lists at iDIAcomputing.com Sun May 20 18:51:25 2007 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Sun, 20 May 2007 20:51:25 -0400 Subject: [Rxtx] Underlying input stream returned zero bytes In-Reply-To: References: <4650E0CF.8040900@iDIAcomputing.com> Message-ID: <4650ED0D.9000204@iDIAcomputing.com> Trent Jarvi wrote: > On Sun, 20 May 2007, George Dinwiddie wrote: > >> Uxing RXTX-2.1-7 on Windows XP Pro: when I try to read from a port which >> has no data available, I get >> java.io.IOException: Underlying input stream returned zero bytes >> at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) >> >> This is using code that worked fine with Sun's javax.comm API (the old >> 2.0 version) until a JVM upgrade broke it. >> >> Any suggestions on what's wrong? I'd dig into it deeper, but I don't >> have a C compiler on this box. As near as I can tell from reading the >> Java source, this means the open() call didn't grab a file descriptor. >> >> - George >> >> > > Hi George, > > Perhaps changing the threshold and or timeout may result in the behavior > you expect. Thanks, Trent. Any suggestions on values? BTW, The javax.comm 2.0 library seems to enable the timeout when opened as: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier( serialPortParams.getPortName()); int timeout = 60000; serialPort = (SerialPort) portId.open(processname, timeout); When I serialPort.enableReceiveTimeout(timeout); serialPort.enableReceiveThreshold(1); I don't seem to receive any characters. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ----------------------------------------------------------------------