From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From ilkka at myller.com Sat Aug 1 00:22:18 2009 From: ilkka at myller.com (Ilkka Myller) Date: Sat, 1 Aug 2009 07:22:18 +0300 Subject: [Rxtx] caco receiving SIGSEGV In-Reply-To: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> References: <20090731234703.HM.000000000000A8W@asutosh.gopinath.mail-wwl14.bo3.lycos.com.lycos.com> Message-ID: > > sorry, i am using the 2.2pre2 bundle available from > > http://rxtx.qbang.org/wiki/index.php/Download > > but the shared object generated are showing 2.2pre1 > (librxtxSerial-2.2pre1.so) Actually, that bug is not fixed in 2.2pre2 either. The patch has been committed to CVS after 2.2pre2 release. That said - this probably is different issue since you are having those segmentation faults while accessing the open serial port (and not while closing it). -- I From rxtx at qbang.org Sun Aug 2 15:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 13:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 13:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 14:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 15:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 16:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 17:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 17:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 04:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 05:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 07:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 15:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 19:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 03:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 03:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 04:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 04:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 04:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 04:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 04:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 05:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 05:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 05:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 10:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 13:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 08:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 13:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 14:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 21:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 09:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 19:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 10:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 14:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 13:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 16:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 17:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 17:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 12:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 12:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 15:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 15:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 15:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 18:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 18:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 19:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 10:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 10:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 13:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 13:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 13:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 15:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 16:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 16:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From ilkka at myller.com Mon Aug 31 22:07:25 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 1 Sep 2009 07:07:25 +0300 Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <3682EFB2-5764-407F-9CD6-34752D3DAD69@myller.com> Hi, CVS server is reachable, but when trying anonymous login it replies: " Fatal error, aborting. anonymous: no such system user " It seems that the anonymous cvs account is not yet properly configured on the new system. -- I > On Mon, 31 Aug 2009, Trent Jarvi wrote: > > The server has been beemed to another location for those > experiencing routing problems. > > in bash: > > export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot > cvs login (no passwd) > cvs co -r commapi-0-0-1 rxtx-devel > > -- > Trent Jarvi > tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 10:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 10:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 13:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 13:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 13:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 15:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 16:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 16:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From ilkka at myller.com Mon Aug 31 22:07:25 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 1 Sep 2009 07:07:25 +0300 Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <3682EFB2-5764-407F-9CD6-34752D3DAD69@myller.com> Hi, CVS server is reachable, but when trying anonymous login it replies: " Fatal error, aborting. anonymous: no such system user " It seems that the anonymous cvs account is not yet properly configured on the new system. -- I > On Mon, 31 Aug 2009, Trent Jarvi wrote: > > The server has been beemed to another location for those > experiencing routing problems. > > in bash: > > export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot > cvs login (no passwd) > cvs co -r commapi-0-0-1 rxtx-devel > > -- > Trent Jarvi > tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 10:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 10:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 13:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 13:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 13:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 15:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 16:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 16:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From ilkka at myller.com Mon Aug 31 22:07:25 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 1 Sep 2009 07:07:25 +0300 Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <3682EFB2-5764-407F-9CD6-34752D3DAD69@myller.com> Hi, CVS server is reachable, but when trying anonymous login it replies: " Fatal error, aborting. anonymous: no such system user " It seems that the anonymous cvs account is not yet properly configured on the new system. -- I > On Mon, 31 Aug 2009, Trent Jarvi wrote: > > The server has been beemed to another location for those > experiencing routing problems. > > in bash: > > export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot > cvs login (no passwd) > cvs co -r commapi-0-0-1 rxtx-devel > > -- > Trent Jarvi > tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 10:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 10:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 13:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 13:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 13:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 15:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 16:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 16:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From ilkka at myller.com Mon Aug 31 22:07:25 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 1 Sep 2009 07:07:25 +0300 Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <3682EFB2-5764-407F-9CD6-34752D3DAD69@myller.com> Hi, CVS server is reachable, but when trying anonymous login it replies: " Fatal error, aborting. anonymous: no such system user " It seems that the anonymous cvs account is not yet properly configured on the new system. -- I > On Mon, 31 Aug 2009, Trent Jarvi wrote: > > The server has been beemed to another location for those > experiencing routing problems. > > in bash: > > export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot > cvs login (no passwd) > cvs co -r commapi-0-0-1 rxtx-devel > > -- > Trent Jarvi > tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 10:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 10:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 13:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 13:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 13:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 15:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 16:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 16:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From ilkka at myller.com Mon Aug 31 22:07:25 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 1 Sep 2009 07:07:25 +0300 Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <3682EFB2-5764-407F-9CD6-34752D3DAD69@myller.com> Hi, CVS server is reachable, but when trying anonymous login it replies: " Fatal error, aborting. anonymous: no such system user " It seems that the anonymous cvs account is not yet properly configured on the new system. -- I > On Mon, 31 Aug 2009, Trent Jarvi wrote: > > The server has been beemed to another location for those > experiencing routing problems. > > in bash: > > export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot > cvs login (no passwd) > cvs co -r commapi-0-0-1 rxtx-devel > > -- > Trent Jarvi > tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); log("INIT 4"); this.inputStream = this.serialPort.getInputStream(); log("INIT 5"); this.outputStream = new PrintStream( this.serialPort.getOutputStream()); log("INIT 6"); this.serialPort.enableReceiveTimeout(500); log("INIT 7"); this.serialPort.clearCommInput(); log("INIT 8"); this.serialPort.addEventListener(this); this.serialPort.notifyOnDataAvailable(true); this.serialPort.notifyOnOutputEmpty(true); log("INIT 9"); } catch (UnsupportedCommOperationException e) { IOException ex = new IOException("Unsupported operation"); ex.initCause(e); throw ex; } catch (PortInUseException e) { IOException ex = new IOException("Port is in use"); ex.initCause(e); throw ex; } catch (Throwable t) { IOException ex = new IOException("Unknown error"); ex.initCause(t); throw ex; } } // ~--- methods ------------------------------------------------------------ public void close() { try { log("CLOSE 1"); if (this.serialPort != null) { log("CLOSE 2"); this.inputStream.close(); log("CLOSE 3"); this.outputStream.close(); log("CLOSE 4"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); // new CloseThread().start(); log("CLOSE 5"); } log("CLOSE 6"); } catch (Throwable t) { t.printStackTrace(); } log("CLOSE 7"); } public void doTest() throws Throwable { log("TEST 1"); for (int i = 0; i < 20; i++) { log("TEST 2 #" + (i + 1)); this.outputStream.print("V"); this.outputStream.flush(); System.out.println("Zeit ben?tigt (SENDEN): " + ((System.currentTimeMillis() - zstVorher)) + " ms"); zstVorher = System.currentTimeMillis(); } log("TEST 3"); log("TEST 4"); this.serialPort.clearCommInput(); log("TEST 5"); } private static void log(String msg) { System.out.println(msg); } public static void main(String[] args) { try { log(String.format("RXTX: java %s, native %s", gnu.io.RXTXVersion.getVersion(), gnu.io.RXTXVersion.nativeGetVersion())); log("MAIN 1"); log("MAIN 2"); SerialTest ss = new SerialTest(); log("MAIN 3"); log("MAIN 4"); ss.doTest(); log("MAIN 5"); log("MAIN 6"); ss.close(); log("MAIN 7"); SerialTest ss1 = new SerialTest(); log("MAIN 8"); ss1.doTest(); log("MAIN 9"); ss1.close(); log("MAIN 8"); log("MAIN 9"); } catch (Throwable t) { t.printStackTrace(); } log("MAIN 10"); } public void serialEvent(SerialPortEvent arg0) { int eType = arg0.getEventType(); switch (eType) { case SerialPortEvent.DATA_AVAILABLE: log("receive sth"); try { int i = inputStream.read(buf); if (i == -1) { log("TODO: handle EOF condition"); return; } handleReceivedBytes(buf, i); return; } catch (IOException e) { log("TODO: handle IOException condition"); return; } default: log("TODO: handle event type: " + eType); break; } } private void handleReceivedBytes(byte[] bytes, int len) { bCount += len; for (int i = 0; i < len; i++) { // we are waiting for data or etx if (buf[i] == 7 || buf[i] == 13) { // normal condition - handle and flush... handleReceivedSerialLine(msg.toString()); msg.setLength(0); } else { // normal condition add byte to message... char c = (char) buf[i]; if (msg.length() >= maxmsg) { log("ERROR: maximum message length exceeded (" + maxmsg + "): buffered data discarded"); msg.setLength(0); } msg.append(c); } } } private void handleReceivedSerialLine(String msg) { log("Complete message: '" + msg + "'"); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: application/octet-stream Size: 8234 bytes Desc: SerialTest.java URL: From torn878 at googlemail.com Thu Aug 6 03:01:38 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 11:01:38 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Hi Ilkka and Michael, @Ilkka: I also use your code for testing. I didn't want to post my "original code", because it is too long. So hacked your hack ( *g* ) for showing my problem. I hope it is no problem for you. @Michael: Thanks for your very improved SerialEvent. But now I'm sure that my mistake isn't at SerialEvent, but it is at my send-method (doTest). A also get no data with the "improved" version from Michael. I still get OUTPUT_BUFFER_EMPTY - Event but no DATA_AVAILABLE - Events. Please can you take a look at my send-method - especially at the flush - method if I use it in a correct way! Thanks a lot! 2009/8/6 Ilkka Myller > Bernhard, I see that you have added your event handler method over code I > sent you to test just the SerialPort.close() method. It was a quick hack to > test port closing - and just that. > > I completely agree with Michael here. In addition that you have not > specified which events you want to receive (you just left the few "demo" > addNotify...() methods I put there), your event handler does not check which > event is received. > Also the event handler is not well written - it basicly halts the event > handling in an almost infinite read loop when *any* event is received. > > -- > I > > > Michael Erskine kirjoitti 6.8.2009 kello 11.05: > > > There's way too much work being done in this event handler: I also see >> that every event will be greeted with a new char[100] constructor and an >> excessive amount of casting and String concatenation. Did you know you can >> (and probably should) call read with a byte[] argument? Plus I doubt you can >> assume that each "line" received by your handler will always represent a >> "line" sent by the other end: deal with possible buffering and decouple the >> byte handling from the message handling. >> >> Regards, >> Michael Erskine. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 03:18:46 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 12:18:46 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> Message-ID: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> > Hi Ilkka and Michael, > > @Ilkka: I also use your code for testing. I didn't want to post my > "original code", because it is too long. So hacked your hack ( *g* ) > for showing my problem. I hope it is no problem for you. Bernhard: That original code I sent you privately was a simple port open -> close with added manual console logging outputs to pin-point the "hangs" in your system .. no event-handlers etc. Problem here is that the code was a partial copy-paste and a 2-minute hack from a proprietary project source I'm not allowed to post to public forums. Even with your extensive modifications to my sample code it's header comments, formatting and variable names are still clearly identifiable to the original source. That is the very reason I sent it to you privately with separate note that it should not be posted here. But no big harm done, but could we please *stop re-posting* it now. :) Michael: Your corrections to the event handling are good example how things should be done. -- I From michael.erskine at ketech.com Thu Aug 6 03:44:06 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 10:44:06 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of > Ilkka Myller > Sent: 06 August 2009 10:19 > To: rxtx > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > doesn't works (OS: Linux) > Problem here is that the code was a partial copy-paste and a 2-minute > hack from a proprietary project source I'm not allowed to post to > public forums. > Even with your extensive modifications to my sample code it's header > comments, formatting and variable names are still clearly identifiable > to the original source. I'm in a similar situation here at work: the serial/protocol libraries I have written belong to the company I work for and can't easily be presented as examples. When I have time (one glorious day!) I'll write a LGPL serial package from scratch that wraps JavaComm/RXTX with best practices for typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. I'm sure my employers would be fine with this due to what RXTX has given us (although I'm not sure if they appreciate the extent of the debt we owe to the RXTX project!) Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 08:50:53 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 16:50:53 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> <29c18e410908060201x681e3701w1055d4e5ff596edc@mail.gmail.com> <6AF4D2BD-B5C4-4B26-B007-CBD7A91413FA@myller.com> <06BA3262D918014F9183B66425D5A8D465EF63452B@no-sv-03.ketech.local> Message-ID: <29c18e410908060750k57b45cdyd85b42afaa8826ec@mail.gmail.com> Hi guys, now I solved my problem. Sorry, I can't say what I've done. I used an older version of my serial connect and now it works fine. I also can't find any bigger differences between the two versions (at serial connect)... If somebody have the same problem like me, tell me with an email and I will give you a working copy of my source-code. Thanks to all! (particulary to Michael and Ilkka) Have a nice day! 2009/8/6 Michael Erskine > > -----Original Message----- > > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of > > Ilkka Myller > > Sent: 06 August 2009 10:19 > > To: rxtx > > Subject: Re: [Rxtx] sending is very slow (512ms) and inputStream.read() > > doesn't works (OS: Linux) > > > Problem here is that the code was a partial copy-paste and a 2-minute > > hack from a proprietary project source I'm not allowed to post to > > public forums. > > Even with your extensive modifications to my sample code it's header > > comments, formatting and variable names are still clearly identifiable > > to the original source. > > I'm in a similar situation here at work: the serial/protocol libraries I > have written belong to the company I work for and can't easily be presented > as examples. When I have time (one glorious day!) I'll write a LGPL serial > package from scratch that wraps JavaComm/RXTX with best practices for > typical usage that are cross-platform, efficient, and (AFAICT) bulletproof. > I'm sure my employers would be fine with this due to what RXTX has given us > (although I'm not sure if they appreciate the extent of the debt we owe to > the RXTX project!) > > Regards, > Michael Erskine. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kmuldoon at truebluedot.com Thu Aug 6 11:07:51 2009 From: kmuldoon at truebluedot.com (Kevin Muldoon) Date: Thu, 6 Aug 2009 13:07:51 -0400 Subject: [Rxtx] i1 Eye One Spectrophotometer Message-ID: Does anyone have a list of serial commands the i1 Eye One Spectrophotometer uses? We're successfully communicating with a DTP41 Strip reading Spectro using KeySpan and need to add EyeOne support. Thanks. -- TrueBlueDot - Fine Art Printing Kevin Muldoon, Owner New Haven, CT 06511 203.215.8601 kmuldoon at truebluedot.com www.truebluedot.com "Our pigment meets your imagination" -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at triera.net Sun Aug 9 06:18:39 2009 From: andy at triera.net (Andy Rozman) Date: Sun, 09 Aug 2009 14:18:39 +0200 Subject: [Rxtx] bluetooth... take 2 Message-ID: <4A7EBE9F.8030203@triera.net> Hi ! I was trying to go through all posts of previous years, but its quite hard since we don't have any searchable list archive (at least I get just some entried from 2005)... Ok, so problem is this. With help of Trent I discovered where the problem is, at least where I think it is... On first init of CommPortIdentifier (in static context) my BT port (actually both of them) are detected, but in getPortIdentifiers() when they are created (accessed) again port I need is missing... After I read few digests, I think that problem is in Windows native file. On second read there are probably some flags added when opening port and therefore my COM port is not found. I would need some help (from someone who has done this before) so that changes to this .dll file could be made, so that on next read (2nd), COM port won't use flags that make it unusable for me. If this works, we could provide this file to all developers, that want to use BT ports, as alternative to "normal" file... I don't know if this problem is also present on linux, because at this time I had no luck configuring it on Linux... at least not with virtual COMs availables. For now I am using very old javax.comm implementation from IBM and this one works ok (I used this one before I used rxtx). When I specify correct port it connects to it and communication with device is working... I hope somebody can help me. Andy From byhisdeeds at gmail.com Tue Aug 18 11:41:32 2009 From: byhisdeeds at gmail.com (John Preston) Date: Tue, 18 Aug 2009 12:41:32 -0500 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable Message-ID: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> I'm using RXTX-2.1-7 to try and connect to a serial device that I have connected to my fedora linux FC8 box using a serial to usb cable. The port it uses is /dev/ttyACM0, and I can talk to the device using the minicom serial communication program. However when I try to use the RXTX library to open the port it tells me that the port cannot be found. It only see's ttyS0 and ttyS1. Is there something that I'm missing? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisdyingdream at gmail.com Tue Aug 18 12:00:40 2009 From: thisdyingdream at gmail.com (Steven Harms) Date: Tue, 18 Aug 2009 14:00:40 -0400 Subject: [Rxtx] Cannot access serial device connected via a serial to usb cable In-Reply-To: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> References: <14320c890908181041h1adf3994ybcf2810d9efd6638@mail.gmail.com> Message-ID: Have you updated your javax.comm.properties file? On Tue, Aug 18, 2009 at 1:41 PM, John Preston wrote: > I'm using RXTX-2.1-7 to try and connect to a serial device that I have > connected to my fedora linux FC8 box using a serial to usb cable. The port > it uses is /dev/ttyACM0, and I can talk to the device using the minicom > serial communication program. However when I try to use the RXTX library to > open the port it tells me that the port cannot be found. It only see's ttyS0 > and ttyS1. > > Is there something that I'm missing? > > John > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- GPG Key ID: C92EF367 / 1428 FE8E 1E07 DDA8 EFD7 195F DCCD F5B3 C92E F367 WWW: http://www.sharms.org/blog From beat.arnet at gmail.com Tue Aug 18 19:00:25 2009 From: beat.arnet at gmail.com (Beat Arnet) Date: Tue, 18 Aug 2009 21:00:25 -0400 Subject: [Rxtx] Error 0x3e3 at termios.c(1301) In-Reply-To: References: Message-ID: For the record, the crash was due to the buffer overflow in the YACK() function. http://mailman.qbang.org/pipermail/rxtx/2009-April/4196248.html Problem solved. Beat On Mon, May 18, 2009 at 3:27 PM, Beat Arnet wrote: > All, > I am experiencing a situation in which RXTX crashes consistently (both with > 2.1 and 2.2). > Steps to reproduce: > - computer with JAVA program is sending bytes over RS-232 to embedded > device, embedded device is off > - embedded device powers up and transmit startup banner > - JVM crashes: Error 0x3e3 at termios.c(1301) > > Any idea of what I should be looking for? > Thanks! > Beat > > # > # An unexpected error has been detected by Java Runtime Environment: > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6163696c, pid=808, > tid=9648 > # > # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode) > # Problematic frame: > # C 0x6163696c > # > # If you would like to submit a bug report, please visit: > # http://java.sun.com/webapps/bugreport/crash.jsp > # > > --------------- T H R E A D --------------- > > Current thread (0x0af7e400): JavaThread "Thread-4" [_thread_in_native, > id=9648] > > siginfo: ExceptionCode=0xc0000005, reading address 0x6163696c > > Registers: > EAX=0xffffffff, EBX=0x78652064, ECX=0x7c90f661, EDX=0x00000005 > ESP=0x0c68f990, EBP=0x70706120, ESI=0x6f207469, EDI=0x6e612072 > EIP=0x6163696c, EFLAGS=0x00010206 > > Top of Stack: (sp=0x0c68f990) > 0x0c68f990: 6e6f6974 71657220 74736575 0a0a0d2e > 0x0c68f9a0: 00000000 0c68f9d4 6d94556c 0daa3cb4 > 0x0c68f9b0: 74697277 74794265 3e0d2065 0a000a3e > 0x0c68f9c0: 7c90cfea 7c80a059 000007d4 0af7e400 > 0x0c68f9d0: 6d909d8d 000007d4 00000002 6d945bf6 > 0x0c68f9e0: 0af7e400 00000001 00000000 0af8b024 > 0x0c68f9f0: 00000032 0af8b038 00000002 00000000 > 0x0c68fa00: 00000000 0af7e400 0af8b02c 06e85900 > > Instructions: (pc=0x6163696c) > 0x6163695c: > [error occurred during error reporting, step 100, id 0xc0000005] > > Stack: [0x0c640000,0x0c690000), sp=0x0c68f990, free space=318k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native > code) > C 0x6163696c > > [error occurred during error reporting, step 120, id 0xc0000005] > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j gnu.io.RXTXPort.writeByte(IZ)V+0 > j gnu.io.RXTXPort$SerialOutputStream.write(I)V+86 > j codeskin.serial.SerialPortRxtx2_1.write(I)V+29 > j codeskin.c2oooprog.BootLoader2xxx$PingTask.run()V+87 > v ~StubRoutines::call_stub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From byhisdeeds at gmail.com Wed Aug 19 07:42:53 2009 From: byhisdeeds at gmail.com (John Preston) Date: Wed, 19 Aug 2009 08:42:53 -0500 Subject: [Rxtx] Reading characters from serial port Message-ID: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> I am new to rxtx and am trying to communicate with a serial device. I send a string command to it and it should respond with a ascii string terminated with a carriage return character (hex 13). I send the command string ok and the outputbufferempty event triggers telling me that it is probably sent. However I don't get the dataavailable event being triggered to read anything. In fooling around yesterday I got it to read some characters from the device so I think the communication has been established but that maybe I am not triggering the dataavailableevent because some required termination is missing. Can anyone help me and point me as to where I'm missing something. john -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Aug 20 17:39:41 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 20 Aug 2009 17:39:41 -0600 (MDT) Subject: [Rxtx] Reading characters from serial port In-Reply-To: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: On Wed, 19 Aug 2009, John Preston wrote: > I am new to rxtx and am trying to communicate with a serial device. I send a > string command to it and it should respond with a ascii string terminated > with a carriage return character (hex 13). I send the command string ok and > the outputbufferempty event triggers telling me that it is probably sent. > However I don't get the dataavailable event being triggered to read > anything. In fooling around yesterday I got it to read some characters from > the device so I think the communication has been established but that maybe > I am not triggering the dataavailableevent because some required termination > is missing. > > Can anyone help me and point me as to where I'm missing something. > Hi John, Could we see the code/data you are using that you think is sending the terminator character and 'string?' -- Trent Jarvi tjarvi at qbang.org From byhisdeeds at gmail.com Fri Aug 21 08:25:03 2009 From: byhisdeeds at gmail.com (John Preston) Date: Fri, 21 Aug 2009 09:25:03 -0500 Subject: [Rxtx] Reading characters from serial port In-Reply-To: References: <14320c890908190642v426b485awb64b8d84556256c1@mail.gmail.com> Message-ID: <14320c890908210725q6ecbbf8cj477c97d9d51f5e87@mail.gmail.com> My code is: ========================================================== package nulltest; // derived from SUN's examples in the javax.comm package import java.io.*; import java.util.*; import gnu.io.*; // for rxtxSerial library public class nulltest implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static CommPortIdentifier saveportId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static String messageString = "V"; static OutputStream outputStream; static boolean outputBufferEmptyFlag = false; public static void main(String[] args) { boolean portFound = false; String defaultPort = "/dev/ttyUSB0"; if (args.length > 0) { defaultPort = args[0]; } System.out.println("Set default port to " + defaultPort); // parse ports and if the default port is found, initialized the reader 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; // init reader thread nulltest reader = new nulltest(); } } } if (!portFound) { System.out.println("port " + defaultPort + " not found."); } } public void initwritetoport() { // initwritetoport() assumes that the port has already been opened and // initialized by "public nulltest()" try { // get the outputstream outputStream = serialPort.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } } public void writetoport() { System.out.println("Writing \"" + messageString + "\" to " + serialPort.getName()); try { // write string to serial port outputStream.write((messageString+"\r").getBytes()); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } } public nulltest() { // initalize serial port try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { e.printStackTrace(); } try { inputStream = serialPort.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { serialPort.addEventListener(this); } catch (TooManyListenersException e) { e.printStackTrace(); } // activate the DATA_AVAILABLE notifier serialPort.notifyOnOutputEmpty(true); serialPort.notifyOnDataAvailable(true); try { // set port parameters serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } try { // set port parameters serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); } // start the read thread readThread = new Thread(this); readThread.start(); } public void run() { // first thing in the thread, we initialize the write operation initwritetoport(); try { while (true) { // write string to port, the serialEvent will read it writetoport(); Thread.sleep(10000); } } catch (Exception e) { e.printStackTrace(); } } public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: System.out.println("SerialPortEvent.BI event: " + event); break; case SerialPortEvent.OE: System.out.println("SerialPortEvent.OE event: " + event); break; case SerialPortEvent.FE: System.out.println("SerialPortEvent.FE event: " + event); break; case SerialPortEvent.PE: System.out.println("SerialPortEvent.PE event: " + event); break; case SerialPortEvent.CD: System.out.println("SerialPortEvent.CD event: " + event); break; case SerialPortEvent.CTS: System.out.println("SerialPortEvent.CTS event: " + event); break; case SerialPortEvent.DSR: System.out.println("SerialPortEvent.DSR event: " + event); break; case SerialPortEvent.RI: System.out.println("SerialPortEvent.RI event: " + event); break; case SerialPortEvent.OUTPUT_BUFFER_EMPTY: System.out.println("SerialPortEvent.OUTPUT_BUFFER_EMPTY event: " + event); break; case SerialPortEvent.DATA_AVAILABLE: System.out.println("SerialPortEvent.DATA_AVAILABLE event: " + event); // we get here if data has been received StringBuffer out = new StringBuffer(); byte[] readBuffer = new byte[200]; try { // read data while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); out.append(new String(readBuffer, 0, numBytes)); } System.out.println("Read: " + out.toString()); } catch (IOException e) { e.printStackTrace(); } break; } } } ================================================== The device returns the following characters in response to the V command: V22 (ascii) or 0x56 0x32 0x32 0x0a (hex) John From breno.leitao at gmail.com Tue Aug 25 12:14:44 2009 From: breno.leitao at gmail.com (Breno Leitao) Date: Tue, 25 Aug 2009 15:14:44 -0300 Subject: [Rxtx] bug#112 Message-ID: <1e464b5b0908251114t4692851bpe347c32076aefdf2@mail.gmail.com> Hi Guys, I was able to reproduce bug#112 in my machine. Any idea if there is anyone working in this bug ? Also, I tried to get the rxtx cvs code, but I was unable, since password (mousy) seems to be invalid. Any update on this ? Thanks Breno -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob_Jacobsen at lbl.gov Sun Aug 30 11:07:57 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 10:07:57 -0700 Subject: [Rxtx] RXTX on Snow Leopard Message-ID: JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried to open a port: At 10:34 AM +0000 8/30/09, pmansvelder wrote: >Caught >java.lang.UnsatisfiedLinkError: >/Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >architecture in universal wrapper while loading driver >gnu.io.RXTXCommDriver A little Googling seems to indicate that 10.6 is looking for a "x86_64" processor architecture, as opposed to the previous "i386". JMRI users don't generally have the capability to build software, so we've had them use a slightly modified version of the older .pkg RXTX installer for RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the program to the gnu.io namespace) Has anybody created a more recent MacOS X installer that will work for Snow Leopard? Preferably, for both namespaces, but we can move the migration schedule up if only the gnu.io form is available. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 14:55:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 14:55:09 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > JMRI uses RXTX, and we had a first report of trouble today for RXTX on Mac OS > X 10.6, a.k.a as Snow Leopard. A user reported an exception when RXTX tried > to open a port: > > At 10:34 AM +0000 8/30/09, pmansvelder wrote: >> Caught >> java.lang.UnsatisfiedLinkError: >> /Library/Java/Extensions/librxtxSerial.jnilib: no suitable image found. >> Did find: /Library/Java/Extensions/librxtxSerial.jnilib: no matching >> architecture in universal wrapper while loading driver >> gnu.io.RXTXCommDriver > > A little Googling seems to indicate that 10.6 is looking for a "x86_64" > processor architecture, as opposed to the previous "i386". > > JMRI users don't generally have the capability to build software, so we've > had them use a slightly modified version of the older .pkg RXTX installer for > RXTX 2.0.7 (javax.comm namespace; we're in the process of converting the > program to the gnu.io namespace) > > Has anybody created a more recent MacOS X installer that will work for Snow > Leopard? Preferably, for both namespaces, but we can move the migration > schedule up if only the gnu.io form is available. > Hi Bob, RXTX 2.0 currently does not have a champion bringing it forward. I can think of a few options. 1) put the rxtx changes in gnu.io into another release of rxtx 2.0. This would basically be same work of changing package names back to javax.comm. contrib/ChangePackage.sh automates most of the work for you. I could compile a snow lepard package if you bring the source code changes over. 2) If we really are going to keep 2.0 alive, perhaps a more maintainable solution is in order. The javax.comm namespace could be included in the current gnu.io work. The exceptions would need to be dynamically handled in some fashion to map into the right namespace. 3) move to gnu.io. It should be possib;e to use the ChangePackage.sh script against your codebase and switch fairly quickly. Just recompiling the existing 2.0 code would not be enough for x86_64 maci. There are 64 bit fixes and concurrency fixes that would need to be applied for it to work well. In the past, I just took the rxtx 2.1 code and changed the namespace for 2.0. -- Trent Jarvi tjarvi at qbang.org From Bob_Jacobsen at lbl.gov Sun Aug 30 15:29:07 2009 From: Bob_Jacobsen at lbl.gov (Bob Jacobsen) Date: Sun, 30 Aug 2009 14:29:07 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >3) move to gnu.io. > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in the wrong places, but I haven't found one yet. Bob -- Bob Jacobsen, UC Berkeley jacobsen at berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG From tjarvi at qbang.org Sun Aug 30 15:41:27 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Sun, 30 Aug 2009 15:41:27 -0600 (MDT) Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: On Sun, 30 Aug 2009, Bob Jacobsen wrote: > At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >> 3) move to gnu.io. >> > > Is there an gnu.io RXTX installer for Snow Leopard? I'm probably looking in > the wrong places, but I haven't found one yet. > Hi Bob, I don't know if anyone has done an installer. I'm not familiar with what that requires. We just have binaries at rxtx.org. I need to push rxtx 2.2 out the door. It is more like an incremental update to rxtx 2.1. The prerelease binaries and source are in our pub dir. http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 10:37:59 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:37:59 -0700 Subject: [Rxtx] RXTX on Snow Leopard In-Reply-To: References: Message-ID: <6E394A94-9928-442E-B1A9-D491C0B064EC@sun.com> I just downloaded the rxt-2.2 pr22 bins, and I get 2 errors (with Snow Leopard) [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f The warning seems fishy to me, I copied in the RXTXcomm and librxtxSerial from the zip file I downloaded. I am hoping that the invalid memory access is related to mismatch, although I dont put much hope in it being the case as Java code should not be able to cause this. On Aug 30, 2009, at 2:41 PM, Trent Jarvi wrote: > > > On Sun, 30 Aug 2009, Bob Jacobsen wrote: > >> At 2:55 PM -0600 8/30/09, Trent Jarvi wrote: >>> 3) move to gnu.io. >> >> Is there an gnu.io RXTX installer for Snow Leopard? I'm probably >> looking in the wrong places, but I haven't found one yet. >> > > Hi Bob, > > I don't know if anyone has done an installer. I'm not familiar with > what that requires. > > We just have binaries at rxtx.org. I need to push rxtx 2.2 out the > door. It is more like an incremental update to rxtx 2.1. The > prerelease binaries and source are in our pub dir. > > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2.zip > http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From Eric.Arseneau at Sun.COM Mon Aug 31 10:40:12 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 09:40:12 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? Message-ID: I did not quite get what the status was from the previous e-mail. I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors [java] WARNING: RXTX Version mismatch [java] Jar version = RXTX-2.2pre1 [java] native lib Version = RXTX-2.2pre2 [java] Invalid memory access of location 0x114649938 rip=0x11453e12f I think I will try to build my own binaries, which I hope should be pretty straightforward for Mac. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 13:14:25 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 12:14:25 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Not a very knowledgeable Mac developer. I installed latest update of Xcode and got the source to try and build. Building with Xcode is not working, getting errors and such. Hoping someone will put out binaries for 10.6 soon :( Or updated source to do it. I checked out code from CVS to see if it was in a better state. Is there a better/simpler way to build than using Xcode GUI? On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > I did not quite get what the status was from the previous e-mail. > > I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > and got 2 errors > [java] WARNING: RXTX Version mismatch > [java] Jar version = RXTX-2.2pre1 > [java] native lib Version = RXTX-2.2pre2 > [java] Invalid memory access of location 0x114649938 > rip=0x11453e12f > > I think I will try to build my own binaries, which I hope should be > pretty straightforward for Mac. > > Thank you, > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnny.luong at trustcommerce.com Mon Aug 31 13:33:14 2009 From: johnny.luong at trustcommerce.com (Johnny Luong) Date: Mon, 31 Aug 2009 12:33:14 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <4A9C257A.5090301@trustcommerce.com> Eric Arseneau wrote: > Not a very knowledgeable Mac developer. I installed latest update of > Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from >> http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx Hi Eric, I think it's just a bug in the packaging of the strings for the first set of errors. Once Trent puts out the final version, it'll have a consistent version number reported in the JAR file and in the DLL/SO in your environment. As for the memory access issue, it might be best to recompile it with debugging symbols and see if it generates a stack trace that is useful. (it does this on windows when it dumps an hs_err.log file) Best, Johnny From ilkka at myller.com Mon Aug 31 13:58:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 31 Aug 2009 22:58:31 +0300 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: Hi Eric, The 2.2pre2-release does not include recently posted segmentation fault patch. The patch very likely fixes the invalid memory access error you are experiencing. CVS code should work ok. I've also noticed that Xcode project included with the source is *really* old. It's basicly not usable with modern Xcode .. and it's been like that for a very long time. Instead of fixing Xcode build-configs I suggest you do normal configure/make build from the source. That seems to work ok with 10.5/10.6. I would be happy to work on an updated Xcode project for rxtx, but I'm currently unable to get the latest CVS revisions. The rxtx cvs server has bad route tables/isp connection etc. and it's unreachable from multiple european ISP's subnets. Including the one I use. -- I > Not a very knowledgeable Mac developer. I installed latest update > of Xcode and got the source to try and build. > > Building with Xcode is not working, getting errors and such. Hoping > someone will put out binaries for 10.6 soon :( Or updated source to > do it. > > I checked out code from CVS to see if it was in a better state. Is > there a better/simpler way to build than using Xcode GUI? > > On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: > >> I did not quite get what the status was from the previous e-mail. >> >> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >> and got 2 errors >> [java] WARNING: RXTX Version mismatch >> [java] Jar version = RXTX-2.2pre1 >> [java] native lib Version = RXTX-2.2pre2 >> [java] Invalid memory access of location 0x114649938 >> rip=0x11453e12f >> >> I think I will try to build my own binaries, which I hope should be >> pretty straightforward for Mac. >> >> Thank you, >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 15:27:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 15:27:56 -0600 (MDT) Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Ilkka Myller wrote: > I would be happy to work on an updated Xcode project for rxtx, but I'm > currently unable to get the latest CVS revisions. The rxtx cvs server has > bad route tables/isp connection etc. and it's unreachable from multiple > european ISP's subnets. Including the one I use.? > I'm beaming a copy of the rxtx cvs over to another server. I'll post an update when it is done. -- Trent Jarvi tjarvi at qbang.org From Eric.Arseneau at Sun.COM Mon Aug 31 16:12:01 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:12:01 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> I get the following: ------------------------------------------------------ The JCL extension to RxTx requires comm.jar If you intend to use RxTx for commapi support comm.jar needs to be located in /System/Library/Frameworks/JavaVM.framework/ Versions/1.6.0/Home/lib/ext/comm.jar You can either quit configure and place the jar in the correct location or let this script do it. ------------------------------------------------------ Do you wish to [Q]uit or use the [S]cript? [Q/S]S Why do I need a comm.jar? I've found a couple of them. On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > Hi Eric, > > The 2.2pre2-release does not include recently posted segmentation > fault patch. The patch very likely fixes the invalid memory access > error you are experiencing. CVS code should work ok. > > I've also noticed that Xcode project included with the source is > *really* old. It's basicly not usable with modern Xcode .. and it's > been like that for a very long time. > > Instead of fixing Xcode build-configs I suggest you do normal > configure/make build from the source. That seems to work ok with > 10.5/10.6. > > I would be happy to work on an updated Xcode project for rxtx, but > I'm currently unable to get the latest CVS revisions. The rxtx cvs > server has bad route tables/isp connection etc. and it's unreachable > from multiple european ISP's subnets. Including the one I use. > > -- > I > >> Not a very knowledgeable Mac developer. I installed latest update >> of Xcode and got the source to try and build. >> >> Building with Xcode is not working, getting errors and such. >> Hoping someone will put out binaries for 10.6 soon :( Or updated >> source to do it. >> >> I checked out code from CVS to see if it was in a better state. Is >> there a better/simpler way to build than using Xcode GUI? >> >> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >> >>> I did not quite get what the status was from the previous e-mail. >>> >>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>> and got 2 errors >>> [java] WARNING: RXTX Version mismatch >>> [java] Jar version = RXTX-2.2pre1 >>> [java] native lib Version = RXTX-2.2pre2 >>> [java] Invalid memory access of location 0x114649938 >>> rip=0x11453e12f >>> >>> I think I will try to build my own binaries, which I hope should >>> be pretty straightforward for Mac. >>> >>> Thank you, >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eric.Arseneau at Sun.COM Mon Aug 31 16:36:55 2009 From: Eric.Arseneau at Sun.COM (Eric Arseneau) Date: Mon, 31 Aug 2009 15:36:55 -0700 Subject: [Rxtx] Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> References: <2DE6ED55-7D92-4DAE-92C1-8BC0D0FA8EE6@sun.com> Message-ID: <18F1BC7F-BA8E-4FAF-B50C-CF9BBB5B789D@sun.com> Ok I found a version of it already on my machine and have been able to build it. Now to see if it will work :) On Aug 31, 2009, at 3:12 PM, Eric Arseneau wrote: > I get the following: > ------------------------------------------------------ > The JCL extension to RxTx requires comm.jar > If you intend to use RxTx for commapi support comm.jar > needs to be located in /System/Library/Frameworks/JavaVM.framework/ > Versions/1.6.0/Home/lib/ext/comm.jar > > You can either quit configure and place the jar in the > correct location or let this script do it. > > ------------------------------------------------------ > Do you wish to [Q]uit or use the [S]cript? [Q/S]S > > Why do I need a comm.jar? I've found a couple of them. > > On Aug 31, 2009, at 12:58 PM, Ilkka Myller wrote: > >> Hi Eric, >> >> The 2.2pre2-release does not include recently posted segmentation >> fault patch. The patch very likely fixes the invalid memory access >> error you are experiencing. CVS code should work ok. >> >> I've also noticed that Xcode project included with the source is >> *really* old. It's basicly not usable with modern Xcode .. and it's >> been like that for a very long time. >> >> Instead of fixing Xcode build-configs I suggest you do normal >> configure/make build from the source. That seems to work ok with >> 10.5/10.6. >> >> I would be happy to work on an updated Xcode project for rxtx, but >> I'm currently unable to get the latest CVS revisions. The rxtx cvs >> server has bad route tables/isp connection etc. and it's >> unreachable from multiple european ISP's subnets. Including the one >> I use. >> >> -- >> I >> >>> Not a very knowledgeable Mac developer. I installed latest update >>> of Xcode and got the source to try and build. >>> >>> Building with Xcode is not working, getting errors and such. >>> Hoping someone will put out binaries for 10.6 soon :( Or updated >>> source to do it. >>> >>> I checked out code from CVS to see if it was in a better state. >>> Is there a better/simpler way to build than using Xcode GUI? >>> >>> On Aug 31, 2009, at 9:40 AM, Eric Arseneau wrote: >>> >>>> I did not quite get what the status was from the previous e-mail. >>>> >>>> I downloaded the zip binaries from http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip >>>> and got 2 errors >>>> [java] WARNING: RXTX Version mismatch >>>> [java] Jar version = RXTX-2.2pre1 >>>> [java] native lib Version = RXTX-2.2pre2 >>>> [java] Invalid memory access of location 0x114649938 >>>> rip=0x11453e12f >>>> >>>> I think I will try to build my own binaries, which I hope should >>>> be pretty straightforward for Mac. >>>> >>>> Thank you, >>>> _______________________________________________ >>>> Rxtx mailing list >>>> Rxtx at qbang.org >>>> http://mailman.qbang.org/mailman/listinfo/rxtx >>> >>> _______________________________________________ >>> Rxtx mailing list >>> Rxtx at qbang.org >>> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Mon Aug 31 17:03:40 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 31 Aug 2009 17:03:40 -0600 (MDT) Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: On Mon, 31 Aug 2009, Trent Jarvi wrote: > On Mon, 31 Aug 2009, Ilkka Myller wrote: > >> I would be happy to work on an updated Xcode project for rxtx, but I'm >> currently unable to get the latest CVS revisions. The rxtx cvs server has >> bad route tables/isp connection etc. and it's unreachable from multiple >> european ISP's subnets. Including the one I use.? >> > > I'm beaming a copy of the rxtx cvs over to another server. I'll post an > update when it is done. > The server has been beemed to another location for those experiencing routing problems. in bash: export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot cvs login (no passwd) cvs co -r commapi-0-0-1 rxtx-devel -- Trent Jarvi tjarvi at qbang.org From ilkka at myller.com Mon Aug 31 22:07:25 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 1 Sep 2009 07:07:25 +0300 Subject: [Rxtx] new CVS server - was Is 2.2pre1 supposed to run ok on Snow Leopard? In-Reply-To: References: Message-ID: <3682EFB2-5764-407F-9CD6-34752D3DAD69@myller.com> Hi, CVS server is reachable, but when trying anonymous login it replies: " Fatal error, aborting. anonymous: no such system user " It seems that the anonymous cvs account is not yet properly configured on the new system. -- I > On Mon, 31 Aug 2009, Trent Jarvi wrote: > > The server has been beemed to another location for those > experiencing routing problems. > > in bash: > > export CVSROOT=:pserver:anonymous at qbang.org:2401/var/cvs/cvsroot > cvs login (no passwd) > cvs co -r commapi-0-0-1 rxtx-devel > > -- > Trent Jarvi > tjarvi at qbang.org From rxtx at qbang.org Sun Aug 2 13:10:45 2009 From: rxtx at qbang.org (Top Pharmacy) Date: Sun, 2 Aug 2009 15:10:45 -0400 Subject: [Rxtx] MedHealth 798697 Message-ID: <200908021910.n72JAjVC000566@rxtx.qbang.org> An HTML attachment was scrubbed... URL: From cowwoc at bbs.darktech.org Mon Aug 3 11:27:01 2009 From: cowwoc at bbs.darktech.org (cowwoc) Date: Mon, 03 Aug 2009 13:27:01 -0400 Subject: [Rxtx] Feedback needed: using a comport after a timeout Message-ID: <4A771DE5.9050602@bbs.darktech.org> Hi, Can we safely assume that users will always close a comport after a read or write timeout? Does anyone have a real-life counter-example? Thank you, Gili From tjarvi at qbang.org Mon Aug 3 11:52:46 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 3 Aug 2009 13:52:46 -0400 (EDT) Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: On Mon, 3 Aug 2009, cowwoc wrote: > Hi, > > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? > Polling for data with read is the only viable option if the driver does not fully support the line status register. Many 'serial' devices have drivers that represent the UART to varying degrees. -- Trent Jarvi tjarvi at qbang.org From mikeklein at vxappliance.com Mon Aug 3 12:46:10 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 11:46:10 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat Message-ID: <4A773072.2010600@vxappliance.com> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This is on an ubuntu 64-bit system. My onewire code works fine as does code for a keypad/lcd combo. I am using java from a tomcat webapp. However the cid modem on 3rd port doesn't register any activity on ring. I have code setup to register listeners on everything/etc. and successfully send ATCID command (Code used to work)...however on ring of phone I'm not getting RING event with phone#. I definitely have cid service as my home phones do show the CID #. I have verified line to modem (it is plugged into right port!) and there is a dialtone when offhook. I have tested line w/my buttset. Any ideas? I'm at point of getting another modem. From ilkka at myller.com Mon Aug 3 13:28:14 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 22:28:14 +0300 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: Timeout is not always an indication of error (or any other unexpected situation). And even if it were: an error does not always lead to closing of the serial link. This decision depends on the protocol used over serial link. RXTX is an I/O library, not an implementation of any specific communications protocol that might be implemented on top of it. Therefore it can not be safely assumed that users of the I/O library will *always* close the serial port after r/w timeout. Real-life counter-example is pointless here since we can never know for what or how RXTX library will be used. We can only hope users use the RXTX interfaces as documented - for no other reason than to prevent unexpected changes in behaviour of their own software when upgrading the library. And RXTX developers have responsibility to take care that library continues to behave as documented. (to a reasonable degree) And currently, the RXTX does not prefer either interpretation of timeouts and serial port closing. That decision as been left to the protocol implementation. Which is proper. -- I > > > On Mon, 3 Aug 2009, cowwoc wrote: > >> Hi, >> >> Can we safely assume that users will always close a comport after >> a read or write timeout? Does anyone have a real-life counter- >> example? >> > > Polling for data with read is the only viable option if the driver > does not fully support the line status register. > > Many 'serial' devices have drivers that represent the UART to > varying degrees. > > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From ilkka at myller.com Mon Aug 3 14:22:32 2009 From: ilkka at myller.com (Ilkka Myller) Date: Mon, 3 Aug 2009 23:22:32 +0300 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <4A773072.2010600@vxappliance.com> References: <4A773072.2010600@vxappliance.com> Message-ID: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Hi Mike, Are you missing hardware Ring Indicator (RI-signal) or AT Hayes protocol RING message? Or both? Here are some ideas (in form of a checklist): If you meant AT Hayes protocol RING message: 1. Check that your modem is actually connected with some terminal application (AT commands work etc. ... this is basic - I know - sorry) 2. Check that modem is in voice mode (AT#CLS=8) 3. Check that CID reception is enabled (AT#CID=1) (see notes below) 4. Check that verbose AT messages are enabled (including RING) (ATV1) 5. You should receive RING messages with caller id info with both terminal application and RXTX based application. Notes: Depending on what kind of a modem you have Caller-ID (RING) function your are looking for might be enabled with any of the following: AT#CID=1 AT#CLS=8#CID=1 AT#CID=2 AT%CCID=1 AT%CCID=2 AT+VCID=1 AT#CC1 AT*ID1 I suggest you look in your modem AT command reference. I would also reset the modem to factory defaults before starting: AT&F AT&W0 ATZ0 -- If you meant hardware RI signal: 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) connected (loop test it). 2. Check that your modem actually changes RI pin level when call is received (use scope etc.) 3. Check with some generic terminal application that your system receives those RI signal events correctly (if not, RS232->USB converter might not include RI handling in some or all ports) 4. Check that your RXTX based application has enabled RI signal events notification with SerialPort.notifyOnRingIndicator(true) 5. If all above work, both the terminal application and RXTX should be able to detect RI signal events sent by the UART. Notes: RI signal is just a hardware bit/signal from the modem, and it obviously does not in include any CID data as AT Hayes RING message does. Most modems just signal the RI *about* the same time they output the AT RING message. Some before, some after the RING. Just saying this so that you dont assume that RI event is *always* indication that there is RING message already waiting in receive buffer. Common mistake is to: Wait for RI-event -> Receive the RI-event on phone ring -> Go to check if there is data (assumed RING message with CID) waiting in receive buffer -> receive buffer is empty -> fail. Some modems will output the RING message seconds after first RI signal change. Hopefully these tips help. -- I Mike Klein kirjoitti 3.8.2009 kello 21.46: > I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. > This > is on an ubuntu 64-bit system. > > My onewire code works fine as does code for a keypad/lcd combo. I am > using java from a tomcat webapp. > > However the cid modem on 3rd port doesn't register any activity on > ring. > I have code setup to register listeners on everything/etc. and > successfully send ATCID command (Code used to work)...however on > ring of > phone I'm not getting RING event with phone#. > > I definitely have cid service as my home phones do show the CID #. I > have verified line to modem (it is plugged into right port!) and there > is a dialtone when offhook. I have tested line w/my buttset. > > Any ideas? I'm at point of getting another modem. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From mikeklein at vxappliance.com Mon Aug 3 15:52:27 2009 From: mikeklein at vxappliance.com (Mike Klein) Date: Mon, 03 Aug 2009 14:52:27 -0700 Subject: [Rxtx] CID modem code not working under rxtx and java/tomcat In-Reply-To: <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> References: <4A773072.2010600@vxappliance.com> <2304D624-5862-4DF4-91C0-D032B94DF76C@myller.com> Message-ID: <4A775C1B.5040504@vxappliance.com> Thanks immensely for pointers! As code used to work...I guess a re-examination of everything is in order...I will look at your suggestions. mike Ilkka Myller wrote: > Hi Mike, > > Are you missing hardware Ring Indicator (RI-signal) or AT Hayes > protocol RING message? Or both? > > Here are some ideas (in form of a checklist): > > If you meant AT Hayes protocol RING message: > > 1. Check that your modem is actually connected with some terminal > application (AT commands work etc. ... this is basic - I know - sorry) > 2. Check that modem is in voice mode (AT#CLS=8) > 3. Check that CID reception is enabled (AT#CID=1) (see notes below) > 4. Check that verbose AT messages are enabled (including RING) (ATV1) > 5. You should receive RING messages with caller id info with both > terminal application and RXTX based application. > > Notes: > > Depending on what kind of a modem you have Caller-ID (RING) function > your are looking for might be enabled with any of the following: > AT#CID=1 > AT#CLS=8#CID=1 > AT#CID=2 > AT%CCID=1 > AT%CCID=2 > AT+VCID=1 > AT#CC1 > AT*ID1 > > I suggest you look in your modem AT command reference. > > I would also reset the modem to factory defaults before starting: > AT&F > AT&W0 > ATZ0 > > -- > > If you meant hardware RI signal: > > 1. Check that your cable (DB9 connector, I assume) has pin #9 (RI) > connected (loop test it). > 2. Check that your modem actually changes RI pin level when call is > received (use scope etc.) > 3. Check with some generic terminal application that your system > receives those RI signal events correctly (if not, RS232->USB > converter might not include RI handling in some or all ports) > 4. Check that your RXTX based application has enabled RI signal events > notification with SerialPort.notifyOnRingIndicator(true) > 5. If all above work, both the terminal application and RXTX should be > able to detect RI signal events sent by the UART. > > Notes: > RI signal is just a hardware bit/signal from the modem, and it > obviously does not in include any CID data as AT Hayes RING message does. > > Most modems just signal the RI *about* the same time they output the > AT RING message. Some before, some after the RING. > Just saying this so that you dont assume that RI event is *always* > indication that there is RING message already waiting in receive buffer. > Common mistake is to: Wait for RI-event -> Receive the RI-event on > phone ring -> Go to check if there is data (assumed RING message with > CID) waiting in receive buffer -> receive buffer is empty -> fail. > Some modems will output the RING message seconds after first RI signal > change. > > > Hopefully these tips help. > > -- > I > > > Mike Klein kirjoitti 3.8.2009 kello 21.46: > >> I have a usb to 8xdb9 converter box that creates /dev/ttyUSB{0-7}. This >> is on an ubuntu 64-bit system. >> >> My onewire code works fine as does code for a keypad/lcd combo. I am >> using java from a tomcat webapp. >> >> However the cid modem on 3rd port doesn't register any activity on ring. >> I have code setup to register listeners on everything/etc. and >> successfully send ATCID command (Code used to work)...however on ring of >> phone I'm not getting RING event with phone#. >> >> I definitely have cid service as my home phones do show the CID #. I >> have verified line to modem (it is plugged into right port!) and there >> is a dialtone when offhook. I have tested line w/my buttset. >> >> Any ideas? I'm at point of getting another modem. >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From m.j.tandy at warwick.ac.uk Mon Aug 3 15:59:20 2009 From: m.j.tandy at warwick.ac.uk (Michael Tandy) Date: Mon, 3 Aug 2009 22:59:20 +0100 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <4A771DE5.9050602@bbs.darktech.org> References: <4A771DE5.9050602@bbs.darktech.org> Message-ID: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. From torn878 at googlemail.com Tue Aug 4 02:20:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 10:20:29 +0200 Subject: [Rxtx] Application hangs up at serialPort.close() Message-ID: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Hi guys! The last days I have tried 1000 solution regarding that known issue. But nothing - absolute nothing - works for me. With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash - also a known problem...) ). The problems are always the same: -> removeEventListener() takes a very long time (about 5 seconds) -> the CloseTheard is hanging up totally at port.close() I know that there are difficulties with IOLock... What can I do to solve this problem? ---------------------------------------------------------------------------- Here is my code for closing my serial port: ---------------------------------------------------------------------------- class CloseThread extends Thread { public void run() { port.removeEventListener(); port.close(); } } public void closePort() { try { if (port != null) { port.getInputStream().close(); port.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} } ----------------------------------------------------------------------- Thanks a lot! Bernhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Tue Aug 4 03:19:44 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 4 Aug 2009 12:19:44 +0300 Subject: [Rxtx] Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> Message-ID: Hi, I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from repositories: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu repositories have only 2.1.7r2-4) The created a small application that opens the serial port, registers serial port event listeners, sends few kilobytes of data to loopback adapter and receives it. I copied your closing methods (that one with CloseThread etc.) and used them to close the serial port in my code. I tested with native RS232 UART, Prolific USB-adapter and FTDI USB - adapter. Everything worked perfectly. No hangs at port.close(). Maybe you could provide more information so this issue could be reproduced. -- I Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > Hi guys! > The last days I have tried 1000 solution regarding that known issue. > But nothing - absolute nothing - works for me. > With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 > and RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 > bit (JVM-Crash - also a known problem...) ). > > The problems are always the same: > > -> removeEventListener() takes a very long time (about 5 seconds) > -> the CloseTheard is hanging up totally at port.close() > > I know that there are difficulties with IOLock... What can I do to > solve this problem? > > ---------------------------------------------------------------------------- > Here is my code for closing my serial port: > ---------------------------------------------------------------------------- > > class CloseThread extends Thread > { > public void run() > { > port.removeEventListener(); > port.close(); > } > } > > > public void closePort() > { > > try > { > if (port != null) > { > port.getInputStream().close(); > port.getOutputStream().close(); > > new CloseThread().start(); > > } > > } > catch (Exception e) {} > } > > ----------------------------------------------------------------------- > > Thanks a lot! > > Bernhard > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Tue Aug 4 05:18:01 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Tue, 4 Aug 2009 13:18:01 +0200 Subject: [Rxtx] Fwd: Application hangs up at serialPort.close() In-Reply-To: <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> References: <29c18e410908040120r6a3e6c86tc4d4467a01cd9b4@mail.gmail.com> <29c18e410908040416t161719bbqbfa2dba8408b7c73@mail.gmail.com> Message-ID: <29c18e410908040418s12bbbe16oc6f9a9971ee13d55@mail.gmail.com> Hi Ikka,that's crazy... My System: -> Ubuntu 9.04 (amd64) - I also tried it with Xubuntu 8.10 (i686) -> the same result -> Java 1.6.0-14 -> RxTx 2.2pre (from wiki) -> USB - FTDI (for canusb - dongle from canusb.com) Mabye you can send your piece of code and I will try it on my machine. Perhaps the mistake is in my program and has nothing to do with RxTx... I don't know. More information... Good question... I don't know what I can talk more about. Thanks for your help! Bernhard 2009/8/4 Ilkka Myller Hi, > > I tested this with Ubuntu 9.04 (x86_64) with latest available JVM from > repositories: > > java version "1.6.0_14" > Java(TM) SE Runtime Environment (build 1.6.0_14-b08) > Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) > > The RXTX version I used was 2.2pre2. (downloaded from RXTX wiki, ubuntu > repositories have only 2.1.7r2-4) > > The created a small application that opens the serial port, registers > serial port event listeners, sends few kilobytes of data to loopback adapter > and receives it. > I copied your closing methods (that one with CloseThread etc.) and used > them to close the serial port in my code. > > I tested with native RS232 UART, Prolific USB-adapter and FTDI USB > -adapter. > > Everything worked perfectly. No hangs at port.close(). > > Maybe you could provide more information so this issue could be reproduced. > > -- > I > > Bernhard Perun kirjoitti 4.8.2009 kello 11.20: > > Hi guys! >> The last days I have tried 1000 solution regarding that known issue. >> But nothing - absolute nothing - works for me. >> With Windows and RXTX 2.1.7 it works perfect, but under Ubuntu 9.04 and >> RXTX 2.2pre1 (RXTX 2.1.7r2 doesn't work with Ubuntu 9.04 - 64 bit (JVM-Crash >> - also a known problem...) ). >> >> The problems are always the same: >> >> -> removeEventListener() takes a very long time (about 5 seconds) >> -> the CloseTheard is hanging up totally at port.close() >> >> I know that there are difficulties with IOLock... What can I do to solve >> this problem? >> >> >> ---------------------------------------------------------------------------- >> Here is my code for closing my serial port: >> >> ---------------------------------------------------------------------------- >> >> class CloseThread extends Thread >> { >> public void run() >> { >> port.removeEventListener(); >> port.close(); >> } >> } >> >> >> public void closePort() >> { >> >> try >> { >> if (port != null) >> { >> port.getInputStream().close(); >> port.getOutputStream().close(); >> >> new CloseThread().start(); >> >> } >> >> } >> catch (Exception e) {} >> } >> >> ----------------------------------------------------------------------- >> >> Thanks a lot! >> >> Bernhard >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvieway at hotmail.com Tue Aug 4 13:10:22 2009 From: danielvieway at hotmail.com (Daniel Powell) Date: Wed, 5 Aug 2009 07:10:22 +1200 Subject: [Rxtx] Feedback needed: using a comport after a timeout In-Reply-To: <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> References: <4A771DE5.9050602@bbs.darktech.org> <302aa0340908031459l26d5ff85u7a595d90327cf733@mail.gmail.com> Message-ID: > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My apologies for lurking. I intend to use RXTX to attach to a serial over USB interface for the engine management computer and a separate GPS stream on my race car. The ECU is powered and disabled several times during datalogging sessions. The Asus EEEPC (logging device) is in a water tight enclosed casing that takes some time to unscrew to open. As such the datalogging application needs to be autonomous. I've used engidea.win32jcom in the past however it logs sporadically at best. I intend to rewrite it using RXTX and a thread to monitor and restart threads that have no return. I don't know as of yet if I can close the comm port on thread termination. This is a by-product of the logical comport being deleted as the USB device is powered off. http://www.oranz.co.nz/index.php?page=daniel-powells-champion Daniel Powell. -----Original Message----- From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Michael Tandy Sent: Tuesday, 4 August 2009 9:59 a.m. To: Rxtx Mailing list Subject: Re: [Rxtx] Feedback needed: using a comport after a timeout > Can we safely assume that users will always close a comport after a > read or write timeout? Does anyone have a real-life counter-example? My application receives regular, variable-length packets, and I use bulk reads because bulk operations are usually more efficient. I rely on timeouts occurring after every packet, to make sure packets smaller than the buffer size are dealt with in a timely manner. Admittedly, I could do things differently, such as not relying on bulk reads. _______________________________________________ Rxtx mailing list Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx From agusmunioz at gmail.com Wed Aug 5 17:29:40 2009 From: agusmunioz at gmail.com (=?ISO-8859-1?Q?Agustin_Mu=F1oz?=) Date: Wed, 5 Aug 2009 20:29:40 -0300 Subject: [Rxtx] windows virtual machine on a linux host Message-ID: <988288430908051629t11ace8d4s855f33bf148a8427@mail.gmail.com> Hi. I'm developing an application that must run in a virtual machine with Windows as OS, over a linux host. I'm using virtualbox. The hardware that I have to connect with, brings a software that creates a COM port, but in fact, it is connected through an USB port. I've tested my application in a machine with Windows as the OS and it works fine. But when I deploy my aplicaction in the virtual machine, although it is able to read the information written by the hardware, when my application tries to write the acknowldege signal, throws the next exception: java.io.IOException: No error in readArray at gnu.io.RXTXPort.readArray(Native Method) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1398) at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1287) at ar.com.tpark.radar.comm.lectores.LectorPuertoExsa.leer(LectorPuertoExsa.java:33) at ar.com.tpark.radar.comm.LectorSeniales.startWorking(LectorSeniales.java:130) at ar.com.tpark.radar.comm.LectorSeniales.access$000(LectorSeniales.java:30) at ar.com.tpark.radar.comm.LectorSeniales$1.run(LectorSeniales.java:78) And the console outputs the next message: Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(482): Access denied I'm using rxtx-2.1.7, and the linux is Ubuntu Any idea? Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From torn878 at googlemail.com Thu Aug 6 01:38:11 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 09:38:11 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) Message-ID: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Hi guys, my first problem (Application hangs up at serialPort.close()) I could solve. Just use RXTXPort instead of SerialPort and all works fine with Linux. Special thanks to Ilkka Myller! Unfortunately I got a new problem: -------------------------------------------------- (I attached the code - sorry, it is only a test code - don't expect a nice code) If I remove the while(read) - loop of the serialEvent - method, the sending works very fast (0ms-2ms per sending). But if I don't remove the while(read) - loop on one hand the sending is very slow (512ms per sending) on the other hand I can't get the data with my while((serialInt = inputStream.read()) != -1) - loop. SerialEvent recognizes that data comes in, but I can't read this data. Please can you tell me where my mistake is !?!?! My system: -> Ubuntu 9.04 (amd64) -> RXTX 2.2pre2 -> Java 1.6 (SUN) Thanks for your help, Bernhard. -------------- next part -------------- A non-text attachment was scrubbed... Name: SerialTest.java Type: text/x-java Size: 5204 bytes Desc: not available URL: From michael.erskine at ketech.com Thu Aug 6 01:55:19 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 08:55:19 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> At first glance I see that you're assuming that every SerialPortEvent is of type SerialPortEvent.DATA_AVAILABLE which may not be the case. Regards, Michael Erskine. From michael.erskine at ketech.com Thu Aug 6 02:05:08 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:05:08 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> There's way too much work being done in this event handler: I also see that every event will be greeted with a new char[100] constructor and an excessive amount of casting and String concatenation. Did you know you can (and probably should) call read with a byte[] argument? Plus I doubt you can assume that each "line" received by your handler will always represent a "line" sent by the other end: deal with possible buffering and decouple the byte handling from the message handling. Regards, Michael Erskine. From torn878 at googlemail.com Thu Aug 6 02:13:29 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:13:29 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344B8@no-sv-03.ketech.local> Message-ID: <29c18e410908060113m45f9d916p52beab9d31fa1df2@mail.gmail.com> Thanks, you're right. I determine that I always get a "OUTPUT_BUFFER_EMPTY" - Event... What means that? 2009/8/6 Michael Erskine > At first glance I see that you're assuming that every SerialPortEvent is of > type SerialPortEvent.DATA_AVAILABLE which may not be the case. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:15:28 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:15:28 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <846941AD-E26A-4F27-843D-C36B5A401B83@myller.com> I really dont understand how there can be a difference in using SerialPort or RXTXPort since SerialPort is just an interface and RXTXPort implementing it. But glad to hear you got your code working :) -- I Bernhard Perun kirjoitti 6.8.2009 kello 10.38: > Hi guys, > > my first problem (Application hangs up at serialPort.close()) I could > solve. Just use RXTXPort instead of SerialPort and all works fine with > Linux. > Special thanks to Ilkka Myller! > > > Unfortunately I got a new problem: > -------------------------------------------------- > (I attached the code - sorry, it is only a test code - don't expect > a nice code) > > If I remove the while(read) - loop of the serialEvent - method, the > sending works very fast (0ms-2ms per sending). > > But if I don't remove the while(read) - loop on one hand the sending > is very slow (512ms per sending) on the other hand I can't get the > data with my while((serialInt = inputStream.read()) != -1) - loop. > SerialEvent recognizes that data comes in, but I can't read this data. > > Please can you tell me where my mistake is !?!?! > > My system: > -> Ubuntu 9.04 (amd64) > -> RXTX 2.2pre2 > -> Java 1.6 (SUN) > > Thanks for your help, Bernhard. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From torn878 at googlemail.com Thu Aug 6 02:21:22 2009 From: torn878 at googlemail.com (Bernhard Perun) Date: Thu, 6 Aug 2009 10:21:22 +0200 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: <29c18e410908060121j2443c926ya11d2a55e54209a4@mail.gmail.com> The point is that this example runs perfect under windows (but without the flush-method - it seems that windows doesn't need the flash - method in the send-method... with the flash-method under windows I have the same difficulties like here in Linux)... 2009/8/6 Michael Erskine > There's way too much work being done in this event handler: I also see that > every event will be greeted with a new char[100] constructor and an > excessive amount of casting and String concatenation. Did you know you can > (and probably should) call read with a byte[] argument? Plus I doubt you can > assume that each "line" received by your handler will always represent a > "line" sent by the other end: deal with possible buffering and decouple the > byte handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilkka at myller.com Thu Aug 6 02:23:31 2009 From: ilkka at myller.com (Ilkka Myller) Date: Thu, 6 Aug 2009 11:23:31 +0300 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> <06BA3262D918014F9183B66425D5A8D465EF6344C3@no-sv-03.ketech.local> Message-ID: Bernhard, I see that you have added your event handler method over code I sent you to test just the SerialPort.close() method. It was a quick hack to test port closing - and just that. I completely agree with Michael here. In addition that you have not specified which events you want to receive (you just left the few "demo" addNotify...() methods I put there), your event handler does not check which event is received. Also the event handler is not well written - it basicly halts the event handling in an almost infinite read loop when *any* event is received. -- I Michael Erskine kirjoitti 6.8.2009 kello 11.05: > There's way too much work being done in this event handler: I also > see that every event will be greeted with a new char[100] > constructor and an excessive amount of casting and String > concatenation. Did you know you can (and probably should) call read > with a byte[] argument? Plus I doubt you can assume that each "line" > received by your handler will always represent a "line" sent by the > other end: deal with possible buffering and decouple the byte > handling from the message handling. > > Regards, > Michael Erskine. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From michael.erskine at ketech.com Thu Aug 6 02:38:58 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Thu, 6 Aug 2009 09:38:58 +0100 Subject: [Rxtx] sending is very slow (512ms) and inputStream.read() doesn't works (OS: Linux) In-Reply-To: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> References: <29c18e410908060038i496cd50fh6efc350806ff3acb@mail.gmail.com> Message-ID: <06BA3262D918014F9183B66425D5A8D465EF6344E9@no-sv-03.ketech.local> I've rewritten your event handler to do things the way I usually do (which works well for me) but your tests are not waiting for data to be sent let alone waiting for the other end to deal with the data, generate responses, send it and the UART on your machine to receive the data. Please put some thought into that. Regards, Michael Erskine. ------------------------------- >8 CUT HERE >8 --------------------------------- //~--- non-JDK imports -------------------------------------------------------- import gnu.io.PortInUseException; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import gnu.io.UnsupportedCommOperationException; //~--- JDK imports ------------------------------------------------------------ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; //~--- classes ---------------------------------------------------------------- public class SerialTest implements SerialPortEventListener { private long zstVorher; private RXTXPort serialPort; private InputStream inputStream; private PrintStream outputStream; /** Raw data buffer */ private byte[] buf = new byte[1024]; /** Total byte counter */ private long bCount = 0; /** Received message */ protected StringBuilder msg; /** Maximum message length */ protected int maxmsg = 100; // ~--- inner classes ------------------------------------------------------ class CloseThread extends Thread { @Override public void run() { log("CLOSETHREAD 1"); serialPort.removeEventListener(); log("CLOSETHREAD 2"); serialPort.close(); log("CLOSETHREAD 3 (SUCCESS!)"); } } // ~--- constructors ------------------------------------------------------- public SerialTest() throws IOException { init(); } public void init() throws IOException { try { log("INIT 1"); this.serialPort = new RXTXPort("COM6"); log("INIT 2"); this.serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); log("INIT 3"); this.serialPort.setFlowControlMode(SerialPort.FLOWC