[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:
@@ -36,6 +36,8 @@ import tuwien.auto.calimero.link.medium.TPSettings;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class SerialClient extends AbstractKNXClient {
|
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 Logger logger = LoggerFactory.getLogger(SerialClient.class);
|
||||||
|
|
||||||
private final String serialPort;
|
private final String serialPort;
|
||||||
@@ -69,7 +71,8 @@ public class SerialClient extends AbstractKNXClient {
|
|||||||
e);
|
e);
|
||||||
} catch (KNXException e) {
|
} catch (KNXException e) {
|
||||||
final String msg = e.getMessage();
|
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");
|
StringBuilder sb = new StringBuilder("Available ports are:\n");
|
||||||
Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
|
Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
|
||||||
while (portList.hasMoreElements()) {
|
while (portList.hasMoreElements()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user