Question

Hoping to find solution here.

I have a controller which uses a App specific protocol over UART and this protocol works only at 14400 bps.

I have to use java code to communicate with this controller over serial port.

But i fount the API's i am using doesn't support 14400 baud rate although they call it standard!!.

I tried using javax.comm and rxtx jar's. No real hel as both of them doesn't support this baud rate.

Can any one please help me in this regard, It will be really Helpful.

Thanks!

Ok Here is the code snippet

        selectedPort = (SerialPort) portID.open("FlashProgramming",
                TIMEOUT);
        System.out.println("port " + selectedPort + " is opened");



    try {

        selectedPort.setSerialPortParams(14400,
                SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
                SerialPort.PARITY_NONE);

//Here trying to set the Baud rate to 14400, but it is rolling back to 9600, the default as 14400 is not supported!!

    }


    // no handshaking or other flow control
    try {
        selectedPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
    } catch (UnsupportedCommOperationException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    // timer on any read of the serial port
    try {
        selectedPort.enableReceiveTimeout(TIMEOUT);
    } catch (UnsupportedCommOperationException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    System.out.println("Comport Configeration is done");

    try {

        Serialdriver.in = selectedPort.getInputStream();
        Serialdriver.out = selectedPort.getOutputStream();

        System.out.println("i/p & o/p's are initialized");

        Serialdriver.handlerParamselScreen.displaystatus("Seleted Com port "
                + selectedPort + " is Successfully opened");
    }



        selectedPort.addEventListener(Serialdriver);



    selectedPort.notifyOnDataAvailable(true);


    return selectedPort;

}
Was it helpful?

Solution

Well Here is the solution,

I replaced the low level dll's from javax.comm to rxtx.

Here is the link - rxtx latest driveres

And the best part is it supports both x32 and x64 jre's!. And porting the code from javax.comm to rxtx is just 5 min job.

I hope it is helpfull.

Cheers!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top