Check if Serial port is connected
in
Core Library Questions
•
2 years ago
I have an application that usess multiple serial ports. When I run my application it automaticaly connects to all serial ports that are read from file (well their names are). I simply store the opened ports into an array and that is it. If all ports are connected everything is good. But when I try to send something to a port that is not connected I get NullPointerException. I tryed catching the exception, checking if serial port is null but nothing works. Is there any way to check if the port is actualy working before I try sending something and getting an exception that I can't catch?
1