Problem sending string through serial port
Hey all
I am currently trying to develop a java program which is able to send commands through the serial port to a Nudam 6021 module.
Everything works fine, except that the Nudam module does not understand the commands from the java program. I can see that the Nudam module recieves the command, but it just doesn't understand it. I have tried to investigate the problem and to me there seems to be a problem with my java code.
I have tried sending the command to the nudam module by using Hyperterminal, Borland c builder and a program called DCON. And every time i use something other than the java program, the Nudam module will understand the command. Or to put it another way, my java class is the only destination from where the nudam module is unable to understand the command.
I should also note that i have tried sending the command with hyperterminal to another computer which recieved the command with hyperterminal, and the command showed up on the other computer just fine.
I use BlueJ as my java editor, and i have the javax.comm package installed. i also have jdk.1.5.0_06 installed.
Here's the java code:
import java.io.*;
import java.util.*;
import javax.comm.*;
//Class SerialTransmit is able to transmit a string
public class SerialTransmit
{
private Connect connection;//An object of class Connect
private String messageString = "#0000.000";//"Serial transmit test.\r\n"; //String to send
private OutputStream outputStream;//Output string
public SerialTransmit()
{
}//End of constructor
/*Send the messageto the serial connection */
public void Transmit()
{
//Get the stream
try{outputStream=connection.serialPort.getOutputStream();
} catch (IOException e) {}
//Send the stream
try {
outputStream.write(messageString.getBytes());
} catch (IOException e) {
System.out.println("Error by writing to the serial port");}
}//End of Transmit
}
I am preatty new to java programming, but for some reason i suspect some sort of charset problem to be the reason for my program not working. I don't think that the command is sent out in the correct format.
Does anyone know a solution to this problem? I have tried for 2 days now to solve the problem, but i'm getting nowhere. Any help is much appreciated.

