Hiii all
I am using java 1.6 and RXTXComm package (Javax.comm) package.
I can read data from a electronic weighing machine. Now I have to set the weight as zero. I can tare this weight by sending T command to serial port. I had tried several times but no response from device. Somebody please help me.

this is my code snippet

public class WriteToSerialPort {
    CommPortIdentifier pid;
    SerialPort serial;
    java.io.OutputStream outstream;
    public void writeToPort() throws Exception
    {
        CommPortIdentifier pid=CommPortIdentifier.getPortIdentifier("COM1");
        serial=(SerialPort)pid.open("test app",1000);
        serial.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
        serial.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
        outstream=serial.getOutputStream();
        char tare=(char)84;
        outstream.write(tare);

    }

    public static void main(String args[])throws Exception
    {
        WriteToSerialPort ob=new WriteToSerialPort();
        ob.writeToPort();
    }
}

thanks in advance

Hi,
I think you should flush the outputstream after you have written data to it.

outstream.flush();

Hello azibhai4u
I am using java 1.6 and RXTXComm package (Javax.comm) package.
HOW can I read data from a electronic weighing machine?
Please help give source code................

hey, Javax.comm package isn't supported for windows :(
how can I get this? how can I program my serial port - a very simple code just to open a port and see its working?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.