mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
[206884] Update Terminal Ownership ID to "org.eclipse.tm.terminal.serial"
This commit is contained in:
parent
dc038f7d6c
commit
493f9cc6fc
1 changed files with 25 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2003, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,10 +11,11 @@
|
||||||
* Helmut Haigermoser and Ted Williams.
|
* Helmut Haigermoser and Ted Williams.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - extracted from TerminalControl
|
* Michael Scharf (Wind River) - extracted from TerminalControl
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
* Martin Oberhuber (Wind River) - [207158] improve error message when port not available
|
* Martin Oberhuber (Wind River) - [207158] improve error message when port not available
|
||||||
* Martin Oberhuber (Wind River) - [208029] COM port not released after quick disconnect/reconnect
|
* Martin Oberhuber (Wind River) - [208029] COM port not released after quick disconnect/reconnect
|
||||||
|
* Martin Oberhuber (Wind River) - [206884] Update Terminal Ownership ID to "org.eclipse.tm.terminal.serial"
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.serial;
|
package org.eclipse.tm.internal.terminal.serial;
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ public class SerialConnectWorker extends Thread {
|
||||||
fControl = control;
|
fControl = control;
|
||||||
fConn = conn;
|
fConn = conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the named port to the name of known ports to rxtx
|
* Adds the named port to the name of known ports to rxtx
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -65,7 +66,7 @@ public class SerialConnectWorker extends Thread {
|
||||||
boolean sepNeeded=false;
|
boolean sepNeeded=false;
|
||||||
// When we add a port to this property, rxtx forgets the
|
// When we add a port to this property, rxtx forgets the
|
||||||
// ports it finds by scanning the system.
|
// ports it finds by scanning the system.
|
||||||
|
|
||||||
// iterate over the known ports and add them to the property
|
// iterate over the known ports and add them to the property
|
||||||
Enumeration portIdEnum= CommPortIdentifier.getPortIdentifiers();
|
Enumeration portIdEnum= CommPortIdentifier.getPortIdentifiers();
|
||||||
while (portIdEnum.hasMoreElements()) {
|
while (portIdEnum.hasMoreElements()) {
|
||||||
|
@ -95,13 +96,25 @@ public class SerialConnectWorker extends Thread {
|
||||||
// Reinitialize the ports because we have changed the list of known ports
|
// Reinitialize the ports because we have changed the list of known ports
|
||||||
CommPortIdentifier.getPortIdentifiers();
|
CommPortIdentifier.getPortIdentifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the ID that this connector uses for RXTX Comm Ownership Handling.
|
||||||
|
*
|
||||||
|
* Note that this was changed in Terminal 2.0 as per
|
||||||
|
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=206884 - previous versions
|
||||||
|
* of the serial terminal connector used a different string,
|
||||||
|
* "org.eclipse.tm.internal.terminal.serial".
|
||||||
|
*
|
||||||
|
* @since org.eclipse.tm.terminal.serial 2.0
|
||||||
|
* @return ownership ID, "org.eclipse.tm.terminal.serial"
|
||||||
|
*/
|
||||||
|
public static final String getOwnershipId() {
|
||||||
|
return "org.eclipse.tm.terminal.serial"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
String portName=null;
|
String portName=null;
|
||||||
//Ownership identifier:
|
final String strID = getOwnershipId();
|
||||||
//TODO [206884] This is part of API and should be changed for the next release
|
|
||||||
final String strID = getClass().getPackage().getName();
|
|
||||||
//final String strID = "org.eclipse.tm.terminal.serial"; //$NON-NLS-1$
|
|
||||||
SerialPort serialPort = null;
|
SerialPort serialPort = null;
|
||||||
try {
|
try {
|
||||||
fControl.setState(TerminalState.OPENED);
|
fControl.setState(TerminalState.OPENED);
|
||||||
|
@ -110,7 +123,7 @@ public class SerialConnectWorker extends Thread {
|
||||||
try {
|
try {
|
||||||
fConn.setSerialPortIdentifier(CommPortIdentifier.getPortIdentifier(portName));
|
fConn.setSerialPortIdentifier(CommPortIdentifier.getPortIdentifier(portName));
|
||||||
} catch (NoSuchPortException e) {
|
} catch (NoSuchPortException e) {
|
||||||
// let's try
|
// let's try
|
||||||
addPort(portName);
|
addPort(portName);
|
||||||
fConn.setSerialPortIdentifier(CommPortIdentifier.getPortIdentifier(portName));
|
fConn.setSerialPortIdentifier(CommPortIdentifier.getPortIdentifier(portName));
|
||||||
}
|
}
|
||||||
|
@ -139,11 +152,11 @@ public class SerialConnectWorker extends Thread {
|
||||||
if(msg==null)
|
if(msg==null)
|
||||||
msg=portName;
|
msg=portName;
|
||||||
fControl.displayTextInTerminal("No such port: \"" + msg+"\"\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
fControl.displayTextInTerminal("No such port: \"" + msg+"\"\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Logger.logException(exception);
|
Logger.logException(exception);
|
||||||
if (serialPort!=null) {
|
if (serialPort!=null) {
|
||||||
//Event listener is removed as part of close(),
|
//Event listener is removed as part of close(),
|
||||||
//but exceptions need to be caught to ensure that close() really succeeds
|
//but exceptions need to be caught to ensure that close() really succeeds
|
||||||
try {
|
try {
|
||||||
serialPort.removeEventListener();
|
serialPort.removeEventListener();
|
||||||
|
|
Loading…
Add table
Reference in a new issue