[knx] FT12: List available serial ports if port cannot be opened (#12942)
Fixes a regression introduced by upgrading Calimero library to 2.5. Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
parent
b5489057b6
commit
822c27c181
|
@ -36,6 +36,8 @@ import tuwien.auto.calimero.link.medium.TPSettings;
|
|||
@NonNullByDefault
|
||||
public class SerialClient extends AbstractKNXClient {
|
||||
|
||||
private static final String CALIMERO_ERROR_CANNOT_OPEN_PORT = "failed to open serial port";
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SerialClient.class);
|
||||
|
||||
private final String serialPort;
|
||||
|
@ -69,7 +71,8 @@ public class SerialClient extends AbstractKNXClient {
|
|||
e);
|
||||
} catch (KNXException e) {
|
||||
final String msg = e.getMessage();
|
||||
if ((msg != null) && (msg.startsWith("can not open serial port"))) {
|
||||
// TODO add a test for this string match; error message might change in later version of Calimero library
|
||||
if ((msg != null) && (msg.startsWith(CALIMERO_ERROR_CANNOT_OPEN_PORT))) {
|
||||
StringBuilder sb = new StringBuilder("Available ports are:\n");
|
||||
Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
|
||||
while (portList.hasMoreElements()) {
|
||||
|
|
Loading…
Reference in New Issue