Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javax.comm

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi,

I'm using an application that uses the javax.comm package, I want to
make a communication with my internal modem(in COM4) with the AT commands.

this is what do the application:

1-open the COM4.
2-get the input and the output.
3-send the message "AT"
4-receive from the modem

with the AT command, when I type "AT" to the modem, it should response
"OK" .
but with my application The response that I receive is "AT", it seem
that when I send a command I receive the echo.

strange the same thing, when I send "ati7" , I receive "ati7".

here is the source:


import java.io.*;
import java.util.*;
import javax.comm.*;

public class ModemCommunication {

static CommPortIdentifier portNumber;
static String messageString = "at\n";
static SerialPort serialPort;
static OutputStream outputStream;
static InputStream inputStream;


public static void main(String[] args) {

try {

portNumber = CommPortIdentifier.getPortIdentifier("COM4");
serialPort = (SerialPort)portNumber.open("MyApp", 3500);


serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);

outputStream = serialPort.getOutputStream();

outputStream.write(messageString.getBytes());


inputStream = serialPort.getInputStream();


while (inputStream.available() > 0) {
int numBytes = inputStream.read();
System.out.print((char)numBytes);


}

} catch (Exception e) {System.out.println(e.toString());}




}
}
 
hi,

now help, till now , please is there a java programmer for help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top