[Rxtx] NRJavaSerial, a fork of rxtx that fixes the papercuts!

Chris Bartley bartley at cmu.edu
Mon Mar 28 12:27:49 MDT 2011


I would think you'll also want your returned collection to be immutable by the client.  So, for example, this method in your fork of RXTXCommDriver[1]

	public Set<String> getPortIdentifiers() {
	   ...
	}

...should wrap your ports Set (which is a class member) with Collections.unmodifiableSet() before returning to the client (and make it clear in the javadocs that it's immutable).  Or, alternatively, create a new, mutable Set and return that.  Either way, the code as it stands now is buggy because the client could modify your Set.

Chris
[1] http://code.google.com/p/nrjavaserial/source/browse/trunk/nrjavaserial/src/main/java/gnu/io/RXTXCommDriver.java

On Mar 28, 2011, at 1:44 PM, Kevin Harrington NR wrote:

> So i took a closer look at Iterator List and Set as replacements, and
> decided on Set<>. It assumes uniqueness which is what this would want.
> I know sun recommends Enumeration over Iterator, but the code to
> implement and use Iterator vs enumeration is FAR nicer to the end
> user. My focus will be user experience over "convention". As an
> example:
> 
> for (Enumeration<E> e = v.elements(); e.hasMoreElements();)
>    System.out.println(e.nextElement());
> 
> vs:
> 
> for(String s: stringSetObject)
>    System.out.println(s);
> 
> Which is more intuitive? Easier to read? Easier to understand whats
> going on and how to use it?
> 
> On Mon, Mar 28, 2011 at 11:52 AM,  <rxtx-request at qbang.org> wrote:
>> Send Rxtx mailing list submissions to
>>        rxtx at qbang.org
>> 
>> To subscribe or unsubscribe via the World Wide Web, visit
>>        http://mailman.qbang.org/mailman/listinfo/rxtx
>> or, via email, send a message with subject or body 'help' to
>>        rxtx-request at qbang.org
>> 
>> You can reach the person managing the list at
>>        rxtx-owner at qbang.org
>> 
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Rxtx digest..."
>> 
>> 
>> Today's Topics:
>> 
>>   1. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (Kevin Harrington NR)
>>   2. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (Adrian Crum)
>>   3. Re  Get RXTX working on MacOSX 10.6.7 (Kevin Harrington NR)
>>   4. Re: Get RXTX working on MacOSX 10.6.7 (Andre-John Mas)
>>   5. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (Andre-John Mas)
>>   6. SLAB_USBtoUART (Chris Tooley)
>>   7. Re: SLAB_USBtoUART (Kustaa Nyholm)
>>   8. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (Adrian Crum)
>>   9. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (George H)
>>  10. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (Michael Erskine)
>>  11. Re: NRJavaSerial, a fork of rxtx that fixes the papercuts!
>>      (Adrian Crum)
>> 
>> 
>> ----------------------------------------------------------------------
>> 
>> Message: 1
>> Date: Thu, 24 Mar 2011 14:56:02 -0400
>> From: Kevin Harrington NR <kharrington at neuronrobotics.com>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID:
>>        <AANLkTi=6+RVZi=LoA3RF_n7yMokKnuzJCW=DZGUOGdnh at mail.gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>> 
>> I have fixed a few problems with the native lib in OSX. the 3.7.4
>> release will be on the google code page by the end of today. I do not
>> have a mac, so mac development and testing is catch as catch can by
>> borrowing friends computers.
>> 
>> I put out a release once a month (unless there is a show stopper bug).
>> I will only skip months is there is no issues posted and no code
>> changes as a result. I try to have a 1 day turn around on patches, and
>> would love any other developer help that anyone wants to offer. I will
>> warn everyone, i will be taking NRJavaSerial in a modern direction and
>> creating simpler to use interfaces for future releases. I will not
>> break an old interface (for now), but i will be deprecating things
>> along the way for the sake of modernisation. A good example is the
>> addition of interfaces using ArrayList<> instead of Enumerations.
>> 
>> Sorry for the problems, and i hope the new release solves your problems!
>> 
>> 
>> ------------------------------
>> 
>> Message: 2
>> Date: Thu, 24 Mar 2011 13:26:49 -0700
>> From: Adrian Crum <adrian.crum at sandglass-software.com>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID: <4D8BA909.9040606 at sandglass-software.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>> 
>> Using a concrete class in an API is a bad idea. Maybe you should
>> consider using Collection<> or Iterator<> instead of ArrayList.
>> 
>> -Adrian
>> 
>> On 3/24/2011 11:56 AM, Kevin Harrington NR wrote:
>>> I have fixed a few problems with the native lib in OSX. the 3.7.4
>>> release will be on the google code page by the end of today. I do not
>>> have a mac, so mac development and testing is catch as catch can by
>>> borrowing friends computers.
>>> 
>>> I put out a release once a month (unless there is a show stopper bug).
>>> I will only skip months is there is no issues posted and no code
>>> changes as a result. I try to have a 1 day turn around on patches, and
>>> would love any other developer help that anyone wants to offer. I will
>>> warn everyone, i will be taking NRJavaSerial in a modern direction and
>>> creating simpler to use interfaces for future releases. I will not
>>> break an old interface (for now), but i will be deprecating things
>>> along the way for the sake of modernisation. A good example is the
>>> addition of interfaces using ArrayList<>  instead of Enumerations.
>>> 
>>> Sorry for the problems, and i hope the new release solves your problems!
>>> _______________________________________________
>>> Rxtx mailing list
>>> Rxtx at qbang.org
>>> http://mailman.qbang.org/mailman/listinfo/rxtx
>> 
>> 
>> ------------------------------
>> 
>> Message: 3
>> Date: Thu, 24 Mar 2011 16:56:41 -0400
>> From: Kevin Harrington NR <kharrington at neuronrobotics.com>
>> To: rxtx at qbang.org
>> Subject: [Rxtx] Re  Get RXTX working on MacOSX 10.6.7
>> Message-ID:
>>        <AANLkTimrOb=yAyJWsLVSBfzHR1o0+wjA1UyvvA_-vnQ_ at mail.gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>> 
>> I have tested the NRJavaSerial 3.7.4 release against OSX 10.6 (latest
>> update as of a week ago) and it can communicate to the serial port
>> just fine. With our lib, dont forget, you no longer need an external
>> native code library, it is all extracted from inside the .jar file.
>> This prevents mix-ups of versions and missing library errors.
>> 
>> 
>> http://code.google.com/p/nrjavaserial/downloads/list
>> 
>> 
>> ------------------------------
>> 
>> Message: 4
>> Date: Fri, 25 Mar 2011 16:29:38 -0400
>> From: Andre-John Mas <ajmas at sympatico.ca>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] Get RXTX working on MacOSX 10.6.7
>> Message-ID: <BLU0-SMTP64792F1895987CECE2D192C5B90 at phx.gbl>
>> Content-Type: text/plain; charset="us-ascii"
>> 
>> 
>> On 24-Mar-2011, at 14:24, Chris Bartley wrote:
>> 
>>> Hi Dave,
>>> 
>>> Before proceeding with RxTx, have you verified that you can connect to your device from your Mac with a terminal program such as minicom?  I got minicom via MacPorts.  If that works, then RxTx should too.
>> 
>> The 'screen' command can also be used.
>> 
>> Andre
>> 
>> ------------------------------
>> 
>> Message: 5
>> Date: Fri, 25 Mar 2011 16:32:26 -0400
>> From: Andre-John Mas <ajmas at sympatico.ca>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID: <BLU0-SMTP84E9180A3FEED1E48210A3C5B90 at phx.gbl>
>> Content-Type: text/plain; charset="us-ascii"
>> 
>> 
>> On 24-Mar-2011, at 16:26, Adrian Crum wrote:
>> 
>>> Using a concrete class in an API is a bad idea. Maybe you should consider using Collection<> or Iterator<> instead of ArrayList.
>>> 
>>> -Adrian
>> 
>> Could probably use List<> too, depending on the use case. One advantage with using Set<> or List<> is that they give some sort of
>> indication of the uniqueness of the results.
>> 
>> My 5c.
>> 
>> Andre
>> 
>> ------------------------------
>> 
>> Message: 6
>> Date: Fri, 25 Mar 2011 17:06:12 -0700
>> From: Chris Tooley <ctooley at uvic.ca>
>> To: rxtx at qbang.org
>> Subject: [Rxtx] SLAB_USBtoUART
>> Message-ID: <4D8D2DF4.80103 at uvic.ca>
>> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
>> 
>> Anyone have luck getting RxTx to work with this:
>> http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
>> ?
>> 
>> I am using Mac OS X and
>> 
>> screen /dev/tty.SLAB_USBtoUART 115200
>> 
>> works
>> 
>> Unfortunately, I can't get any of the examples at the wiki to work..?  I
>> have a specialized device on the other end that returns data once I send
>> a command to it.
>> 
>> Currently it's just echoing back what I send...? :(
>> 
>> -Chris
>> 
>> 
>> ------------------------------
>> 
>> Message: 7
>> Date: Sat, 26 Mar 2011 06:32:06 +0200
>> From: Kustaa Nyholm <Kustaa.Nyholm at planmeca.com>
>> To: "rxtx at qbang.org" <rxtx at qbang.org>
>> Subject: Re: [Rxtx] SLAB_USBtoUART
>> Message-ID: <C9B337E1.80CF%kustaa.nyholm at planmeca.com>
>> Content-Type: text/plain; charset="us-ascii"
>> 
>> On 3/26/11 02:06, "Chris Tooley" <ctooley at uvic.ca> wrote:
>> 
>>> Anyone have luck getting RxTx to work with this:
>>> http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
>>> ?
>>> 
>>> I am using Mac OS X and
>>> 
>>> screen /dev/tty.SLAB_USBtoUART 115200
>>> 
>>> works
>>> 
>> This works for me in Mac using RxTx version:
>> 
>>  Jar version = RXTX-2.2pre1
>>  native lib Version = RXTX-2.2pre2
>> 
>> 
>> I initially had some crashes but when I updated to the lates Silabs drivers
>> all problems disappeared.
>> 
>> 
>> br Kusti
>> 
>> 
>> 
>> ------------------------------
>> 
>> Message: 8
>> Date: Sun, 27 Mar 2011 16:58:39 -0700
>> From: Adrian Crum <adrian.crum at sandglass-software.com>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID: <4D8FCF2F.7060402 at sandglass-software.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>> 
>> http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
>> 
>> 
>> On 3/25/2011 1:32 PM, Andre-John Mas wrote:
>>> On 24-Mar-2011, at 16:26, Adrian Crum wrote:
>>> 
>>>> Using a concrete class in an API is a bad idea. Maybe you should consider using Collection<>  or Iterator<>  instead of ArrayList.
>>>> 
>>>> -Adrian
>>> Could probably use List<>  too, depending on the use case. One advantage with using Set<>  or List<>  is that they give some sort of
>>> indication of the uniqueness of the results.
>>> 
>>> My 5c.
>>> 
>>> Andre
>>> _______________________________________________
>>> Rxtx mailing list
>>> Rxtx at qbang.org
>>> http://mailman.qbang.org/mailman/listinfo/rxtx
>> 
>> 
>> ------------------------------
>> 
>> Message: 9
>> Date: Mon, 28 Mar 2011 07:54:06 +0300
>> From: George H <george.dma at gmail.com>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID:
>>        <AANLkTimD236HHY_KkxJLYQJwU0GL38HZ=meOpKpKm-J0 at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>> 
>> On Mon, Mar 28, 2011 at 2:58 AM, Adrian Crum <
>> adrian.crum at sandglass-software.com> wrote:
>> 
>>> http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
>>> 
>>> 
>>> 
>>> On 3/25/2011 1:32 PM, Andre-John Mas wrote:
>>> 
>>>> On 24-Mar-2011, at 16:26, Adrian Crum wrote:
>>>> 
>>>>  Using a concrete class in an API is a bad idea. Maybe you should consider
>>>>> using Collection<>  or Iterator<>  instead of ArrayList.
>>>>> 
>>>>> -Adrian
>>>>> 
>>>> Could probably use List<>  too, depending on the use case. One advantage
>>>> with using Set<>  or List<>  is that they give some sort of
>>>> indication of the uniqueness of the results.
>>>> 
>>>> My 5c.
>>>> 
>>>> Andre
>>>> _______________________________________________
>>>> 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
>>> 
>> 
>> 
>> Well when writing a library it's always good convention to only expose
>> interfaces to the outside and on the inside you can use concrete classes
>> where you wish, or sometimes not.
>> 
>> I guess some hierarchy design docs would provide the community with enough
>> info to lend a helping hand. Not talking about anything fancy just some
>> simple diagrams.
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <http://mailman.qbang.org/pipermail/rxtx/attachments/20110328/2f4860cd/attachment-0002.htm>
>> 
>> ------------------------------
>> 
>> Message: 10
>> Date: Mon, 28 Mar 2011 10:51:40 +0100
>> From: Michael Erskine <msemtd at googlemail.com>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID:
>>        <AANLkTikxUsTt8-vLZ-mXT+yuwFcdtyJXRCiUnE5DgWmQ at mail.gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>> 
>> The java.util.List<> interface is the most appropriate for replacing
>> the java.util.Enumeration<> interface for the various RXTX collections
>> exposed through the API (although there is some argument for that list
>> to have some uniqueness of elements and some specific order).
>> 
>> Regards,
>> Michael Erskine.
>> 
>> 
>> ------------------------------
>> 
>> Message: 11
>> Date: Mon, 28 Mar 2011 09:53:53 -0700
>> From: Adrian Crum <adrian.crum at sandglass-software.com>
>> To: rxtx at qbang.org
>> Subject: Re: [Rxtx] NRJavaSerial, a fork of rxtx that fixes the
>>        papercuts!
>> Message-ID: <4D90BD21.4050306 at sandglass-software.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>> 
>> Sun/Oracle recommends replacing Enumeration with Iterator:
>> 
>> http://download.oracle.com/javase/6/docs/api/java/util/Enumeration.html
>> 
>> -Adrian
>> 
>> On 3/28/2011 2:51 AM, Michael Erskine wrote:
>>> The java.util.List<>  interface is the most appropriate for replacing
>>> the java.util.Enumeration<>  interface for the various RXTX collections
>>> exposed through the API (although there is some argument for that list
>>> to have some uniqueness of elements and some specific order).
>>> 
>>> Regards,
>>> Michael Erskine.
>>> _______________________________________________
>>> Rxtx mailing list
>>> Rxtx at qbang.org
>>> http://mailman.qbang.org/mailman/listinfo/rxtx
>> 
>> 
>> ------------------------------
>> 
>> _______________________________________________
>> Rxtx mailing list
>> Rxtx at qbang.org
>> http://mailman.qbang.org/mailman/listinfo/rxtx
>> 
>> 
>> End of Rxtx Digest, Vol 43, Issue 16
>> ************************************
>> 
> _______________________________________________
> Rxtx mailing list
> Rxtx at qbang.org
> http://mailman.qbang.org/mailman/listinfo/rxtx
> 




More information about the Rxtx mailing list