Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions silabs-pti/.classpath
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<classpathentry kind="src" output="bin/main"
path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
<attribute name="gradle_scope" value="main" />
<attribute name="gradle_used_by_scope" value="main,test" />
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<classpathentry kind="src" output="bin/main"
path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
<attribute name="gradle_scope" value="main" />
<attribute name="gradle_used_by_scope" value="main,test" />
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/java">
<classpathentry kind="src" output="bin/test"
path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
<attribute name="test" value="true" />
<attribute name="gradle_scope" value="test" />
<attribute name="gradle_used_by_scope" value="test" />
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<classpathentry kind="src" output="bin/test"
path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
<attribute name="test" value="true" />
<attribute name="gradle_scope" value="test" />
<attribute name="gradle_used_by_scope" value="test" />
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry combineaccessrules="false" kind="src" path="/pcap"/>
<classpathentry kind="output" path="bin/default"/>
<classpathentry combineaccessrules="false" kind="src"
path="/pcap" />
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true" />
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.buildship.core.gradleclasspathcontainer" />
<classpathentry kind="output" path="bin/default" />
</classpath>
11 changes: 11 additions & 0 deletions silabs-pti/.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1703680810725</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
2 changes: 1 addition & 1 deletion silabs-pti/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
Expand Down
2 changes: 1 addition & 1 deletion silabs-pti/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.1
1.12.2
26 changes: 21 additions & 5 deletions silabs-pti/src/main/java/com/silabs/pti/Interactive.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -40,6 +41,7 @@
import com.silabs.pti.adapter.IFramer;
import com.silabs.pti.adapter.TimeSynchronizer;
import com.silabs.pti.debugchannel.DebugMessageConnectionListener;
import com.silabs.pti.debugchannel.EventType;
import com.silabs.pti.debugchannel.TextConnectionListener;
import com.silabs.pti.filter.CliDebugMessageFilter;
import com.silabs.pti.format.FileFormat;
Expand Down Expand Up @@ -177,7 +179,7 @@ public boolean quit() {
public void version() {
try {
System.out.println(CommandLine.getVersionString());
} catch (Exception e) {
} catch (final Exception e) {
System.out.println(e.getMessage());
}
}
Expand All @@ -193,9 +195,9 @@ public void filter(final String... args) {
System.out.println("Valid expressions:\n" + CliDebugMessageFilter.helpText());
} else {
try {
CliDebugMessageFilter cf = new CliDebugMessageFilter(args[0]);
final CliDebugMessageFilter cf = new CliDebugMessageFilter(args[0]);
this.filter = cf;
} catch (ParseException pe) {
} catch (final ParseException pe) {
System.out.println("Filter expression error: " + pe.getMessage());
}
}
Expand All @@ -208,7 +210,7 @@ public void andFilter(final String... args) {
} else {
try {
this.filter.andFilter(args[0]);
} catch (ParseException pe) {
} catch (final ParseException pe) {
System.out.println("Filter expression error: " + pe.getMessage());
}
}
Expand All @@ -221,7 +223,7 @@ public void orFilter(final String... args) {
} else {
try {
this.filter.orFilter(args[0]);
} catch (ParseException pe) {
} catch (final ParseException pe) {
System.out.println("Filter expression error: " + pe.getMessage());
}
}
Expand Down Expand Up @@ -500,4 +502,18 @@ public void format(final String... s) {
System.out.println("Current format: " + formatType.name());
}

@Cli(help = "Print all event type")
public void eventTypes(final String... s) {
EventType[] types = EventType.getAllTypes();
Arrays.sort(types, 0, types.length, new Comparator<EventType>() {
@Override
public int compare(EventType o1, EventType o2) {
return o1.value() - o2.value();
}
});
for (EventType e : types) {
System.out.println("0x" + Integer.toHexString(e.value()) + " / " + e.value() + ": '" + e.name() + "', "
+ e.description());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ public BufferedNioConnection(final String host, final int port, final IConnectiv
super(host, port, logger);
}

@SuppressWarnings("resource")
@Override
public void connect() throws IOException {
if (isConnected())
return;
InetSocketAddress address = new InetSocketAddress(host, port);
final InetSocketAddress address = new InetSocketAddress(host, port);
if (connectionEnabler != null)
connectionEnabler.prepareConnection(host + ":" + port);
channel = SocketChannel.open(address);
Expand All @@ -58,30 +57,30 @@ public void connect() throws IOException {
@Override
public void run() {
logInfo("Reading thread start.");
ByteBuffer buffer = ByteBuffer.allocate(100000);
final ByteBuffer buffer = ByteBuffer.allocate(100000);
readLoop: while (true) {
try {
int ret = selector.select();
final int ret = selector.select();
if (ret > 0) {
if (selector.selectedKeys().contains(readKey)) {
// We can read:
buffer.rewind();
int readCount = channel.read(buffer);
long readTime = System.currentTimeMillis();
final int readCount = channel.read(buffer);
final long readTime = System.currentTimeMillis();
if (readCount == -1) {
// End of stream
break readLoop;
} else if (readCount > 0) {
byte[] data = new byte[readCount];
final byte[] data = new byte[readCount];
buffer.rewind();
buffer.get(data);
processIncomingData(readTime, readCount, data);
}
}
}
} catch (ClosedSelectorException cse) {
} catch (final ClosedSelectorException cse) {
break readLoop;
} catch (IOException ioe) {
} catch (final IOException ioe) {
reportProblem("Error reading data", ioe);
logError("Reading thread error.", ioe);
}
Expand All @@ -103,7 +102,7 @@ public void close() {
logInfo("Disconnect.");
channel.close();
selector.close();
} catch (IOException ioe) {
} catch (final IOException ioe) {
reportProblem("Close socket.", ioe);
logError("Disconnect error.", ioe);
}
Expand All @@ -118,7 +117,7 @@ public void send(final byte[] message) throws IOException {
logError("Attempting to write, but socket is not connected.", null);
return;
}
byte[] outgoing = (frameOutgoing ? outgoingFramer.frame(message) : message);
final byte[] outgoing = (frameOutgoing ? outgoingFramer.frame(message) : message);

logInfo("Write " + outgoing.length + " bytes.");
channel.write(ByteBuffer.wrap(outgoing));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,28 @@
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;

/**
* Various classes for apache mina connectivity.
*
* @author Jing
*/
public class PtiCodecFactory extends DemuxingProtocolCodecFactory {

private ProtocolDecoder decoder;
private ProtocolEncoder encoder;
private final ProtocolDecoder decoder;
private final ProtocolEncoder encoder;

public PtiCodecFactory(Charset charset) {
public PtiCodecFactory(final Charset charset) {
decoder = new PtiProtocolDecoder();
encoder = new PtiProtocolEncoder(charset);
}

@Override
public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception {
public ProtocolEncoder getEncoder(final IoSession ioSession) throws Exception {
return encoder;
}

@Override
public ProtocolDecoder getDecoder(IoSession ioSession) throws Exception {
public ProtocolDecoder getDecoder(final IoSession ioSession) throws Exception {
return decoder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
import org.apache.mina.filter.codec.demux.MessageDecoderAdapter;
import org.apache.mina.filter.codec.demux.MessageDecoderResult;

/**
* Various classes for apache mina connectivity.
*
* @author Jing
*/
public class PtiMessageDecoder extends MessageDecoderAdapter {

@Override
public MessageDecoderResult decodable(IoSession session, IoBuffer in) {
public MessageDecoderResult decodable(final IoSession session, final IoBuffer in) {
return MessageDecoderResult.OK;
}

@Override
public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
byte[] array = new byte[in.remaining()];
public MessageDecoderResult
decode(final IoSession session, final IoBuffer in, final ProtocolDecoderOutput out) throws Exception {
final byte[] array = new byte[in.remaining()];
in.get(array);
out.write(array);
return MessageDecoderResult.OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;

/**
* Various classes for apache mina connectivity.
*
* @author Jing
*/
public class PtiProtocolDecoder extends ProtocolDecoderAdapter {
@Override
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
byte[] array = new byte[in.remaining()];
public void decode(final IoSession session, final IoBuffer in, final ProtocolDecoderOutput out) throws Exception {
final byte[] array = new byte[in.remaining()];
in.get(array);
out.write(array);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@
import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;

/**
* Various classes for apache mina connectivity.
*
* @author Jing
*/
public class PtiProtocolEncoder extends ProtocolEncoderAdapter {
private final Charset charset;

public PtiProtocolEncoder(Charset charset) {
public PtiProtocolEncoder(final Charset charset) {
this.charset = charset;
}

@Override
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
CharsetEncoder encoder = charset.newEncoder();
String value = message == null ? "" : message.toString();
IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception {
final CharsetEncoder encoder = charset.newEncoder();
final String value = message == null ? "" : message.toString();
final IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
buf.putString(value, encoder);
buf.flip();
out.write(buf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/


// !!!! This file is generated via 'gradle createDebugMessageTypes' command. Please do not edit manually!!!!!

// !!!! This file is generated via 'gradle createDebugMessageTypes' command. Please do not edit manually!!!!!

package com.silabs.pti.debugchannel;

Expand Down Expand Up @@ -142,10 +140,14 @@ public static DebugMessageType get(final int value) {
}
}
return DebugMessageType.INVALID;
}
}

public static int featureLevel() { return 22; }
public static int featureLevel() {
return 22;
}

public static String featureDate() { return "2022.1.8"; }
public static String featureDate() {
return "2022.1.8";
}

}
Loading