Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2008-04-07 19:56:45 +0000
committereutarass2008-04-07 19:56:45 +0000
commit3008d4750370013e6e9750ddb00039df362dbb5a (patch)
tree322ea479c63ff1e54b99994585184875914d1f67 /plugins/org.eclipse.tm.tcf
parent3c90f4ac3612c74dd8309c85c6a96c77d860156c (diff)
downloadorg.eclipse.tcf-3008d4750370013e6e9750ddb00039df362dbb5a.tar.gz
org.eclipse.tcf-3008d4750370013e6e9750ddb00039df362dbb5a.tar.xz
org.eclipse.tcf-3008d4750370013e6e9750ddb00039df362dbb5a.zip
Bug 223520: [tcf] Registers service changes: data formatting is removed from the service.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf')
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java66
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java37
2 files changed, 56 insertions, 47 deletions
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java
index c402ae02c..42424c063 100644
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java
+++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java
@@ -15,6 +15,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.tm.tcf.core.Base64;
import org.eclipse.tm.tcf.core.Command;
import org.eclipse.tm.tcf.protocol.IChannel;
import org.eclipse.tm.tcf.protocol.IToken;
@@ -36,10 +37,6 @@ public class RegistersProxy implements IRegisters {
this.props = props;
}
- public String[] getAvailableFormats() {
- return toStringArray(props.get(PROP_FORMATS));
- }
-
public int[] getBitNumbers() {
return toIntArray(props.get(PROP_BITS));
}
@@ -69,6 +66,12 @@ public class RegistersProxy implements IRegisters {
public String getParentID() {
return (String)props.get(PROP_PARENT_ID);
}
+
+ public int getSize() {
+ Number n = (Number)props.get(PROP_SIZE);
+ if (n == null) return 0;
+ return n.intValue();
+ }
public Map<String, Object> getProperties() {
return props;
@@ -128,25 +131,26 @@ public class RegistersProxy implements IRegisters {
return n.booleanValue();
}
- public IToken get(String format, final DoneGet done) {
+ public IToken get(final DoneGet done) {
return new Command(channel, RegistersProxy.this, "get",
- new Object[]{ getID(), format }) {
+ new Object[]{ getID() }) {
@Override
public void done(Exception error, Object[] args) {
- String val = null;
+ byte[] val = null;
if (error == null) {
assert args.length == 3;
error = toError(args[0], args[1]);
- val = (String)args[2];
+ String str = (String)args[2];
+ if (str != null) val = Base64.toByteArray(str.toCharArray());
}
done.doneGet(token, error, val);
}
}.token;
}
- public IToken set(String format, String value, final DoneSet done) {
+ public IToken set(byte[] value, final DoneSet done) {
return new Command(channel, RegistersProxy.this, "set",
- new Object[]{ getID(), format, value }) {
+ new Object[]{ getID(), Base64.toBase64(value, 0, value.length) }) {
@Override
public void done(Exception error, Object[] args) {
if (error == null) {
@@ -252,6 +256,33 @@ public class RegistersProxy implements IRegisters {
return arr;
}
+ private static class NamedValueInfo implements NamedValue {
+
+ private final String desc;
+ private final String name;
+ private final byte[] value;
+
+ NamedValueInfo(Map<String,Object> m) {
+ desc = (String)m.get("Description");
+ name = (String)m.get("Name");
+ String str = (String)m.get("Value");
+ if (str == null) value = null;
+ else value = Base64.toByteArray(str.toCharArray());
+ }
+
+ public String getDescription() {
+ return desc;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public byte[] getValue() {
+ return value;
+ }
+ }
+
@SuppressWarnings("unchecked")
private NamedValue[] toValuesArray(Object o) {
Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
@@ -259,20 +290,7 @@ public class RegistersProxy implements IRegisters {
int i = 0;
NamedValue[] arr = new NamedValue[c.size()];
for (final Map<String,Object> m : c) {
- arr[i++] = new NamedValue() {
-
- public String getDescription() {
- return (String)m.get("Description");
- }
-
- public String getName() {
- return (String)m.get("Name");
- }
-
- public Number getValue() {
- return (Number)m.get("Value");
- }
- };
+ arr[i++] = new NamedValueInfo(m);
}
return arr;
}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java
index 5bfed81c2..9fb1de145 100644
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java
+++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java
@@ -32,7 +32,7 @@ public interface IRegisters extends IService {
PROP_PROCESS_ID = "ProcessID",
PROP_NAME = "Name",
PROP_DESCRIPTION = "Description",
- PROP_FORMATS = "Formats",
+ PROP_SIZE = "Size",
PROP_READBLE = "Readable",
PROP_READ_ONCE = "ReadOnce",
PROP_WRITEABLE = "Writeable",
@@ -47,16 +47,6 @@ public interface IRegisters extends IService {
PROP_VALUES = "Values";
/**
- * Standard known formats for register data.
- */
- static final String
- FORMAT_BINARY = "Binary",
- FORMAT_OCTAL = "Octal",
- FORMAT_DECIMAL = "Decimal",
- FORMAT_HEX = "Hex",
- FORMAT_NATURAL = "Natural";
-
- /**
* Retrieve context info for given context ID.
*
* @param id context ID.
@@ -134,11 +124,14 @@ public interface IRegisters extends IService {
String getDescription();
/**
- * Get value formats available for register get/set commands.
- * See FORMAT_* for knows format IDs definition.
- * @return array of supported format IDs.
+ * Get context size in bytes.
+ * Byte arrays in get()/set() methods should be same size.
+ * Hardware register can be smaller then this size, for example in case
+ * when register size is not an even number of bytes. In such case implementation
+ * should add/remove padding that consist of necessary number of zero bits.
+ * @return context size in bytes.
*/
- String[] getAvailableFormats();
+ int getSize();
/**
* Check if context value can be read.
@@ -226,20 +219,18 @@ public interface IRegisters extends IService {
/**
* Read value of the context.
- * @param format - ID of a format to use for result value.
* @param done - call back object.
* @return - pending command handle.
*/
- IToken get(String format, DoneGet done);
+ IToken get(DoneGet done);
/**
* Set value of the context.
- * @param format - ID of a format used for value.
* @param value - value to write into the context.
* @param done - call back object.
* @return - pending command handle.
*/
- IToken set(String format, String value, DoneSet done);
+ IToken set(byte[] value, DoneSet done);
}
/**
@@ -248,10 +239,10 @@ public interface IRegisters extends IService {
*/
interface NamedValue {
/**
- * Get number associated with this named value.
- * @return the value as a number.
+ * Get value associated with the name.
+ * @return the value as an array of bytes.
*/
- Number getValue();
+ byte[] getValue();
/**
* Get name (mnemonic) of the value.
@@ -270,7 +261,7 @@ public interface IRegisters extends IService {
* 'get' command call back interface.
*/
interface DoneGet {
- void doneGet(IToken token, Exception error, String value);
+ void doneGet(IToken token, Exception error, byte[] value);
}
/**

Back to the top