Some sort of encoding or formatting problem on outputstream

Hey. Sorry for the long post =)

I'm trying to send commands through the comport via a java program i have written. The problem is, that the command arrives just fine at it's destination, but there's something akward about the command sent from the java program.

If i send the exact same command from c++, hyperterminal, DCON or any other program than java, the command arrives and works. But if i send the command with my java program, the command will arrive, but it doesn't look exactly the same as the other ones, sent from other programs.

I just tried connecting my computer to another computer, so i could recieve the commands on the other computer, and get a visual confirmation on how the command looks. I used Hyperterminal to view the commands.

If i send the command several times from a c++ program, each new command overwrites the next, so at all times i can only see one command on the screen.

And then, if i send the command several times from my java program, each command will not overwrite the previous, and i can see as many commands on the screen as i have sent.

I took 2 screenshots. One screenshot to see how the command looks from a c++ program, and the other picture to see how the command looks when sent from the java program:

The command seen on the other computer, when sent from a c++ program: [url=http://www.humor.fo/c.jpg][/url]

As you can see, when the command is sent from the c++ program, the blinking underscore which indicates where on the document you are, is located under the first letter of the command. And as sayd previously, each new command will replace the previous.

The command seen on the other computer, when sent from the java program: http://www.humor.fo/java.jpg

When the command is sent from the java program, the underscore will appear right after the last letter of the command, and each new command is placed next to the previous, and no command is replaced with a new one.

The commands from the java program can't be used, because i want to send these commands to a Nudam module. The Nudam module can understand every command except the commands from the java program. And it has to be done in java =)

Here's the code:

import java.io.*;

import java.util.*;

import javax.comm.*;

import java.lang.*;

import java.awt.*;

import java.applet.*;

import java.awt.event.*;

//Class SerialTransmit is able to transmit a string

publicclass 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 message to the serial connection */

publicvoid Transmit()

{

//Get the stream

try{outputStream=connection.serialPort.getOutputStream();

outputStream.close();

}catch (IOException e){}

//Send the stream

try{

outputStream.write(messageString.getBytes());

}catch (IOException e){

System.out.println("Error by writing to the serial port");}

}

}

Does any one know a solution to this?

[4616 byte] By [Runiloa] at [2007-11-27 6:08:01]
# 1
How does the C++ program sent the data? Should the data be terminated with a certain character?Kaj
kajbja at 2007-7-12 17:09:49 > top of Java-index,Java Essentials,Java Programming...
# 2
I would guess that the C++ is appending a \r.
ejpa at 2007-7-12 17:09:49 > top of Java-index,Java Essentials,Java Programming...