This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Can anybody tell my how can I send command to Modem using java? I am developing a desktop application using JDK 5, I know there a COMM api I can download from SUN, but I can do it with that API? how? Please ideas...
Originally posted by Carlos Rincon: I can do it with that API?
On a UNIX system, you could probably open the appropriate /dev/ttyS* file and read and write to it using ordinary FileInputStream/FileOutputStream classes. Wait, let me go try that... yes, it seems to work. That might work on Mac OS X, too.
On Windows, it's possible that you could open a file named "COM1" and write to it, and that would send a command to the first serial port... but it's also possible that it won't. You'd have to give it a try.
With the COMM API you can control a serial port - you get control over the signal pins that control the link as well as the ability to set the speed and send/receive data. The COMM API is a very mature package and has not changed in years. You should start by downloading the COMM package and getting the included examples working. The most common problem people have with this package is just getting the java.comm.properties file in the right directory. This file simply tells the package which driver to use - why the designers could not figure out a way to do this automatically, I'll never be able to understand. Bill
Joined: Mar 28, 2005
Thanks a lot for the replies, I have other question, the COMM api can write in serial and pararell port, I know modem is asocciate to a serial port, but not a physical serial port, but logical, so I don't sure it work...