Input Stream 0 when opening the serial port with different baud rates.
posted 7 years ago
I have two serial devices with different baud rates. One is the end device with baud rate 9600 and the other is the coordinator with baud rate 38400. My application is supposed to detect the connected device by sending a command.
1. I open the port with 9600 baud rate, send a command and wait for reply. If I get a reply I detect the end device.
2. If I don't get a reply I close the port and open it with 38400 baud rate, send a command and wait for a reply.
My problem is that when I open the port with one baud rate(9600), close it and then open with other baud rate(38400) my input stream is 0 even when the device is connected to the port.
AM I doing anything wrong here. I am using a RXTX library for serial communication. I tried flushing the output stream but it gives a nativeDrain Exception.