For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2005 > javax.comm: how to get the name of a device at the serial port?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author javax.comm: how to get the name of a device at the serial port?
Sarah Klage

2005-02-26, 8:58 am

Hello,

is there a possibility to get the name of a device connected to a particular
COM port (serial port) or another unique id? I checked the javax.comm
package (and its docs) but found no informations about that.

And: Is there a possibility to check in short intervalls if the device is
still connected to the com port?

kind regards
Sarah



Chris Smith

2005-02-26, 3:59 pm

Sarah Klage <sarah@wlankosten.de> wrote:
> is there a possibility to get the name of a device connected to a particular
> COM port (serial port) or another unique id? I checked the javax.comm
> package (and its docs) but found no informations about that.


> And: Is there a possibility to check in short intervalls if the device is
> still connected to the com port?


Neither of these is even theoretically possible. Without knowing some
about the higher-level protocol spoken by the device, there is no
provision in RS232 for a device to provide its name or to signal its
presence.

If you do know something about a higher-level protocol and it allows you
to ask for a device name or detect presence of a device (for example
with some kind of ping), then you need implement those functions
yourself, in whatever way that protocol provides.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Knute Johnson

2005-02-26, 8:58 pm

Sarah Klage wrote:
> Hello,
>
> is there a possibility to get the name of a device connected to a particular
> COM port (serial port) or another unique id? I checked the javax.comm
> package (and its docs) but found no informations about that.
>
> And: Is there a possibility to check in short intervalls if the device is
> still connected to the com port?
>
> kind regards
> Sarah
>


You need to look into serial data communication and RS232 in particular.
There are two lines on the serial port to tell you that a device is
attached, DTR and DSR.

--

Knute Johnson
email s/nospam/knute/
dar7yl

2005-02-27, 3:59 am

"Sarah Klage" <sarah@wlankosten.de> wrote in message
news:422044f9@x-privat.org...
>
> is there a possibility to get the name of a device connected to a
> particular
> COM port (serial port) or another unique id? I checked the javax.comm
> package (and its docs) but found no informations about that.


The serial port doesn't have any information about a device
attached to it. However, if you suspect that the device is
a Hayes-compatable modem, you can interrogate it by
sending an information request command "ATI<num>\r"
where <num> is any number from 0 to 999, but usually
limits out at about 7. Different modems return various
response strings that you can parse to extract useful information.

Otherwise, anything may be attached to the serial port, and
you would have to know what sort of protocol it talks in order
to recognize it.

> And: Is there a possibility to check in short intervalls if the device is
> still connected to the com port?


Usually, a device raises the DTR-DSR line when it connects, which
you can test using javax.comm.CommPort.isDSR().

regards,
Dar7yl


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com