From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0001.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0001.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0003.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0002.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0001.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0004.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0003.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0003.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0002.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0002.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0001.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0005.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0004.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0004.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0003.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0003.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0002.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0001.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0006.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0005.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0005.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0004.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0004.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0003.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0002.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0007.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0006.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0006.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0005.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0005.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0004.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0003.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0008.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0007.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0007.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0006.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0006.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0005.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0004.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0009.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0008.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0008.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0007.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0007.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0006.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0005.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0010.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0009.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0009.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0008.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0008.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0007.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0006.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0011.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0010.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0010.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0009.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0009.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0008.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0007.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0012.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0011.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0011.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0010.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0010.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0009.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0008.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0001.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0013.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0012.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0012.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0011.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0011.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0011.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0010.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0002.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0002.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0002.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0001.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0014.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0013.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0013.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0012.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0012.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0012.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0011.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0003.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0003.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0003.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0002.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0001.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0015.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0014.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0014.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0013.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0013.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0013.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0012.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0004.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0004.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0004.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0003.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0002.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0016.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0015.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0015.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0014.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0014.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0014.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0013.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0005.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0005.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0005.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0004.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0003.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0017.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0016.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0016.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0015.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0015.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0015.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0014.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0006.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0006.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0006.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0005.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0004.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0018.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0017.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0017.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0016.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0016.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0016.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0015.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0007.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0007.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0007.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0006.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0005.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0001.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0001.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0019.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0018.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0018.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0017.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0017.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0017.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0016.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0008.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0008.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0008.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0008.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0007.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0002.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0002.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0002.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0020.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0019.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0019.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0018.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0018.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0018.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0017.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0009.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0009.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0009.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0009.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0008.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0003.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0003.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0003.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0021.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0020.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0020.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0019.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0019.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0019.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0018.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0010.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0010.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0010.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0010.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0009.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0004.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0004.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0004.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0022.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0021.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0021.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0020.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0020.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0020.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0019.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0011.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0011.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0011.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0011.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0010.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0005.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0005.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0005.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0023.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0022.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0022.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0021.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0021.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0021.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0020.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0012.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0012.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0012.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0012.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0011.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0006.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0006.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0006.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0024.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0023.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0023.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0022.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0022.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0022.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0021.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0013.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0013.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0013.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0013.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0012.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0007.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0007.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0007.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0001.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0001.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0001.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0025.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0024.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0024.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0023.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0023.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0023.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0022.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0014.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0014.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0014.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0014.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0013.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0008.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0008.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0008.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0002.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0002.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0002.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0026.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0025.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0025.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0024.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0024.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0024.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0023.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0015.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0015.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0015.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0015.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0014.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0009.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0009.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0009.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0003.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0003.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0003.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0027.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0026.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0026.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0025.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0025.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0025.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0024.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0016.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0016.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0016.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0016.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0015.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0010.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0010.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0010.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0004.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0004.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0004.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0028.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0027.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0027.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0026.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0026.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0026.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0025.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0017.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0017.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0017.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0017.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0016.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0011.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0011.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0011.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0005.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0005.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0005.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0001.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0029.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0028.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0028.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0027.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0027.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0027.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0026.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0018.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0018.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0018.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0018.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0017.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0012.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0012.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0012.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0007.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0007.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0007.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0002.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0001.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0030.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0029.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0029.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0028.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0028.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0028.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0027.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0019.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0019.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0019.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0019.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0018.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0013.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0013.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0013.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0008.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0008.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0008.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0003.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0002.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0001.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0031.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0030.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0030.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0029.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0029.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0029.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0028.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0020.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0020.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0020.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0020.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0019.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0014.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0014.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0014.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0009.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0009.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0009.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0004.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0003.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0002.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0001.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0001.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0032.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0031.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0031.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0030.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0030.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0030.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0029.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0021.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0021.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0021.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0021.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0020.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0015.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0015.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0015.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0010.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0010.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0010.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0005.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0004.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0003.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0002.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0002.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0033.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0032.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0032.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0031.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0031.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0031.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0030.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0022.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0022.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0022.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0022.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0021.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0016.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0016.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0016.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0011.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0011.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0011.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0006.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0006.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0005.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0004.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0004.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0034.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0033.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0033.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0032.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0032.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0032.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0031.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0023.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0023.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0023.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0023.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0022.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0017.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0017.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0017.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0012.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0012.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0012.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0007.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0007.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0006.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0005.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0005.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0035.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0034.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0034.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0033.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0033.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0033.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0032.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0024.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0024.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0024.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0024.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0023.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0018.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0018.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0018.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0013.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0013.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0013.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0008.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0008.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0007.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0006.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0006.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0036.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0035.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0035.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0034.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0034.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0034.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0033.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0025.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0025.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0025.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0025.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0024.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0019.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0019.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0019.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0014.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0014.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0014.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0009.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0009.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0008.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0007.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0007.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0037.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0036.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0036.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0035.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0035.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0035.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0034.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0026.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0026.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0026.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0026.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0025.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0020.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0020.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0020.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email. From fredm at alum.mit.edu Wed Mar 18 16:33:54 2009 From: fredm at alum.mit.edu (Fred G. Martin) Date: Wed, 18 Mar 2009 18:33:54 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: References: Message-ID: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Yes, I agree with Noel that Keyspan on Mac OS X is well-supported reliable. Last summer, my students and I spent a bunch of time fighting with PL-2303 on Mac OS X. Our conclusion then was there was no reliable driver for Mac OS X for this chip. We've had good luck with Keyspan and FTDI on the Mac platform. Fred On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel wrote: > >> >> ? ?1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >> ? ? ? (Phineas Gage) >> > >> From: Phineas Gage >> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >> 10.5.6 > >> >> Coming back to a question in the original post- does anyone know of a >> USB-Serial adapter that behaves well with RXTX under OS X using >> supported drivers that came from its manufacturer? >> > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, > and have had very little trouble. We have been using the same adaptors for > about 10 years now, I tried some other solutions ( eg Stealth Serial Port) > but have found the Keyspans to be robust, easy and they seem to be fairly > future proof. > I use the Keyspan drivers for OSX and rxtx together with ImageJ. > I have 5 Mac systems in daily use by a number (about 15) of different users, > on ?(4 G5's and 1 Intel), and the part which gives the least trouble is the > Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl > microscope stage controllers and a Leica motorized focus drive on an MZ16 > stereo microscope, and also some in house interfaces which read Mitutoyo > Binary coded serial micrometer heads into an rs232C port. > We are running 10.5.6. > I am running a version of rxtx which is patched to work with 64 bit ImageJ > on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I > think. On the G5's the version is the same. > Hope this helps. > -- > Noel Goldsmith > Air Vehicles Division > Defence Science and Technology Organisation > 506 Lorimer Street Port Melbourne Vic 3207 > Ph 03 96267527 Fax 03 96267089 > Mobile 0428364003 > Noel.goldsmith at dsto.defence.gov.au > > > > IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. ?If you have received this email in error, you are requested to contact the sender and delete the email. > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > From tjarvi at qbang.org Wed Mar 18 17:46:09 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 17:46:09 -0600 (MDT) Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Hi Ilkka, The patch should be going in tonight. I just got access to test on a system today. On Wed, 18 Mar 2009, Ilkka Myller wrote: > Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). ?The patch is for 2.2pre2 code. > > Link to rxtx-list archive:? > http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html > > The patch is not yet in CVS (@2009-03-18) > > -- > I > > Phineas Gage kirjoitti 18.3.2009 kello 21.57: > > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. > The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at?http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available?http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip?(after I get around the locking problem by > creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these > problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I > doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from?www.serialio.com?on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits the > * following problems using this test program in OS X itself using the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in the same > * thread, or using SerialEvents, the program only works once. If I run it a > * second time, no data is sent or received on the serial port. I have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > ???private InputStream m_in; > ???private OutputStream m_out; > > ???public Main() { > ???} > > ???public void run() > ???????throws Exception { > ???????CommPortIdentifier portIdentifier = > ???????????CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > ???????if (portIdentifier.isCurrentlyOwned()) { > ???????????System.out.println("Error: Port is currently in use"); > ???????} else { > ???????????CommPort commPort = (RXTXPort) portIdentifier.open( > ???????????????Main.class.getName(), 2000); > > ???????????RXTXPort serialPort = (RXTXPort) commPort; > ???????????serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, > ???????????????SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > ???????????serialPort.addEventListener(this); > ???????????serialPort.notifyOnDataAvailable(true); > ???????????// set receive timeout, otherwise program will never complete > ???????????serialPort.enableReceiveTimeout(2000); > > ???????????m_in = serialPort.getInputStream(); > ???????????m_out = serialPort.getOutputStream(); > > ???????????// Read response method #1: read in a separate thread > ???????????//Thread thr = new Thread(new SerialReader(in)); > ???????????//thr.start(); > ???????????//Thread.sleep(1000); // make sure thread is started > > ???????????// a few basic PowerLinc commands > ???????????byte[] getVersion = new byte[]{0x02, 0x60}; // get version command > ???????????byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0x00}; // light off command > ???????????byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, > ???????????????0x11, (byte) 0xff}; // light on command > > ???????????// send command > ???????????System.out.println("Sending data"); > ???????????m_out.write(getVersion); > ???????????System.out.println("Flushing"); > ???????????m_out.flush(); > ???????????System.out.println("Done"); > > ???????????// Read response, method #2: read data from the same thread > ???????????//int i; > ???????????//while (-1 != (i = in.read())) > ???????????//{ > ???????????// ???System.out.print (Integer.toHexString(i) + " "); > ???????????//} > ???????????//System.out.println(); > > ???????????// only if using event listener > ???????????//serialPort.removeEventListener(); > > ???????????// wait for data to be returned > ???????????Thread.sleep(2000); > > ???????????System.out.println("Closing"); > ???????????m_out.close(); > ???????????m_in.close(); > ???????????commPort.close(); > ???????????System.out.println("Closed"); > ???????} > ???} > > ???/** > ????* Called when a serial event occurs. > ????* > ????* @param ev the event > ????*/ > ???public void serialEvent(SerialPortEvent ev) { > ???????// Read response, method #3: process SerialPortEvents > ???????System.out.println("Serial event: " + ev.getEventType()); > ???????if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > ???????????try { > ???????????????int i = m_in.read(); > ???????????????System.out.println(Integer.toHexString(i) + " "); > ???????????} catch (IOException ioe) { > ???????????????ioe.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Thread that dumps input from the serial port to standard out. > ????*/ > ???public class SerialReader implements Runnable { > > ???????private InputStream in; > > ???????public SerialReader(InputStream in) { > ???????????this.in = in; > ???????} > > ???????public void run() { > ???????????byte[] buffer = new byte[1024]; > ???????????int len = -1; > ???????????try { > ???????????????while ((len = this.in.read(buffer)) > -1) { > ???????????????????for (int i = 0; i < len; i++) > ???????????????????????System.out.println(Integer.toHexString(i) + " "); > ???????????????} > ???????????} catch (IOException e) { > ???????????????e.printStackTrace(); > ???????????} > ???????} > ???} > > ???/** > ????* Main. > ????* > ????* args command line arguments > ????*/ > ???public static void main(final String[] args) > ???????throws Exception { > ???????Main main = new Main(); > ???????main.run(); > ???} > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > > From phineas919 at gmail.com Wed Mar 18 21:09:24 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 23:09:24 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <49C16413.8070806@gatworks.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> <49C16413.8070806@gatworks.com> Message-ID: <74545A08-BD24-4270-A3DB-FA11712C85B8@gmail.com> I did some more testing and it seems as though it's not _always_ returning 1 byte on a read. One time it returned 3 bytes, for example, so the driver and RXTX are capable of returning more. I put some printf's in the code in SerialImp.c:readArray() then found my way back up to RXTXPort.java. In this file there's a method called waitForTheNativeCodeSilly(), which sleeps for 5 milliseconds at a time, waiting for MonitorThread MonitorThreadLock to be set to true when data is available. MonitorThread hangs out mostly in SerialImp:eventLoop(), waiting for termios.c:serial_select to return when some data's available. So it's a little complicated, and while I don't understand serial IO very well, it seems to me that the reason small numbers of characters are returned is just that it's the nature of the character IO of serial ports. I'm calling read(byte[1024]) in the Java code, data becomes available and RXTX has no way of knowing how long the data will actually be or when incoming data will stop. It returns me data, after some chosen time, when it's available, so I get it. The device I'm communicating with may have inter-character delays, complicating how RXTX knows when input is done. It's not like a TCP socket where data arrives over the network in large blocks. Thinking about it that way, it looks to me to be better to handle incoming data with events rather than using the InputStream model. I suspect that's why it's now available like this in the gnu.io package. I could be way off base with all of this... Thanks for the earlier feedback from Jean and Greg...I've gone ahead and purchased an FTDI based adapter. And thanks to Ilkka and Trent for the invalid memory access patch. So to summarize, from my original code, problem #1 seems to be a problem or at least incompatibility with the Prolific 1.2.1 R2 serial driver, problem #2 seems to be just because there's no great way for RXTX to know how long to read before returning data and problem #4 will be solved in a new patch at some point soon. The only one left is #3. I'm still not sure why closing the CommPort from the main thread wouldn't stop a reader thread from returning (my suspicion is that the thread is down in the native code somewhere hanging out waiting for data and can't be bothered with my CommPort.close()), but it doesn't matter to me much now anyway, because I'm going to handle incoming data using SerialPortEvents, not with a separate reader thread. I hope this helped someone. If I've said something wrong let me know. Sorry I don't have the time to try on a separate Linux box. I've got a Linux VM on OS X, but that would be using the same Serial-USB driver anyway in the end so might not act much different. Thanks all for the help... On Mar 18, 2009, at 5:13 PM, U. George wrote: > Phineas Gage wrote: >> I'm seeing several issues using a Prolific PL2303 USB-Serial >> adapter on OS X 10.5.6 with RXTX. 1) compiled from source using the >> commapi-0-0-1 branch (as of today) > > I suppose I should first ask if u tried any of this on a non OS X > box? Maybe like a linux/86 box? Just to try. Should it work, then > your program, and RXTX are not the issue. > > If you can compile all of source, are u "C" savy enough to place > some printf() statements near the Native read and Native write > routines? If the native read routine has a char count of one in a > buffer ( of lets say 80 bytes ) then that is all the driver is > giving to the native rxtx read routine. > > U might also place a printf near the close() routine to insure that > channel is properly closed before exiting ( or reusing ). > > All this will just help u confirm that the I/O is happening as you > expect. If driver is broken, then nothing you will ever do in java/ > rxtx will fix the driver. From tjarvi at qbang.org Wed Mar 18 21:43:30 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 18 Mar 2009 21:43:30 -0600 (MDT) Subject: [Rxtx] RXTX Commit (fwd) Message-ID: I have one more patch to work through for faster Windows Bluetooth Enumeration. The windows build has consumed far too much of my free time. After windows is ready, we should be ready for release. This was tested on MACI64 extensively. A test suite ran into issues with output buffer empty events and break interrupts. I assume the problems are with the keyspan driver but I need to dig into the logs more to fully understand the issues. Overall, its 98% there. The API was hammered for over an hour using callbacks, open/close/read/write... and remained stable. MACI/MACI64 with the keyspan driver looks fairly good. Amazing really. I'll create a wiki page explaining the testing when we release. ---------- Forwarded message ---------- Date: Wed, 18 Mar 2009 23:27:50 -0400 From: CVS pserv To: tjarvi at qbang.org Subject: RXTX Commit CVS COMMIT SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 Wed Mar 18 23:27:50 EDT 2009 Update of /usr/local/cvsroot/rxtx-devel/src In directory milenoc:/tmp/cvs-serv31872 Modified Files: Tag: commapi-0-0-1 SerialImp.h SerialImp.c Log Message: Ilkka Myller ilkka at myller.com Sun Feb 22 15:31:16 MST 2009 * Previous message: [Rxtx] Hot unplugging usb cable & switching heavy loads (fixed, better fixavailable?) * Next message: [Rxtx] [Patch] Fix for SIGSEGV at SerialImp.c:interruptEventLoop() on platforms that run drain loop thread * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Hi everyone, My first time posting to this list.. :-) I've found a bug in SerialImp.c which causes occasional SIGSEGV halts at interruptEventLoop(). JVM might halt with "Invalid memory access.." error and exit code 139 (SIGSEGV). From java side, interruptEventLoop() is eventually called atleast by RXTXPort.close() and .removeEventListener() methods. How often halts happen depends on hardware configuration, usb rs232 adapters, drivers etc. This bug only affects platforms that need to run native drain loop thread, such as Mac OS X (not win/linux). Analysis: I did some debugging on RXTX native library and found out that following happens: 1. interruptEventLoop() is called 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 3. interruptEventLoop() does ptread_kill() on drain loop thread 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets eis->closing=1 and terminates 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as it should, no problem here) 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to unblock) 7. interruptEventLoop() continues, checks eis->closing really is 1 to see if drain_loop actually died (as it should check, since tcdrain might block drain loop on some hardware/drivers) But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis was finalized earlier and its contents are therefore undefined. By design, steps 4 to 7 run on different simultaneously running threads. As you can see, depending on the order which steps 5 and 7 take place, SIGSEGV halt will or will not happen. Step 5 SHOULD always come last for things to work, but this rarely happens on some hardware configurations. On win/linux this issue does not exist, because their implementation of interruptEventLoop() never uses eis after setting eis->closing=1. Proposed fix: I've included a patch to fix this issue by adding a new flag to signal drain_loop() status for interruptEventLoop() (eis- >drain_loop_running), while keeping usage of other eis flags as they were. Patch removes control of eis->closing flag from drain_loop(), and gives it to interruptEventLoop(), thus preventing SIGSEGV condition. I've tried to keep changes to original RXTX code minimal. Also, patch does not alter the code for "non-drain loop" platforms. This patch is against 2.2pre2 and CVS head (@2009/02/21). I've tested it to work (and resolve the issue) on Mac OS X 10.5.x (both Intel and PPC). Hopefully this patch - or similar addressing this issue - can be integrated in to final 2.2 release. Thank you, -- Ilkka Myller From joonas.koivunen at gmail.com Thu Mar 19 05:43:24 2009 From: joonas.koivunen at gmail.com (Joonas Koivunen) Date: Thu, 19 Mar 2009 13:43:24 +0200 Subject: [Rxtx] Modern linux distributions, udev, patching Message-ID: <47bdc81c0903190443j45283f37ib9ec61b5c849219c@mail.gmail.com> Hi everyone! I need to use an rxtx to communicate with many usb-connected serial devices. Nice thing about these cheap bastards is that they disconnect their usb-connection once in a while and of course when I tell it to restart (the device locks up rather randomly). My linux distribution (Ubuntu 8.04) uses udev so reconnecting to the serial device cannot be implemented using vanilla rxtx-2.1-7r2. It seems (by behaviour) that when loading the library it checks all the devices that are available under /dev and if the device doesn't exist at load-time it will not be accessbile through out the library's load time. Is this correct? Not having studied the code too much but I thought of modifying the port identifier lookup to become stateless; as in that it will not save anything and read the property every time accessed. Can anyone comment if this is good way to proceed? I know the names of the ports I want, on Linux and on Windows. Would it be better for the project trying to get these things working with the upcoming rxtx release? I can't seem to find any milestone what so ever information on the 2.2 project, what are the goals etc? I'd be glad to participate if there's something I can help with. Should I post whatever patch I can come up on this list or someone? -- -- Joonas Koivunen From Martin.Oberhuber at windriver.com Thu Mar 19 09:50:32 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Thu, 19 Mar 2009 16:50:32 +0100 Subject: [Rxtx] RXTX Commit (fwd) In-Reply-To: References: Message-ID: <460801A4097E3D4CA04CC64EE648584809AC45FB@ism-mail03.corp.ad.wrs.com> Hi Trent, for bluetooth enumeration performance, you should seriously consider PJ Naughter's enumser code, see http://bugzilla.qbang.org/show_bug.cgi?id=103 In all my tests so far, the "UsingRegistry" method proved to by correct, reliable and fast. The code change to RXTX should be minimal to get this in registerKnownPorts(). I'd do it myself but I'm so deeply swamped with other work at the moment that there's simply no chance. Will be better in 2 weeks, when Eclipsecon is over. What I'd recommend at this point is create a pre3 with the stuff that you like in there. I can then create an "Eclipsified" version for installation through update manager, for those that like it this way. Also, what about the webstart contribution? Testing those alternative bundlings, we should get an even larger part of the Community to test it before we actually release. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm > -----Original Message----- > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] > On Behalf Of Trent Jarvi > Sent: Donnerstag, 19. M?rz 2009 04:44 > To: rxtx at qbang.org > Subject: [Rxtx] RXTX Commit (fwd) > > > I have one more patch to work through for faster Windows Bluetooth > Enumeration. The windows build has consumed far too much of my free > time. After windows is ready, we should be ready for release. > > This was tested on MACI64 extensively. A test suite ran into issues > with output buffer empty events and break interrupts. I assume the > problems are with the keyspan driver but I need to dig into > the logs more > to fully understand the issues. Overall, its 98% there. > > The API was hammered for over an hour using callbacks, > open/close/read/write... and remained stable. > > MACI/MACI64 with the keyspan driver looks fairly good. > Amazing really. > > I'll create a wiki page explaining the testing when we release. > > ---------- Forwarded message ---------- > Date: Wed, 18 Mar 2009 23:27:50 -0400 > From: CVS pserv > To: tjarvi at qbang.org > Subject: RXTX Commit > > CVS COMMIT > SerialImp.h 1.11.2.54 1.11.2.55 SerialImp.c 1.46.2.202 1.46.2.203 > Wed Mar 18 23:27:50 EDT 2009 > Update of /usr/local/cvsroot/rxtx-devel/src > In directory milenoc:/tmp/cvs-serv31872 > > Modified Files: > Tag: commapi-0-0-1 > SerialImp.h SerialImp.c > Log Message: > Ilkka Myller ilkka at myller.com > Sun Feb 22 15:31:16 MST 2009 > > * Previous message: [Rxtx] Hot unplugging usb cable & > switching heavy loads (fixed, better fixavailable?) > * Next message: [Rxtx] [Patch] Fix for SIGSEGV at > SerialImp.c:interruptEventLoop() on platforms that run drain > loop thread > * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > Hi everyone, > > My first time posting to this list.. :-) > > I've found a bug in SerialImp.c which causes occasional SIGSEGV halts > at interruptEventLoop(). > JVM might halt with "Invalid memory access.." error and exit code 139 > (SIGSEGV). > From java side, interruptEventLoop() is eventually called atleast by > RXTXPort.close() and .removeEventListener() methods. > > How often halts happen depends on hardware configuration, usb rs232 > adapters, drivers etc. > This bug only affects platforms that need to run native drain loop > thread, such as Mac OS X (not win/linux). > > Analysis: > > I did some debugging on RXTX native library and found out that > following happens: > > 1. interruptEventLoop() is called > 2. interruptEventLoop() sets eis->eventloop_interrupted = 1 > 3. interruptEventLoop() does ptread_kill() on drain loop thread > 4. drain_loop() catches eis->event_loop_interrupted = 1 change, sets > eis->closing=1 and terminates > 5. eventLoop() catches eis->closing=1, and goes to *finalize* eis (as > it should, no problem here) > 6. interruptEventLoop() sleeps ( 50 ms, tcdrain might need time to > unblock) > 7. interruptEventLoop() continues, checks eis->closing really is 1 to > see if drain_loop actually died (as it should check, since tcdrain > might block drain loop on some hardware/drivers) > > But.. last step 7 causes obvious SIGSEGV inside if-clause, because eis > was finalized earlier and its contents are therefore undefined. > > By design, steps 4 to 7 run on different simultaneously running > threads. As you can see, depending on the order which steps 5 and 7 > take place, SIGSEGV halt will or will not happen. > Step 5 SHOULD always come last for things to work, but this rarely > happens on some hardware configurations. > On win/linux this issue does not exist, because their implementation > of interruptEventLoop() never uses eis after setting eis->closing=1. > > Proposed fix: > > I've included a patch to fix this issue by adding a new flag to signal > drain_loop() status for interruptEventLoop() (eis- > >drain_loop_running), while keeping usage of other eis flags as they > were. > Patch removes control of eis->closing flag from drain_loop(), and > gives it to interruptEventLoop(), thus preventing SIGSEGV condition. > I've tried to keep changes to original RXTX code minimal. Also, patch > does not alter the code for "non-drain loop" platforms. > > This patch is against 2.2pre2 and CVS head (@2009/02/21). > I've tested it to work (and resolve the issue) on Mac OS X 10.5.x > (both Intel and PPC). > > Hopefully this patch - or similar addressing this issue - can be > integrated in to final 2.2 release. > > > Thank you, > -- Ilkka Myller > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Mon Mar 23 13:24:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 23 Mar 2009 20:24:50 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 Message-ID: Hello again. I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an application running on Ubuntu 8.10 that seem to run stable but after an hour or so the application breaks down with lot's of IO exceptions like this: java.io.IOException: Input/output error in nativeavailable at gnu.io.RXTXPort.nativeavailable(Native Method) at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) at com.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInterface.java:251) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) Any ideas? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090323/313fff14/attachment-0015.html From tjarvi at qbang.org Mon Mar 23 17:05:12 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 23 Mar 2009 17:05:12 -0600 (MDT) Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: On Mon, 23 Mar 2009, Helge Fredriksen wrote: > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an > application running on Ubuntu 8.10 that seem to run stable but after an hour > or so the application breaks down with lot's of IO exceptions like this: > > java.io.IOException: Input/output error in nativeavailable > ??? at gnu.io.RXTXPort.nativeavailable(Native Method) > ??? at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > ??? atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte > rface.java:251) > ??? at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > ??? at gnu.io.RXTXPort.eventLoop(Native Method) > ??? at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? Hi Helge, It sounds like the file descriptor (USB driver) is in an invalid state. What can you tell us about the USB dongle? Is it bluetooth? Do you know what chipset is in it? -- Trent Jarvi tjarvi at qbang.org From helgeingvart at gmail.com Tue Mar 24 01:45:34 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 24 Mar 2009 08:45:34 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: Hello! Here's the device details: FT232R is a USB to serial UART interface. Link to componentt: http://www.ftdichip.com/Products/FT232R.htm Regards, Helge Fredriksen On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. >> >> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >> application running on Ubuntu 8.10 that seem to run stable but after an >> hour >> or so the application breaks down with lot's of IO exceptions like this: >> >> java.io.IOException: Input/output error in nativeavailable >> at gnu.io.RXTXPort.nativeavailable(Native Method) >> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >> >> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >> rface.java:251) >> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >> at gnu.io.RXTXPort.eventLoop(Native Method) >> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >> >> Any ideas? >> > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you know > what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/9464fbd5/attachment-0015.html From ilkka at myller.com Tue Mar 24 02:27:43 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 24 Mar 2009 10:27:43 +0200 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: References: Message-ID: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Hi Helge, I am not sure if this will help, but you could try this: echo on > /sys/bus/usb/devices//power/level echo 0 > /sys/bus/usb/devices//power/autosuspend is the USB-bus device id of your FTDI adapter (bus-device, for example "2-2") This will disable USB power saving/autosuspend of FTDI USB-device. I've seen some some systems where this helps with FTDI-adapter connection drops. Also: is your FTDI device directly connected to PC's USB root hub? If not, test that too. -- I (replace with the usb bus device id of your FTDI serial adapter) Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi > wrote: > > > On Mon, 23 Mar 2009, Helge Fredriksen wrote: > > Hello again. > > I'm having a bit trouble with the 2.2pre2 version it seems. I'm > having an > application running on Ubuntu 8.10 that seem to run stable but after > an hour > or so the application breaks down with lot's of IO exceptions like > this: > > java.io.IOException: Input/output error in nativeavailable > at gnu.io.RXTXPort.nativeavailable(Native Method) > at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) > atcom.poseidon.usb.UsbInterface > $MySerialPortEventListener.serialEvent(UsbInte > > rface.java:251) > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) > at gnu.io.RXTXPort.eventLoop(Native Method) > at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) > > Any ideas? > > Hi Helge, > > It sounds like the file descriptor (USB driver) is in an invalid > state. > > What can you tell us about the USB dongle? Is it bluetooth? Do you > know what chipset is in it? > > -- > Trent Jarvi > tjarvi at qbang.org > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090324/fc485b77/attachment-0015.html From helgeingvart at gmail.com Sat Mar 28 09:32:10 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Sat, 28 Mar 2009 16:32:10 +0100 Subject: [Rxtx] IO exceptions on 2.2pre2 In-Reply-To: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> References: <306B677E-9207-44CB-81CD-787A50DB7DA6@myller.com> Message-ID: Thanks for your suggestions, We have tried switching off the power saving settings as recommended, but regrettably we see the same things happening still. The FTDI device is not connected directly to USB hubs, no. Someone have any more ideas? Best regards, Helge Fredriksen On Tue, Mar 24, 2009 at 9:27 AM, Ilkka Myller wrote: > Hi Helge, > > I am not sure if this will help, but you could try this: > > echo on > /sys/bus/usb/devices//power/level > echo 0 > /sys/bus/usb/devices//power/autosuspend > > is the USB-bus device id of your FTDI adapter (bus-device, for > example "2-2") > > This will disable USB power saving/autosuspend of FTDI USB-device. > I've seen some some systems where this helps with FTDI-adapter connection > drops. > > Also: is your FTDI device directly connected to PC's USB root hub? If not, > test that too. > > > -- > I > > (replace with the usb bus device id of your FTDI serial > adapter) > > Helge Fredriksen kirjoitti 24.3.2009 kello 9.45: > > Hello! > > Here's the device details: > > FT232R is a USB to serial UART interface. > > Link to componentt: http://www.ftdichip.com/Products/FT232R.htm > > Regards, > Helge Fredriksen > > On Tue, Mar 24, 2009 at 12:05 AM, Trent Jarvi wrote: > >> >> >> On Mon, 23 Mar 2009, Helge Fredriksen wrote: >> >> Hello again. >>> >>> I'm having a bit trouble with the 2.2pre2 version it seems. I'm having an >>> application running on Ubuntu 8.10 that seem to run stable but after an >>> hour >>> or so the application breaks down with lot's of IO exceptions like this: >>> >>> java.io.IOException: Input/output error in nativeavailable >>> at gnu.io.RXTXPort.nativeavailable(Native Method) >>> at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1596) >>> >>> atcom.poseidon.usb.UsbInterface$MySerialPortEventListener.serialEvent(UsbInte >>> rface.java:251) >>> at gnu.io.RXTXPort.sendEvent(RXTXPort.java:772) >>> at gnu.io.RXTXPort.eventLoop(Native Method) >>> at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1641) >>> >>> Any ideas? >>> >> >> Hi Helge, >> >> It sounds like the file descriptor (USB driver) is in an invalid state. >> >> What can you tell us about the USB dongle? Is it bluetooth? Do you know >> what chipset is in it? >> >> -- >> Trent Jarvi >> tjarvi at qbang.org > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/2fdf71f4/attachment-0010.html From frederik at fcr.be Sat Mar 28 12:59:03 2009 From: frederik at fcr.be (Frederik Cornil) Date: Sat, 28 Mar 2009 19:59:03 +0100 Subject: [Rxtx] Port determination Message-ID: Hello all, I'm quite new to Serial Communication. I know that you can get the port identifiers with RXTX, but how do you make sure to connect to the correct device? My scenario: I want to connect to a USB device to retrieve some info. To retrieve this info, I need to send some commands to the device. But if I find 2 ports (COM1 and COM16), how to decide which one is the right one? Do I just send the command to the both of them and look which one replies? Thanks in advance, Frederik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090328/06062a07/attachment-0010.html From lyon at docjava.com Sun Mar 29 08:12:45 2009 From: lyon at docjava.com (Dr. Douglas Lyon) Date: Sun, 29 Mar 2009 10:12:45 -0400 Subject: [Rxtx] jnlp tags for the mac Message-ID: Hi All, I am trying to establish a proper tag ordering for 64bit vs 32 bit vs ppc tags on native methods for RXTX in JNLP...Is this right? I have seen conflicting documentation on the web for this topic. Thanks! - Doug From ajmas at sympatico.ca Sun Mar 29 11:47:32 2009 From: ajmas at sympatico.ca (Andre-John Mas) Date: Sun, 29 Mar 2009 13:47:32 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> References: <72ef860f0903181533k46938ec1h322f2959f5aeb57@mail.gmail.com> Message-ID: You may be interested in the open source implementation of the driver: http://sourceforge.net/projects/osx-pl2303/ This not written by FTDI, and in my experience is more reliable. The up side is if you do find issues, then it is easier to get it fixed. Andr?-John On 18-Mar-2009, at 18:33, Fred G. Martin wrote: > Yes, I agree with Noel that Keyspan on Mac OS X is well-supported > reliable. > > Last summer, my students and I spent a bunch of time fighting with > PL-2303 on Mac OS X. Our conclusion then was there was no reliable > driver for Mac OS X for this chip. > > We've had good luck with Keyspan and FTDI on the Mac platform. > > Fred > > > On Wed, Mar 18, 2009 at 6:08 PM, Goldsmith, Noel > wrote: >> >>> >>> 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 >>> (Phineas Gage) >>> >> >>> From: Phineas Gage >>> Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X >>> 10.5.6 >> >>> >>> Coming back to a question in the original post- does anyone know >>> of a >>> USB-Serial adapter that behaves well with RXTX under OS X using >>> supported drivers that came from its manufacturer? >>> >> I am using the Keyspan twin serial adaptors (USA 28X) of various >> vintages, >> and have had very little trouble. We have been using the same >> adaptors for >> about 10 years now, I tried some other solutions ( eg Stealth >> Serial Port) >> but have found the Keyspans to be robust, easy and they seem to be >> fairly >> future proof. >> I use the Keyspan drivers for OSX and rxtx together with ImageJ. >> I have 5 Mac systems in daily use by a number (about 15) of >> different users, >> on (4 G5's and 1 Intel), and the part which gives the least >> trouble is the >> Keyspan. Not that we have much trouble anyway. I am interfacing >> with Ludl >> microscope stage controllers and a Leica motorized focus drive on >> an MZ16 >> stereo microscope, and also some in house interfaces which read >> Mitutoyo >> Binary coded serial micrometer heads into an rs232C port. >> We are running 10.5.6. >> I am running a version of rxtx which is patched to work with 64 bit >> ImageJ >> on the Intel Mac (Thanks to Guilano Gavazzi), the version is the >> 2.2Pre, I >> think. On the G5's the version is the same. >> Hope this helps. >> -- >> Noel Goldsmith >> Air Vehicles Division >> Defence Science and Technology Organisation >> 506 Lorimer Street Port Melbourne Vic 3207 >> Ph 03 96267527 Fax 03 96267089 >> Mobile 0428364003 >> Noel.goldsmith at dsto.defence.gov.au >> >> >> >> IMPORTANT: This email remains the property of the Australian >> Defence Organisation and is subject to the jurisdiction of section >> 70 of the CRIMES ACT 1914. If you have received this email in >> error, you are requested to contact the sender and delete the email. >> >> >> _______________________________________________ >> 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 Steffen.DETTMER at ingenico.com Mon Mar 30 00:21:50 2009 From: Steffen.DETTMER at ingenico.com (Steffen DETTMER) Date: Mon, 30 Mar 2009 08:21:50 +0200 Subject: [Rxtx] Port determination In-Reply-To: References: Message-ID: <20090330062150.GE9729@elberon.bln.de.ingenico.com> * Frederik Cornil wrote on Sat, Mar 28, 2009 at 19:59 +0100: > My scenario: I want to connect to a USB device to retrieve some > info. To retrieve this info, I need to send some commands to > the device. But if I find 2 ports (COM1 and COM16), how to > decide which one is the right one? Do I just send the command > to the both of them and look which one replies? If it is really important, you may also fix the USB devices to port names. On linux, I think this should be possible via /etc/udev/rules.d/. This is also needed to give the appropriate user accounts the needed access rights for the devices. On windows, many applications present the user a selection and users seem to be used to try them (one after the other until it works, even if the device manager would tell more). The win workstation uses typically have access rights by default. Asking the users avoids potential problems in case some other device doesn't do good on the command for your device. It seems often it is expected that modern linux behave close to windows. Personally, I would have a config file to configure that (maybe with some GUI way to change it) but if no port is set, I would send the command to all ports to see which replies. oki, Steffen [End of message.] ------------------------------------------------------------------->8======= About Ingenico: Ingenico is the world?s leading provider of payment solutions, with over 15 million terminals deployed across the globe. Delivering the very latest secure electronic payment technologies, transaction management and the widest range of value added services, Ingenico is shaping the future direction of the payment solutions market. Leveraging on its global presence and local expertise, Ingenico is reinforcing its leadership by taking banks and businesses beyond payment through offering comprehensive solutions, a true source of differentiation and new revenues streams. This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. P Please consider the environment before printing this e-mail From luca.catoni at gmail.com Mon Mar 30 05:57:48 2009 From: luca.catoni at gmail.com (Luca Catoni) Date: Mon, 30 Mar 2009 13:57:48 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter Message-ID: My java application communicates with datalogger via rs232. Rxtx library works fine on linux and windows system using serial port. The problems come when I use an usb adapter FTDI chip-set based ( http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux system (2.6.24 kernel), where there is no need of driver. On windows instead I have no problem. My program is event based; This adapter works correctly using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) and serialPort.notifyOnOutputEmpty(true) calls. My application send first message correctly but I get an error in response: at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.nativeDrain(Native Method) at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) If I comment flush() command after send first message I have no response and my time-out exceeds. It seems there are problems when generating SerialPortEvent.DATA_AVAILABLE event. Can I resolve this problem ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090330/ca80eba6/attachment-0009.html From helgeingvart at gmail.com Tue Mar 31 00:24:06 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 08:24:06 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Yes, this is excactly the same chip that we are using on a linux system and which I reported problems on a week or so ago. My system is also event driven. Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/301355ee/attachment-0008.html From helgeingvart at gmail.com Tue Mar 31 02:32:19 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 31 Mar 2009 10:32:19 +0200 Subject: [Rxtx] rxtx serial port event problems with usb adapter In-Reply-To: References: Message-ID: Hi all again, Is there any chance that the latest driver update mentioned on http://www.ftdichip.com/Drivers/VCP.htm could not be included in the kernel for Ubuntu 8.04 (2.6.24-19-generic) ? Best regards, Helge Fredriksen 2009/3/30 Luca Catoni > My java application communicates with datalogger via rs232. Rxtx library > works fine on linux and windows system using serial port. The problems come > when I use an usb adapter FTDI chip-set based ( > http://www.ftdichip.com/Products/EvaluationKits/US232R-10.htm) on my lunux > system (2.6.24 kernel), where there is no need of driver. On windows instead > I have no problem. My program is event based; This adapter works correctly > using Mincom. But in my program I use serialPort.notifyOnDataAvailable(true) > and serialPort.notifyOnOutputEmpty(true) calls. > > My application send first message correctly but I get an error in response: > > at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) > > at gnu.io.RXTXPort.nativeDrain(Native Method) > > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201) > > > > If I comment flush() command after send first message I have no response > and my time-out exceeds. It seems there are problems when generating > SerialPortEvent.DATA_AVAILABLE event. > > Can I resolve this problem ? > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090331/903a6c88/attachment-0008.html From helgeingvart at gmail.com Mon Mar 2 01:40:16 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Mon, 2 Mar 2009 09:40:16 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API Message-ID: Hello! Anyone having any experience in how to read/write using the API in multiple threads? We are getting exceptions of this sort java.io.IOException: Input/output error in writeArray at gnu.io.RXTXPort.writeArray(Native Method) at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) after some time even if we are pretty sure that it has nothing to do with the physical USB connection beeing problematic. We suspect threading issues, since isolating read/write operations into the same thread seemed to annihilate the problem. We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of the API. Any ideas? Would an updgrade of the API make things better? Best regards, Helge Fredriksen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090302/a1af5fd3/attachment-0038.html From scldad at sdc.com.au Mon Mar 2 17:56:48 2009 From: scldad at sdc.com.au (Stephen Davies) Date: Tue, 3 Mar 2009 11:26:48 +1030 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: Message-ID: <200903031126.48132.scldad@sdc.com.au> G'day Helge. I have written an application using RxTx and separate read and write threads and it has been working fine since 2006. If you are still having problems, I could probably cut out all the application-specific stuff to get something that illustrates what I did. Cheers, Stephen Davies On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > Hello! > > Anyone having any experience in how to read/write using the API in multiple > threads? We are getting exceptions of this sort > > java.io.IOException: Input/output error in writeArray > at gnu.io.RXTXPort.writeArray(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > > after some time even if we are pretty sure that it has nothing to do with > the physical USB connection beeing problematic. We > suspect threading issues, since isolating read/write operations into the > same thread seemed to annihilate the problem. > > We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of > the API. > > Any ideas? Would an updgrade of the API make things better? > > Best regards, > Helge Fredriksen -- ============================================================================= Stephen Davies Consulting P/L Voice: 08-8177 1595 Adelaide, South Australia. Fax : 08-8177 0133 Computing & Network solutions. Mobile:040 304 0583 VoIP:sip:1132210 at sip1.bbpglobal.com From tjarvi at qbang.org Mon Mar 2 17:59:34 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Mon, 2 Mar 2009 17:59:34 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <200903031126.48132.scldad@sdc.com.au> References: <200903031126.48132.scldad@sdc.com.au> Message-ID: It would also be interesting to know a bit more about the 'USB' device. Is this bluetooth? On Tue, 3 Mar 2009, Stephen Davies wrote: > G'day Helge. > > I have written an application using RxTx and separate read and write threads > and it has been working fine since 2006. > > If you are still having problems, I could probably cut out all the > application-specific stuff to get something that illustrates what I did. > > Cheers, > Stephen Davies > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: >> Hello! >> >> Anyone having any experience in how to read/write using the API in multiple >> threads? We are getting exceptions of this sort >> >> java.io.IOException: Input/output error in writeArray >> at gnu.io.RXTXPort.writeArray(Native Method) >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) >> >> after some time even if we are pretty sure that it has nothing to do with >> the physical USB connection beeing problematic. We >> suspect threading issues, since isolating read/write operations into the >> same thread seemed to annihilate the problem. >> >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version of >> the API. >> >> Any ideas? Would an updgrade of the API make things better? >> >> Best regards, >> Helge Fredriksen > > > > -- > ============================================================================= > Stephen Davies Consulting P/L Voice: 08-8177 1595 > Adelaide, South Australia. Fax : 08-8177 0133 > Computing & Network solutions. Mobile:040 304 0583 > VoIP:sip:1132210 at sip1.bbpglobal.com > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From helgeingvart at gmail.com Tue Mar 3 01:03:12 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 09:03:12 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: Thanks for your replies. No, it's not bluetooth, it is some custom made device based on the FTDI FT232R architecture. One more thing, when I get these exceptions, is there any way to wake up the Commport again, or do I need to open it again with the extra labour of reinitialize streams and listeners? Yes, it would be really helpful to see some multithreaded example code, please! Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 1:59 AM, Trent Jarvi wrote: > > > It would also be interesting to know a bit more about the 'USB' device. > Is this bluetooth? > > On Tue, 3 Mar 2009, Stephen Davies wrote: > > > G'day Helge. > > > > I have written an application using RxTx and separate read and write > threads > > and it has been working fine since 2006. > > > > If you are still having problems, I could probably cut out all the > > application-specific stuff to get something that illustrates what I did. > > > > Cheers, > > Stephen Davies > > > > On Monday 02 March 2009 19:10:16 Helge Fredriksen wrote: > >> Hello! > >> > >> Anyone having any experience in how to read/write using the API in > multiple > >> threads? We are getting exceptions of this sort > >> > >> java.io.IOException: Input/output error in writeArray > >> at gnu.io.RXTXPort.writeArray(Native Method) > >> at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1124) > >> > >> after some time even if we are pretty sure that it has nothing to do > with > >> the physical USB connection beeing problematic. We > >> suspect threading issues, since isolating read/write operations into the > >> same thread seemed to annihilate the problem. > >> > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version > of > >> the API. > >> > >> Any ideas? Would an updgrade of the API make things better? > >> > >> Best regards, > >> Helge Fredriksen > > > > > > > > -- > > > ============================================================================= > > Stephen Davies Consulting P/L Voice: 08-8177 > 1595 > > Adelaide, South Australia. Fax : 08-8177 > 0133 > > Computing & Network solutions. Mobile:040 304 > 0583 > > > VoIP:sip:1132210 at sip1.bbpglobal.com > > _______________________________________________ > > 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: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/139ed122/attachment-0037.html From ilkka at myller.com Tue Mar 3 02:00:07 2009 From: ilkka at myller.com (Ilkka Myller) Date: Tue, 3 Mar 2009 11:00:07 +0200 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Hi Helge, Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is more stable in multithreaded use than rxtx 2.1. -- I > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old > version of > >> the API. From michael.erskine at ketech.com Tue Mar 3 02:45:07 2009 From: michael.erskine at ketech.com (Michael Erskine) Date: Tue, 3 Mar 2009 09:45:07 +0000 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> Message-ID: <06BA3262D918014F9183B66425D5A8D45F7D7FBF2C@no-sv-03.ketech.local> > From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf > Of Helge Fredriksen > Sent: 03 March 2009 08:03 > Subject: Re: [Rxtx] Multithreaded usage of the rxtx API > One more thing, when I get these exceptions, is there any way to wake > up the Commport again, or do I need to open it again with the extra > labour of reinitialize streams and listeners? > > Yes, it would be really helpful to see some multithreaded example code, > please! Hi Helge, I use RXTX in many heavily multithreaded applications but I never share InputStream and OutputStream objects: data is read from the input with data received events, buffered into complete messages which are then queued to be processed (in a queue that is essentially a java.util.concurrent.LinkedBlockingDeque). Similarly any messages to be sent (by any thread) are queued to be sent by a dedicated sending thread that just blocks waiting for messages to appear on the queue. I believe it may suffice just to synchronize on the InputStream and OutputStream objects but take care not to deadlock when closing ports. Regards, Michael Erskine. From helgeingvart at gmail.com Tue Mar 3 03:18:42 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Tue, 3 Mar 2009 11:18:42 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Is there anyway to find out the version by quering the API? I think I lost a bit track of where the version of the library I'm using was downloaded from. There seem to have been some upgrade of the project pages? Best regards, Helge Fredriksen On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/136075b3/attachment-0037.html From tristan.dyer at cgi.com Tue Mar 3 09:06:57 2009 From: tristan.dyer at cgi.com (Dyer, Tristan) Date: Tue, 3 Mar 2009 11:06:57 -0500 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/498ba4b0/attachment-0036.html From Martin.Oberhuber at windriver.com Tue Mar 3 10:45:10 2009 From: Martin.Oberhuber at windriver.com (Oberhuber, Martin) Date: Tue, 3 Mar 2009 18:45:10 +0100 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <200903031126.48132.scldad@sdc.com.au><72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <460801A4097E3D4CA04CC64EE6485848099133C1@ism-mail03.corp.ad.wrs.com> Hi Tristan, If you are on linux, then one option is using socat on each machine to forward your serial port to a network socket. There are some nice examples. http://www.dest-unreach.org/socat/ http://stackoverflow.com/questions/52187/virtual-serial-port-for-linux If you google for "virtual serial" "virtual comm port" or similar, you should be finding more. There are some commercial solutions as well as some open source ones. Cheers, -- Martin Oberhuber, Senior Member of Technical Staff, Wind River Target Management Project Lead, DSDP PMC Member http://www.eclipse.org/dsdp/tm ________________________________ From: rxtx-bounces at qbang.org [mailto:rxtx-bounces at qbang.org] On Behalf Of Dyer, Tristan Sent: Dienstag, 03. M?rz 2009 17:07 To: rxtx Subject: [Rxtx] Port Forwarding--off topic Hi, A new requirement I have been handed is to be able to make the system run on a thin client environmnet. I have no idea if a boxed solution (the client is investigating) will be used and if it will automaticly forward serial ports, i have a feeling it wont. Does anybody have experience forwarding serial ports so they can be used remotely? I believe Sun's Secure Global Desktop can do this, but I dont think Sun will be used. I know if i use RDP on windows to another RDP on windows the app works great, but I cant seem to get xrdp to work on linux, is there a differnet solution anybody has used? As an additional constraint from the PHB it has to be "open". And ideally would work windows <-> linux. Thanks, -- Tristan Dyer, Analyst CGI - Services to Credit Unions 7071 Bayers Rd., Suite 103 Halifax, NS B3L 2C2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090303/9e60708b/attachment-0036.html From cstandbridge at esmertec.com Tue Mar 3 11:49:28 2009 From: cstandbridge at esmertec.com (Clive Standbridge) Date: Tue, 3 Mar 2009 18:49:28 +0000 Subject: [Rxtx] Port Forwarding--off topic In-Reply-To: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> References: <9DA32B4D8579AF44AD96C1CC2E9C518D0326CCEA@MTL-MSG-02.cgiclients.com> Message-ID: <20090303184928.GH27479@bilko.esmertec.com> On Tue 3 Mar 2009 11:06:57 -0500(-0500), Dyer, Tristan wrote: > Hi, > > A new requirement I have been handed is to be able to make the system > run on a thin client environmnet. > > I have no idea if a boxed solution (the client is investigating) will be > used and if it will automaticly forward serial ports, i have a feeling > it wont. > > Does anybody have experience forwarding serial ports so they can be used > remotely? > > I believe Sun's Secure Global Desktop can do this, but I dont think Sun > will be used. > > I know if i use RDP on windows to another RDP on windows the app works > great, but I cant seem to get xrdp to work on linux, is there a > differnet solution anybody has used? > > As an additional constraint from the PHB it has to be "open". And > ideally would work windows <-> linux. I've had some success using termnetd and ttyd at the physical and virtual ends respectively. For added complication it's tunnelled over an ssh connection. Occasionally there is an ioctl error but mostly it works alright. You may find termnetd and ttyd packaged for your favourite Linux distribution (I have Debian and Ubuntu). I can't help with the windows requirement though. You might want to search on RFC 2217 which defines a protocol for serial port redirection. I only heard of it after successfully setting up the above so I haven't looked at it in detail. I hope this helps. Clive From tjarvi at qbang.org Tue Mar 3 19:08:56 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Tue, 3 Mar 2009 19:08:56 -0700 (MST) Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: There are two static calls that contain version info. gnu.io.RXTXVersion.getVersion(); // the jar gnu.io.RXTXVersion.nativeGetVersion(); // the shared library On Tue, 3 Mar 2009, Helge Fredriksen wrote: > Is there anyway to find out the version by quering the API? I think I lost a > bit track of where the version of the library I'm using was downloaded from. > There > seem to have been some upgrade of the project pages? > > Best regards, > Helge Fredriksen > > On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the > 2.2 is more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 > year old version of > >> the API. > > > > From helgeingvart at gmail.com Wed Mar 4 06:27:50 2009 From: helgeingvart at gmail.com (Helge Fredriksen) Date: Wed, 4 Mar 2009 14:27:50 +0100 Subject: [Rxtx] Multithreaded usage of the rxtx API In-Reply-To: <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> References: <200903031126.48132.scldad@sdc.com.au> <72BD445E-1BCB-412B-94A4-88CAF9D71D89@myller.com> Message-ID: Ok, tried to download and use the 2.2pre binaries, and I'm getting a mismatch printout. Jar version seems to be on the 2.2pre1, while binaries are on the 2.2pre2 level. Will someone uploading correct ones, or should I just compile my own stuff? Regards, Helge F. On Tue, Mar 3, 2009 at 10:00 AM, Ilkka Myller wrote: > Hi Helge, > > Have you tested your code with rxtx 2.2pre? In my experience the 2.2 is > more stable in multithreaded use than rxtx 2.1. > > -- > > I > > > >> We are running on a Ubuntu 8.10 Linux distro using a 2 year old version >> of >> >> the API. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/905614a9/attachment-0036.html From julianbui at gmail.com Wed Mar 4 14:34:35 2009 From: julianbui at gmail.com (Julian Bui) Date: Wed, 4 Mar 2009 13:34:35 -0800 Subject: [Rxtx] SerialInputStream Message-ID: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Hi all, I noticed that SerialInputStream is not found in javax.comm. Interestingly, the methods on this SerialInputStream do not seem to do the same thing as described in java's InputStream class. For example, the serialinputstream.read() does not block. Here is my test case:\ InputStream in = serialPort.getInputStream(); //where serialPort is an > instance of SerialPort, obviously ... byte[] buffer = new byte[1024]; > int len = -1; > try > { > while ( ( len = this.in.read(buffer)) > -1 ) > { > System.out.println("length:" + len); > System.out.println("buffer:" + new > String(buffer,0,len)); > } > } > catch ( IOException e ) > { > e.printStackTrace(); > } > this code prints out length: len: 0 when no data is transmitted. According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big enough to handle any read data. Because I've declared buffer to be of size 1024, I know this is not the case. Now, read(byte[]) should return "the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached." Also, InputStream blocks on read (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") Because "length:0" is printed out, this indicates that read DOES NOT BLOCK. Can anyone confirm this? This seems not to adhere to the InputStream java docs even though SerialPort.getInputStream() returns a subclass of InputStream. This does not make sense to me. --- Furthermore, the example on the rxtx website for event based communication doesn't seem to work. If you get two events sent in very close time proximity to each other, not all data is printed out. I assume there is some blocking, or buffer overwriting, or threadsafe problem. Has anyone heard of this? Here is the example code on the website: public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; > while ( ( data = in.read()) > -1 ) { if ( data != '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } > catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } I had to modify this to get it to work properly and print out both events' data. Here is my modified code: try { > int avail; > while ((avail = in.available()) > 0) { > byte[] buffer = new byte[avail]; > in.read(buffer, 0, avail); > System.err.print(new String(buffer)); > } > > } catch (IOException e) { > e.printStackTrace(); > System.exit(-1); > } Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly. I do not know if read blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's description). Does my implementation fit in with everyones' understand on how this works? Please let me know guys. Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090304/9930f2b9/attachment-0035.html From tjarvi at qbang.org Wed Mar 4 16:09:42 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Wed, 4 Mar 2009 16:09:42 -0700 (MST) Subject: [Rxtx] SerialInputStream In-Reply-To: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> References: <428370d20903041334xd42fc8epd8144e2b5bd06a2d@mail.gmail.com> Message-ID: On Wed, 4 Mar 2009, Julian Bui wrote: > Hi all, > > I noticed that SerialInputStream is not found in javax.comm.? Interestingly, the methods on this SerialInputStream do not seem to do the same thing as > described in java's InputStream class.? For example, the serialinputstream.read() does not block.? Here is my test case:\ > > InputStream in = serialPort.getInputStream(); //where serialPort is an instance of SerialPort, obviously > > > ... > > byte[] buffer = new byte[1024]; > ??????????? int len = -1; > ??????????? try > ??????????? { > ??????????????? while ( ( len = this.in.read(buffer)) > -1 ) > ??????????????? { > ??????????????????? System.out.println("length:" + len); > ??????????????????? System.out.println("buffer:" + new String(buffer,0,len)); > ??????????????? } > ??????????? } > ??????????? catch ( IOException e ) > ??????????? { > ??????????????? e.printStackTrace(); > ??????????? } > > > this code prints out length: len: 0 when no data is transmitted. > > According to InputStream from the java API, "length: 0" should never be printed unless your buffer is of size 0 because in that case the buffer isn't big > enough to handle any read data.? Because I've declared buffer to be of size 1024, I know this is not the case.? Now, read(byte[]) should return "the total > number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached."? Also, InputStream blocks on read > (quote : "This method blocks until input data is available, end of file is detected, or an exception is thrown.") > > Because "length:0" is printed out, this indicates that read DOES NOT BLOCK.? Can anyone confirm this?? This seems not to adhere to the InputStream java docs > even though SerialPort.getInputStream() returns a subclass of InputStream. > > This does not make sense to me. > > --- > > Furthermore, the example on the rxtx website for event based communication doesn't seem to work.? If you get two events sent in very close time proximity to > each other, not all data is printed out.? I assume there is some blocking, or buffer overwriting, or threadsafe problem.? Has anyone heard of this? > > Here is the example code on the website: > > public void serialEvent(SerialPortEvent arg0) { int data; try { int len = 0; while ( ( data = in.read()) > -1 ) { if ( data?!= '\n' ) { break; } > buffer[len++] = (byte) data; } System.out.print(new String(buffer,0,len)); } catch ( IOException e ) { e.printStackTrace(); System.exit(-1); } } > > > I had to modify this to get it to work properly and print out both events' data. > > Here is my modified code: > > try { > ??????????????????? int avail; > ??????????????????? while ((avail = in.available()) > 0) { > ??????????????????????? byte[] buffer = new byte[avail]; > ??????????????????????? in.read(buffer, 0, avail); > ??????????????????????? System.err.print(new String(buffer)); > ??????????????????? } > > ??????????????? } catch (IOException e) { > ??????????????????? e.printStackTrace(); > ??????????????????? System.exit(-1); > ??????????????? } > > > Because there are no java docs for the rxtx SerialInputStream class, I don't know if I'm using .available() and .read() properly.? I do not know if read > blocks and I don't know if available only shows bytes available so that the next caller doesn't block (see the java inputstream .available() method's > description). > > Does my implementation fit in with everyones' understand on how this works?? > The behavior of read() is dictated by the timeout and threshold values set for the port. This isn't a well documented corner of the API but presumably the following should work: *timeout threshold Behavior *------------------------------------------------------------------------ *0 0 blocks until 1 byte is available *>0 0 blocks until timeout occurs, returns 0 on timeout *>0 >0 blocks until timeout or reads threshold bytes, returns 0 on timeout *0 >0 blocks until either threshold # of bytes or len bytes, whichever was lower. -- Trent Jarvi tjarvi at qbang.org From fx.gendrin at ses-esl.com Thu Mar 12 09:37:24 2009 From: fx.gendrin at ses-esl.com (=?iso-8859-1?Q?Fran=E7ois-Xavier_GENDRIN?=) Date: Thu, 12 Mar 2009 16:37:24 +0100 Subject: [Rxtx] new version Message-ID: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Hi all, Anyone have some news about new version of rxtx ? Best regards, -- Fran?ois-Xavier Gendrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/c0048a2b/attachment-0027.html From tjarvi at qbang.org Thu Mar 12 11:23:04 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 11:23:04 -0600 (MDT) Subject: [Rxtx] new version In-Reply-To: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> References: <1B1721CFDAA644448FFD1B5A7EC2103F021ABF2D@lune.ses-esl.com> Message-ID: On Thu, 12 Mar 2009, Fran?ois-Xavier GENDRIN wrote: > > Hi all, > > ? > > Anyone have some news about new version of rxtx?? > > ? > I've been working on the new release the last couple weekends. I hope to have everything ready this weekend. I've been having some issues with the w32/w64 portion of the release. -- Trent Jarvi tjarvi at qbang.org From rithy8 at gmail.com Thu Mar 12 16:12:05 2009 From: rithy8 at gmail.com (rithy roth) Date: Thu, 12 Mar 2009 14:12:05 -0800 Subject: [Rxtx] question about jar and dll mismatch Message-ID: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Hi, I am using rxtx-2.2pre2-bins\win32. When I start my app, I got a warning: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Is this intentional? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090312/e7f55f49/attachment-0027.html From andrey.u at gmail.com Thu Mar 12 18:38:39 2009 From: andrey.u at gmail.com (Andrey Ustyuzhanin) Date: Fri, 13 Mar 2009 03:38:39 +0300 Subject: [Rxtx] Error 0x5 (USB serial device unplug) Message-ID: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Gteetings! In my project I use USB -> Serial devices and there are possible scenarios when user unplugs device during application work. I'd like to figure out status of RXTX support of such scenarious (the last message I've found in this mailist regarding this subject was dated by Feb 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html) Are there any progress since then? plans maybe? I've checked binary version on Windows XP from rxtx-2.2pre2-bins.zip it still keeps firing Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. like crazy upon device unplug. Thank you in advance! Kindest Regards, Andrey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/9a197be6/attachment-0027.html From tjarvi at qbang.org Thu Mar 12 21:20:33 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:20:33 -0600 (MDT) Subject: [Rxtx] question about jar and dll mismatch In-Reply-To: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> References: <79e2547b0903121512j2878b5c1t67260c87d63cec2b@mail.gmail.com> Message-ID: On Thu, 12 Mar 2009, rithy roth wrote: > Hi, > > I am using rxtx-2.2pre2-bins\win32. > > When I start my app, I got a warning: > > WARNING:? RXTX Version mismatch > ??????? Jar version = RXTX-2.2pre1 > ??????? native lib Version = RXTX-2.2pre2 > > Is this intentional? > > If the jar is indeed pre1, that is a mistake on my part. You should be able to CVS checkout the '2.1' tree and build a clean jar. You don't need to compile the native code. cd src javac gnu/io/*.java jar -cf RXTXcomm.jar gnu/io/*.class I assumed the 2.1pre1 mismatch I saw posted earlier was a user error. Either way, the fix will be pre3 as soon as I can finish it. -- Trent Jarvi tjarvi at qbang.org From tjarvi at qbang.org Thu Mar 12 21:43:18 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 12 Mar 2009 21:43:18 -0600 (MDT) Subject: [Rxtx] Error 0x5 (USB serial device unplug) In-Reply-To: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> References: <450ac4270903121738u79687595o210da2be0e99ed6b@mail.gmail.com> Message-ID: On Fri, 13 Mar 2009, Andrey Ustyuzhanin wrote: > Gteetings! > In my project I use USB -> Serial devices and there are possible scenarios > when user unplugs device during application work.? > > I'd like to figure out status of RXTX support of such scenarious (the last > message I've found in this mailist regarding this subject was dated by Feb > 2007 (http://mailman.qbang.org/pipermail/rxtx/2007-February/3864195.html)? > > Are there any progress since then? plans maybe?? > > I've checked binary version on Windows XP from?rxtx-2.2pre2-bins.zip? > it still keeps firing? > > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(2712): ???????? ? ???????. > Error 0x5 at ..\src\termios.c(517): ???????? ? ???????. > Hi Andrey There are not any plans at the moment. We could shut down the port as mentioned in your link to avoid the messages but thats only a part of the problem. -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 01:33:07 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Fri, 13 Mar 2009 09:33:07 +0200 Subject: [Rxtx] Opening 2 serial port at the same time Message-ID: Hi All, I want to open two serial port ("COM5 and COM7") on windows at the same time. I have opened the 1st one successfully. When I trrry to open 2nd time, I get "Unknown Application" exception. What would be wrong with this? Sincerely, Olcay Ergun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090313/bd4dac34/attachment-0027.html From tjarvi at qbang.org Fri Mar 13 18:38:36 2009 From: tjarvi at qbang.org (Trent Jarvi) Date: Fri, 13 Mar 2009 18:38:36 -0600 (MDT) Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: On Fri, 13 Mar 2009, olcay ergun wrote: > Hi All, > > I want to open two serial port ("COM5 and COM7") on windows at the same > time. > I have opened the 1st one successfully. > When I trrry to open 2nd time, I get "Unknown Application" exception. > > What would be wrong with this? > > Sincerely, > > Hi Olcay Make sure you don't have another application using the port (like even another copy of the program you are using/writing). 5&7 are not common which makes me wonder what they are. It should not make any difference. Are you sure they are OK? Could they be sharing an IRQ or IRQ address? Are these USB Serial dongles? -- Trent Jarvi tjarvi at qbang.org From olcay54 at hotmail.com Fri Mar 13 23:24:57 2009 From: olcay54 at hotmail.com (olcay ergun) Date: Sat, 14 Mar 2009 07:24:57 +0200 Subject: [Rxtx] Opening 2 serial port at the same time In-Reply-To: References: Message-ID: Hi Trent, They are USB-Serial Converters. I solve the problem when I upgrade to the version rxtx 2.1-7r2. Thanks for nice reply. Olcay > Date: Fri, 13 Mar 2009 18:38:36 -0600 > From: tjarvi at qbang.org > To: olcay54 at hotmail.com > CC: rxtx at qbang.org > Subject: Re: [Rxtx] Opening 2 serial port at the same time > > > > On Fri, 13 Mar 2009, olcay ergun wrote: > > > Hi All, > > > > I want to open two serial port ("COM5 and COM7") on windows at the same > > time. > > I have opened the 1st one successfully. > > When I trrry to open 2nd time, I get "Unknown Application" exception. > > > > What would be wrong with this? > > > > Sincerely, > > > > > > Hi Olcay > > Make sure you don't have another application using the port (like even > another copy of the program you are using/writing). > > 5&7 are not common which makes me wonder what they are. It should not > make any difference. Are you sure they are OK? Could they be sharing an > IRQ or IRQ address? Are these USB Serial dongles? > > > -- > Trent Jarvi > tjarvi at qbang.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090314/f8d8ac64/attachment-0026.html From phineas919 at gmail.com Wed Mar 18 13:57:47 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 15:57:47 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 Message-ID: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON modem. The same issues occur with three different versions of the gnu.io RXTX libraries running under JDK 1.5 or 1.6: 1) compiled from source using the commapi-0-0-1 branch (as of today) 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip (after I get around the locking problem by creating /var/lock)\ The details of my hardware and issues I'm seeing are listed in the class comment of my test program below. What I'm wondering is- are these problems specific to my USB serial adapter in combination with RXTX? Does someone know of another one that works well for them on OS X? Am I doing something wrong in my code? Thanks for the valuable work so far on RXTX! ----- package haserver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.RXTXPort; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This tests sending commands to the PowerLinc 2400S/2412S INSTEON RS232 modem. * I'm using a Prolific PL2303 USB-To-Serial bridge controller (Product ID * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com on * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this using * JDK 1.5.0_16 and 1.6.0_07. * * While the PowerLinc modem works fine from a Windows XP VM running in VMWare * Fusion, running the Docklight Scripting V1.8 program, it exhibits the * following problems using this test program in OS X itself using the exact same * hardware: * * Problem #1: No matter whether I read data in a separate thread, in the same * thread, or using SerialEvents, the program only works once. If I run it a * second time, no data is sent or received on the serial port. I have to * unplug the adapter and plug it back in to get it to work again. * * Problem #2: Data is only returned one byte at a time on reads. Even if * read(byte[]) is used, still only one byte is returned at a time. * * Problem #3: If I try to call commPort.close() while still reading data on * another thread, the program hangs. * * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get the error: * Invalid memory access of location 104f0928 rip=1033612f */ public class Main implements SerialPortEventListener { private InputStream m_in; private OutputStream m_out; public Main() { } public void run() throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = (RXTXPort) portIdentifier.open( Main.class.getName(), 2000); RXTXPort serialPort = (RXTXPort) commPort; serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); // set receive timeout, otherwise program will never complete serialPort.enableReceiveTimeout(2000); m_in = serialPort.getInputStream(); m_out = serialPort.getOutputStream(); // Read response method #1: read in a separate thread //Thread thr = new Thread(new SerialReader(in)); //thr.start(); //Thread.sleep(1000); // make sure thread is started // a few basic PowerLinc commands byte[] getVersion = new byte[]{0x02, 0x60}; // get version command byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0x00}; // light off command byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, 0x05, 0x11, (byte) 0xff}; // light on command // send command System.out.println("Sending data"); m_out.write(getVersion); System.out.println("Flushing"); m_out.flush(); System.out.println("Done"); // Read response, method #2: read data from the same thread //int i; //while (-1 != (i = in.read())) //{ // System.out.print (Integer.toHexString(i) + " "); //} //System.out.println(); // only if using event listener //serialPort.removeEventListener(); // wait for data to be returned Thread.sleep(2000); System.out.println("Closing"); m_out.close(); m_in.close(); commPort.close(); System.out.println("Closed"); } } /** * Called when a serial event occurs. * * @param ev the event */ public void serialEvent(SerialPortEvent ev) { // Read response, method #3: process SerialPortEvents System.out.println("Serial event: " + ev.getEventType()); if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int i = m_in.read(); System.out.println(Integer.toHexString(i) + " "); } catch (IOException ioe) { ioe.printStackTrace(); } } } /** * Thread that dumps input from the serial port to standard out. */ public class SerialReader implements Runnable { private InputStream in; public SerialReader(InputStream in) { this.in = in; } public void run() { byte[] buffer = new byte[1024]; int len = -1; try { while ((len = this.in.read(buffer)) > -1) { for (int i = 0; i < len; i++) System.out.println(Integer.toHexString(i) + " "); } } catch (IOException e) { e.printStackTrace(); } } } /** * Main. * * args command line arguments */ public static void main(final String[] args) throws Exception { Main main = new Main(); main.run(); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f8d67680/attachment-0021.html From phineas919 at gmail.com Wed Mar 18 14:50:03 2009 From: phineas919 at gmail.com (Phineas Gage) Date: Wed, 18 Mar 2009 16:50:03 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <47F9324B-D730-4E8E-A284-FC8943E32A49@gmail.com> I wanted to provide one update to this. I didn't mention that I was using the driver available from Prolific at http://www.prolific.com.tw/eng/downloads.asp?ID=31 . I just tried switching to the open source driver available at http://sourceforge.net/projects/osx-pl2303 . This fixed Problem #1 in my original program, where I had to unplug the cable after each run of my program. I still see the other three issues, but this does take care of the biggest one. I would prefer to run with Prolific's original driver because I don't know if I'll hit other issues down the road, but this is an interesting result for debugging purposes. Coming back to a question in the original post- does anyone know of a USB-Serial adapter that behaves well with RXTX under OS X using supported drivers that came from its manufacturer? On Mar 18, 2009, at 3:57 PM, Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ..... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/40fb6502/attachment-0021.html From netbeans at gatworks.com Wed Mar 18 15:13:55 2009 From: netbeans at gatworks.com (U. George) Date: Wed, 18 Mar 2009 17:13:55 -0400 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: <49C16413.8070806@gatworks.com> Phineas Gage wrote: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter on > OS X 10.5.6 with RXTX. > > 1) compiled from source using the commapi-0-0-1 branch (as of today) I suppose I should first ask if u tried any of this on a non OS X box? Maybe like a linux/86 box? Just to try. Should it work, then your program, and RXTX are not the issue. If you can compile all of source, are u "C" savy enough to place some printf() statements near the Native read and Native write routines? If the native read routine has a char count of one in a buffer ( of lets say 80 bytes ) then that is all the driver is giving to the native rxtx read routine. U might also place a printf near the close() routine to insure that channel is properly closed before exiting ( or reusing ). All this will just help u confirm that the I/O is happening as you expect. If driver is broken, then nothing you will ever do in java/rxtx will fix the driver. From ilkka at myller.com Wed Mar 18 15:39:54 2009 From: ilkka at myller.com (Ilkka Myller) Date: Wed, 18 Mar 2009 23:39:54 +0200 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 In-Reply-To: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> References: <7A13DF81-8B1F-4CE0-92D0-F3D5736EB4A6@gmail.com> Message-ID: Few weeks ago I posted a patch to fix the invalid memory access error when closing ports (problem #4). The patch is for 2.2pre2 code. Link to rxtx-list archive: http://mailman.qbang.org/pipermail/rxtx/2009-February/3896597.html The patch is not yet in CVS (@2009-03-18) -- I Phineas Gage kirjoitti 18.3.2009 kello 21.57: > I'm seeing several issues using a Prolific PL2303 USB-Serial adapter > on OS X 10.5.6 with RXTX. I'm communicating with a PowerLinc INSTEON > modem. The same issues occur with three different versions of the > gnu.io RXTX libraries running under JDK 1.5 or 1.6: > > 1) compiled from source using the commapi-0-0-1 branch (as of today) > 2) using the 2.2 pre2 binaries available at http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip > 3) using the 2.1.7 r2 binaries available http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip > (after I get around the locking problem by creating /var/lock)\ > > The details of my hardware and issues I'm seeing are listed in the > class comment of my test program below. What I'm wondering is- are > these problems specific to my USB serial adapter in combination with > RXTX? Does someone know of another one that works well for them on > OS X? Am I doing something wrong in my code? > > Thanks for the valuable work so far on RXTX! > > ----- > > package haserver; > > import gnu.io.CommPort; > import gnu.io.CommPortIdentifier; > import gnu.io.RXTXPort; > import gnu.io.SerialPort; > import gnu.io.SerialPortEvent; > import gnu.io.SerialPortEventListener; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > /** > * This tests sending commands to the PowerLinc 2400S/2412S INSTEON > RS232 modem. > * I'm using a Prolific PL2303 USB-To-Serial bridge controller > (Product ID > * 0x2303, Vendor ID 0x067b, Version 3.00) available from www.serialio.com > on > * a 2.4 GHz MacBook Pro running Mac OS X 10.5.6. I have tried this > using > * JDK 1.5.0_16 and 1.6.0_07. > * > * While the PowerLinc modem works fine from a Windows XP VM running > in VMWare > * Fusion, running the Docklight Scripting V1.8 program, it exhibits > the > * following problems using this test program in OS X itself using > the exact same > * hardware: > * > * Problem #1: No matter whether I read data in a separate thread, in > the same > * thread, or using SerialEvents, the program only works once. If I > run it a > * second time, no data is sent or received on the serial port. I > have to > * unplug the adapter and plug it back in to get it to work again. > * > * Problem #2: Data is only returned one byte at a time on reads. > Even if > * read(byte[]) is used, still only one byte is returned at a time. > * > * Problem #3: If I try to call commPort.close() while still reading > data on > * another thread, the program hangs. > * > * Problem #4: If I use JDK 1.6, after "Closing" is printed, I get > the error: > * Invalid memory access of location 104f0928 rip=1033612f > */ > public class Main implements SerialPortEventListener { > > private InputStream m_in; > private OutputStream m_out; > > public Main() { > } > > public void run() > throws Exception { > CommPortIdentifier portIdentifier = > CommPortIdentifier.getPortIdentifier("/dev/tty.usbserial"); > > if (portIdentifier.isCurrentlyOwned()) { > System.out.println("Error: Port is currently in use"); > } else { > CommPort commPort = (RXTXPort) portIdentifier.open( > Main.class.getName(), 2000); > > RXTXPort serialPort = (RXTXPort) commPort; > serialPort.setSerialPortParams(19200, > SerialPort.DATABITS_8, > SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); > serialPort.addEventListener(this); > serialPort.notifyOnDataAvailable(true); > // set receive timeout, otherwise program will never > complete > serialPort.enableReceiveTimeout(2000); > > m_in = serialPort.getInputStream(); > m_out = serialPort.getOutputStream(); > > // Read response method #1: read in a separate thread > //Thread thr = new Thread(new SerialReader(in)); > //thr.start(); > //Thread.sleep(1000); // make sure thread is started > > // a few basic PowerLinc commands > byte[] getVersion = new byte[]{0x02, 0x60}; // get > version command > byte[] lightOff = new byte[]{0x02, 0x62, 0x11, 0x11, > 0x11, 0x05, > 0x11, (byte) 0x00}; // light off command > byte[] lightOn = new byte[]{0x02, 0x62, 0x11, 0x11, 0x11, > 0x05, > 0x11, (byte) 0xff}; // light on command > > // send command > System.out.println("Sending data"); > m_out.write(getVersion); > System.out.println("Flushing"); > m_out.flush(); > System.out.println("Done"); > > // Read response, method #2: read data from the same thread > //int i; > //while (-1 != (i = in.read())) > //{ > // System.out.print (Integer.toHexString(i) + " "); > //} > //System.out.println(); > > // only if using event listener > //serialPort.removeEventListener(); > > // wait for data to be returned > Thread.sleep(2000); > > System.out.println("Closing"); > m_out.close(); > m_in.close(); > commPort.close(); > System.out.println("Closed"); > } > } > > /** > * Called when a serial event occurs. > * > * @param ev the event > */ > public void serialEvent(SerialPortEvent ev) { > // Read response, method #3: process SerialPortEvents > System.out.println("Serial event: " + ev.getEventType()); > if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { > try { > int i = m_in.read(); > System.out.println(Integer.toHexString(i) + " "); > } catch (IOException ioe) { > ioe.printStackTrace(); > } > } > } > > /** > * Thread that dumps input from the serial port to standard out. > */ > public class SerialReader implements Runnable { > > private InputStream in; > > public SerialReader(InputStream in) { > this.in = in; > } > > public void run() { > byte[] buffer = new byte[1024]; > int len = -1; > try { > while ((len = this.in.read(buffer)) > -1) { > for (int i = 0; i < len; i++) > System.out.println(Integer.toHexString(i) + " > "); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > /** > * Main. > * > * args command line arguments > */ > public static void main(final String[] args) > throws Exception { > Main main = new Main(); > main.run(); > } > } > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.qbang.org/pipermail/rxtx/attachments/20090318/f26a5d73/attachment-0021.html From Noel.Goldsmith at dsto.defence.gov.au Wed Mar 18 16:08:33 2009 From: Noel.Goldsmith at dsto.defence.gov.au (Goldsmith, Noel) Date: Thu, 19 Mar 2009 09:08:33 +1100 Subject: [Rxtx] problems with PL2303 USB-Serial adapter in OS X 10.5.6 (Phineas Gage) In-Reply-To: Message-ID: > > 1. Re: problems with PL2303 USB-Serial adapter in OS X 10.5.6 > (Phineas Gage) > > From: Phineas Gage > Subject: Re: [Rxtx] problems with PL2303 USB-Serial adapter in OS X > 10.5.6 > > Coming back to a question in the original post- does anyone know of a > USB-Serial adapter that behaves well with RXTX under OS X using > supported drivers that came from its manufacturer? > I am using the Keyspan twin serial adaptors (USA 28X) of various vintages, and have had very little trouble. We have been using the same adaptors for about 10 years now, I tried some other solutions ( eg Stealth Serial Port) but have found the Keyspans to be robust, easy and they seem to be fairly future proof. I use the Keyspan drivers for OSX and rxtx together with ImageJ. I have 5 Mac systems in daily use by a number (about 15) of different users, on (4 G5's and 1 Intel), and the part which gives the least trouble is the Keyspan. Not that we have much trouble anyway. I am interfacing with Ludl microscope stage controllers and a Leica motorized focus drive on an MZ16 stereo microscope, and also some in house interfaces which read Mitutoyo Binary coded serial micrometer heads into an rs232C port. We are running 10.5.6. I am running a version of rxtx which is patched to work with 64 bit ImageJ on the Intel Mac (Thanks to Guilano Gavazzi), the version is the 2.2Pre, I think. On the G5's the version is the same. Hope this helps. -- Noel Goldsmith Air Vehicles Division Defence Science and Technology Organisation 506 Lorimer Street Port Melbourne Vic 3207 Ph 03 96267527 Fax 03 96267089 Mobile 0428364003 Noel.goldsmith at dsto.defence.gov.au IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in