GeeCON Prague 2014*
The moose likes I/O and Streams and the fly likes Read Com port Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Read Com port" Watch "Read Com port" New topic
Author

Read Com port

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Hi friends, I just want to know is it possible to read data from com port in java ,with out using wrapper class?

TIA.
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 1055
    
  51

Not sure exactly what you mean by "wrapper class" but RS-232 serial communication is available through some extension libraries such as the Java Communucations API


Tim Driven Development
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
I don't know what you mean by "wrapper class", but check out the libraries listed in the http://www.coderanch.com/how-to/java/JavaIoFaq in the section titled "Where can I get an implementation ...".


Ping & DNS - my free Android networking tools app
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
here wrapper class i mean is, without using any c or c# i.e., JNI in java code. I tried using javax.comm for reading serial port,



is always returning "False". But COM3 port is open and its connecting to weigh scale and data is keep polling in that port. I have no idea, whether some prerequesite is required or anything is wrong in the code.
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 1055
    
  51

Probably not going to be much help here as I'm just Googling around a bit, which I assume you have done plenty of before coming here for help anyway.

Only snip I could find was that one person encountered this problem where they were getting an empty Enumeration because they were using javax.comm API v3 on a Windows environment which is not supported. They resolved their issue by using v2 instead.

Like I said, I'm just Googling for you.
Ron McLeod
Ranch Hand

Joined: Feb 12, 2013
Posts: 322
    
    5

I've used RXTXcomm with JavaSE on Windows 7 to communicate with an application running on an Adruino over a serial link.

This is the code I used to locate the comm ports:
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Thanks for the reply Tim Cooke. I'm using comm-win32_all-2.0.1 version 2 only. but still could not able to connect.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42042
    
  64
Saying "not able to" gives us nothing to comment on in order to help you: http://www.coderanch.com/how-to/java/ItDoesntWorkIsUseless
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159

I'm using version 2 jar file of comm.jar still it is returning "False" for the code,
.
But COM3 port is open and its connecting to weigh scale and data is keep polling in that port.
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 1055
    
  51

What is connecting? What is polling? You say your application is not working but then you say you're receiving data on the port? This makes no sense at all.

Assuming that you have some other application connecting to your Scale then perhaps it is because that thing is hogging the Comm Port that your Java application is unable to get a handle to it. This is just a wild guess on my part.

Like Ulf says, your question is quite vague and you're not giving us much to go an at all. If you want to get more focussed assistance then you need to provide a more focussed question.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

It's been nearly a decade since I used that software, back in the days when computers still came with COM ports installed by default. I vaguely remember that if your code couldn't find any comm ports, that was because it wasn't installed correctly. The installation process was very strange, with different components being loaded into different directories, and it was easy to get it wrong. So go back and review the installation instructions and make sure you followed them exactly.
Ron McLeod
Ranch Hand

Joined: Feb 12, 2013
Posts: 322
    
    5

Since the scale is connected to a Windows platform, you can easily use the Device Manager to check if the COM port is registered by the operating system, then use a terminal application (such as PuTTY) to make a connection.



[commport.png]

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Thanks for all response. When my application doesn't able to connect to the comm port, I used the hyperterminal(set by vendor to check data) to check whether data is being polled to com port.
Issue got solved by adding dll and steps followed in this website,http://edn.embarcadero.com/article/31915. Thanks for all, for your wonderful support and time.
Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 1055
    
  51

Ah ha. Paul wins. Installation problem.

Glad you got it sorted and kudos for posting back and letting us know how you resolved it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read Com port