Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Updating the list of the system's serial ports

Thread view: 
Jörg Zieren - 23 Nov 2007 09:28 GMT
Hi,

I use javax.comm.CommPortIdentifier.getPortIdentifiers() to get a list
of the system's serial ports. This works fine, but the list is only
updated upon loading of the class CommPortIdentifier (through static code).

However, the Java application needs to detect a USB-to-serial converter
which is plugged in at runtime. This converter shows up as an additional
COM port (we're on WinXP). If it is plugged in before the app starts, it
is detected, but not if it is plugged in during runtime.

The said static code in CommPortIdentifier is:

CommDriver commdriver =
(CommDriver)Class.forName("javax.comm.RXTXCommDriver").newInstance();
commdriver.initialize();

This can be repeated, which does detect the newly appeared COM port, but
it only adds to the list of available ports that getPortIdentifiers()
returns, so I assume it's not meant to be done.

Is there some way to properly refresh the list of system COM ports
dynamically?

Thanx in advance,
Jörg
Andrew Thompson - 23 Nov 2007 12:00 GMT
...
>This can be repeated, which does detect the newly appeared COM port, but
>it only adds to the list of available ports that getPortIdentifiers()
>returns, so I assume it's not meant to be done.

Huh?  That paragraph seemed entirely logical up till
the point "..so I assume it's not meant to be done."

Why would you assume it is inappropriate to (for example)
start a thread that regularly checks for new COM connections,
and update a list(?/whatever) accordingly?

Signature

Andrew Thompson
http://www.physci.org/

Jörg Zieren - 23 Nov 2007 21:32 GMT
> ..
>> This can be repeated, which does detect the newly appeared COM port, but
[quoted text clipped - 7 lines]
> start a thread that regularly checks for new COM connections,
> and update a list(?/whatever) accordingly?

You're right, I was being unclear - sorry. The problem is that each
reinitialization *adds* *all* ports to the list of available ports. So at
first there's, say, "COM1 COM2 LPT1". After calling initialize()
"manually" for the first time (i.e. for the second time in total), there's
"COM1 COM2 LPT1 COM1 COM2 LPT1". And so on, so after n calls to
initialize, each port is listed n+1 times.

-Jörg
Andrew Thompson - 24 Nov 2007 04:52 GMT
>> ..
>>> This can be repeated, which does detect the newly appeared COM port, but
[quoted text clipped - 4 lines]
>You're right, I was being unclear - sorry. The problem is that each
>reinitialization *adds* *all* ports to the list of available ports.

Oh right - I get you now.  That is less optimal.

>...So at
>first there's, say, "COM1 COM2 LPT1". After calling initialize()
>"manually" for the first time (i.e. for the second time in total), there's
>"COM1 COM2 LPT1 COM1 COM2 LPT1". And so on, so after n calls to
>initialize, each port is listed n+1 times.

..mmm.  That suggestion of mine just does not sound 'right'
anymore.  I better bow out of this thread and hope one of the
'Java comm' experts can identify the best strategy.

Signature

Andrew Thompson
http://www.physci.org/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.