# HG changeset patch # User dadubrow # Date 1262883837 21600 # Node ID a0609ea7401a09525ed1e27a7a4655eb1c7539df # Parent ec2a80c491358469a0f718486da0425029c1418d add sys trk checking for usb only and use with reconciler diff -r ec2a80c49135 -r a0609ea7401a debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/messages.properties --- a/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/messages.properties Thu Jan 07 07:47:19 2010 -0600 +++ b/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/messages.properties Thu Jan 07 11:03:57 2010 -0600 @@ -7,6 +7,7 @@ ConnectionStatusReconciler_TracingServicePrefix=, Tracing service ConnectionStatusReconciler_TRKServicePrefix=TRK service ConnectionStatusReconciler_unavailableLabel=unavailable +TRKConnectedService.AppTRKName=Application TRK TRKConnectedService.DownLabel=Not Accessible TRKConnectedService.ErrorStatus=Error: TRKConnectedService.InUseLabel=In Use @@ -21,6 +22,7 @@ TRKConnectedService.BadVersionResponseError=TRK version response was corrupted TRKConnectedService.NoPingErrorNoVersionError=Attempt to get TRK version timed out TRKConnectedService.RunningLabel=Available +TRKConnectedService.SysTRKName=System TRK TRKConnectedService.UnknownLabel=Unknown TRKService.Label=TRK TRKService.ServiceInfo=Ensure TRK is running on the device diff -r ec2a80c49135 -r a0609ea7401a debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/service/TRKConnectedService.java --- a/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/service/TRKConnectedService.java Thu Jan 07 07:47:19 2010 -0600 +++ b/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/service/TRKConnectedService.java Thu Jan 07 11:03:57 2010 -0600 @@ -18,22 +18,35 @@ package com.nokia.carbide.trk.support.service; -import com.freescale.cdt.debug.cw.core.SerialConnectionSettings; -import com.nokia.carbide.remoteconnections.interfaces.*; -import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus; -import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller; -import com.nokia.carbide.trk.support.Messages; -import com.nokia.carbide.trk.support.connection.*; -import com.nokia.cpp.internal.api.utils.core.Check; -import com.nokia.cpp.internal.api.utils.core.Pair; -import com.nokia.tcf.api.*; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.osgi.framework.Version; -import java.io.IOException; -import java.text.MessageFormat; -import java.util.List; +import com.freescale.cdt.debug.cw.core.SerialConnectionSettings; +import com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService; +import com.nokia.carbide.remoteconnections.interfaces.AbstractSynchronizedConnection; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionType; +import com.nokia.carbide.remoteconnections.interfaces.IService; +import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus; +import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller; +import com.nokia.carbide.trk.support.Messages; +import com.nokia.carbide.trk.support.connection.SerialConnectionType; +import com.nokia.carbide.trk.support.connection.TCPIPConnectionFactory; +import com.nokia.carbide.trk.support.connection.TCPIPConnectionType; +import com.nokia.carbide.trk.support.connection.USBConnectionType; +import com.nokia.cpp.internal.api.utils.core.Check; +import com.nokia.cpp.internal.api.utils.core.Pair; +import com.nokia.tcf.api.ITCAPIConnection; +import com.nokia.tcf.api.ITCConnection; +import com.nokia.tcf.api.ITCMessage; +import com.nokia.tcf.api.ITCMessageIds; +import com.nokia.tcf.api.ITCMessageInputStream; +import com.nokia.tcf.api.ITCMessageOptions; +import com.nokia.tcf.api.TCFClassFactory; /** * @@ -69,8 +82,12 @@ private static final String TCPIP_IN_USE = Messages.getString("TRKConnectedService.TCPIPInUseStatus"); //$NON-NLS-1$ + private static final Version VERSIONS3_VERSION = new Version(3, 2, 4); private static final byte[] TRK_PING = {0x7e, 0x0, 0x0, (byte) 0xff, 0x7e}; private static final byte[] TRK_VERSION = {0x7e, 0x08, 0x01, (byte) 0xf6, 0x7e}; + private static final byte[] TRK_VERSIONS3 = {0x7e, 0x51, 0x02, (byte) 0xac, 0x7e}; + private static final byte[] SYS_TRK_RESPONSE = + {0x7e, (byte) 0x80, 0x02, 0x00, 0x03, 0x02, 0x03, 0x06, 0x04, 0x00, 0x0a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x54, 0x52, 0x4b, (byte) 0xcb, 0x7e}; private Pair deviceOS; private TRKService trkService; @@ -147,6 +164,9 @@ ITCMessage tcMsgVersion = TCFClassFactory.createITCMessage(TRK_VERSION); tcMsgVersion.setUseMyMessageId(true, trkRequestId); + ITCMessage tcMsgVersions3 = TCFClassFactory.createITCMessage(TRK_VERSIONS3); + tcMsgVersions3.setUseMyMessageId(true, trkRequestId); + // connect ITCAPIConnection api = TCFClassFactory.createITCAPIConnection(); org.eclipse.core.runtime.IStatus connStatus = api.connect(conn, options, ids); @@ -176,6 +196,19 @@ // printMessage(message); if (message != null && message.length == 11) { version = new Version(message[4], message[5], message[8]); + if (version.compareTo(VERSIONS3_VERSION) >= 0) { + // send trk versions3 + sendStatus = api.sendMessage(tcMsgVersions3); + + waitForSingleTCMessage(stream); + if (stream.peekMessages() > 0) { + tcMessage = stream.readMessage(); // version response + message = tcMessage.getMessage(); +// printMessage(message); + boolean isSysTrk = Arrays.equals(message, SYS_TRK_RESPONSE); + getProperties().put(PROP_SYS_TRK, Boolean.valueOf(isSysTrk).toString()); + } + } } else throw new ConnectionFailException(Messages.getString("TRKConnectedService.BadVersionResponseError")); //$NON-NLS-1$ @@ -201,18 +234,18 @@ } // private void printMessage(byte[] message) { -// for (int i = 0; i < message.length; i++) { -// String hexString = Integer.toHexString(message[i]); -// if (hexString.length() == 1) -// hexString = "0" + hexString; -// else if (hexString.length() > 2) -// hexString = hexString.substring(hexString.length() - 2); -// System.out.print(hexString); -// if (i + 1 < message.length) -// System.out.print('-'); +// for (int i = 0; i < message.length; i++) { +// String hexString = Integer.toHexString(message[i]); +// if (hexString.length() == 1) +// hexString = "0" + hexString; +// else if (hexString.length() > 2) +// hexString = hexString.substring(hexString.length() - 2); +// System.out.print(hexString); +// if (i + 1 < message.length) +// System.out.print('-'); +// } +// System.out.println(); // } -// System.out.println(); -//} private void waitForSingleTCMessage(ITCMessageInputStream stream) throws IOException { int timeout = TIMEOUT; @@ -285,10 +318,17 @@ estatus = EStatus.UP; Version serverVersion = getLatestVersionFromServer(); if (serverVersion == null) { - message = MessageFormat.format(OK_STATUS, deviceVersion); + StringBuilder trkVersionString = new StringBuilder(); + String sysTrkProp = getProperties().get(PROP_SYS_TRK); + if (sysTrkProp != null) + trkVersionString.append(Boolean.parseBoolean(sysTrkProp) ? + Messages.getString("TRKConnectedService.SysTRKName") : //$NON-NLS-1$ + Messages.getString("TRKConnectedService.AppTRKName")); //$NON-NLS-1$ + trkVersionString.append(deviceVersion.toString()); + message = MessageFormat.format(OK_STATUS, trkVersionString); } else if (deviceVersion.compareTo(serverVersion) >= 0) { - message = MessageFormat.format(IS_LASTEST, deviceVersion); + message = MessageFormat.format(IS_LASTEST, deviceVersion.toString()); } else { message = MessageFormat.format(NEEDS_INSTALL, @@ -310,7 +350,7 @@ return new TestResult(estatus, getShortDescription(estatus), message); } - + public void setDeviceOS(String familyName, Version version) { deviceOS = new Pair(familyName, version); } diff -r ec2a80c49135 -r a0609ea7401a debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java --- a/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java Thu Jan 07 07:47:19 2010 -0600 +++ b/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java Thu Jan 07 11:03:57 2010 -0600 @@ -92,19 +92,17 @@ } } - private boolean handlesConnection(IConnection connection) { - // only manage status for USBConnectionTypes for now - // in future other IConnection2 types may also be managed - return connection.getConnectionType() instanceof USBConnectionType; + private boolean isDynamic(IConnection connection) { + return connection instanceof IConnection2 && ((IConnection2) connection).isDynamic(); } private boolean isSysTRK(TRKConnectedService service) { String value = service.getProperties().get(TRKConnectedService.PROP_SYS_TRK); - return value != null && Boolean.getBoolean(value); + return Boolean.parseBoolean(value); } private void addConnection(IConnection connection) { - if (!handlesConnection(connection)) + if (!isDynamic(connection)) return; handledConnections.add((IConnection2) connection);