本文整理汇总了Java中com.qualcomm.robotcore.util.TypeConversion类的典型用法代码示例。如果您正苦于以下问题:Java TypeConversion类的具体用法?Java TypeConversion怎么用?Java TypeConversion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeConversion类属于com.qualcomm.robotcore.util包,在下文中一共展示了TypeConversion类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: foundExpectedBytes
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
private boolean foundExpectedBytes(int[] byteArray, Lock lock, byte[] cache) {
try {
lock.lock();
boolean allMatch = true;
StringBuilder s = new StringBuilder(300 * 4);
String mismatch = "";
for (int i = 0; i < byteArray.length; i++) {
s.append(String.format("expected: %02x, got: %02x \n", TypeConversion.unsignedByteToInt( (byte) byteArray[i]), cache[i]));
if (TypeConversion.unsignedByteToInt(cache[i]) != TypeConversion.unsignedByteToInt( (byte) byteArray[i])) {
mismatch = String.format("i: %d, byteArray[i]: %02x, cache[i]: %02x", i, byteArray[i], cache[i]);
allMatch = false;
}
}
RobotLog.e(s.toString() + "\n allMatch: " + allMatch + ", mismatch: " + mismatch);
return allMatch;
} finally {
lock.unlock();
}
}
示例2: notFoundExpectedBytes
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
private boolean notFoundExpectedBytes(int[] byteArray, Lock lock, byte[] cache) {
try {
lock.lock();
boolean allMatch = true;
StringBuilder s = new StringBuilder(300 * 4);
String mismatch = "";
for (int i = 0; i < byteArray.length; i++) {
s.append(String.format("expected: %02x, got: %02x \n", TypeConversion.unsignedByteToInt((byte) byteArray[i]), cache[i]));
if (TypeConversion.unsignedByteToInt(cache[i]) != TypeConversion.unsignedByteToInt((byte) byteArray[i])) {
mismatch = String.format("i: %d, byteArray[i]: %02x, cache[i]: %02x", i, byteArray[i], cache[i]);
allMatch = false;
break;
}
}
RobotLog.e(s.toString() + "\n allMatch: " + allMatch + ", mismatch: " + mismatch);
return !allMatch;
} finally {
lock.unlock();
}
}
示例3: write2
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
private void write2(final byte[] var1) {
if (this.DEBUG_LOGGING) {
RobotLog.d(this.serialNumber + " USB recd: " + Arrays.toString(var1));
}
(new Thread() {
public void run() {
int var1x = TypeConversion.unsignedByteToInt(var1[3]);
int var2 = TypeConversion.unsignedByteToInt(var1[4]);
try {
Thread.sleep(10L);
byte[] var3;
switch (var1[2]) {
case -128:
var3 = new byte[e.length + var2];
System.arraycopy(e, 0, var3, 0, e.length);
var3[3] = var1[3];
var3[4] = var1[4];
System.arraycopy(f, var1x, var3, e.length, var2);
break;
case 0:
var3 = new byte[d.length];
System.arraycopy(d, 0, var3, 0, d.length);
var3[3] = var1[3];
var3[4] = 0;
System.arraycopy(var1, 5, f, var1x, var2);
break;
default:
var3 = Arrays.copyOf(var1, var1.length);
var3[2] = -1;
var3[3] = var1[3];
var3[4] = 0;
}
h.put(var3);
} catch (InterruptedException var4) {
RobotLog.w("USB mock bus interrupted during write");
}
}
}).start();
}
示例4: setMotorTargetPosition
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
@Override
public synchronized void setMotorTargetPosition(int motor, int position) {
this.validateMotor(motor);
byte[] bytes = TypeConversion.intToByteArray(position, ByteOrder.BIG_ENDIAN);
this.write(mpMotorRegTargetEncoderValue[motor], bytes);
}
示例5: getMotorTargetPosition
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
@Override
public synchronized int getMotorTargetPosition(int motor) {
this.validateMotor(motor);
byte[] bytes = this.i2cDeviceClient.read(mpMotorRegTargetEncoderValue[motor], cbEncoder);
return TypeConversion.byteArrayToInt(bytes, ByteOrder.BIG_ENDIAN);
}
示例6: getMotorCurrentPosition
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
@Override
public synchronized int getMotorCurrentPosition(int motor) {
this.validateMotor(motor);
byte[] bytes = this.i2cDeviceClient.read(mpMotorRegCurrentEncoderValue[motor], cbEncoder);
return TypeConversion.byteArrayToInt(bytes, ByteOrder.BIG_ENDIAN);
}
示例7: read8
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
int read8(int ireg) {
byte b = this.i2cDeviceClient.read8(ireg);
return TypeConversion.unsignedByteToInt(b);
}
示例8: readLH
import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
int readLH(int ireg) {
byte[] bytes = this.i2cDeviceClient.read(ireg, 2);
return TypeConversion.byteArrayToInt(bytes, ByteOrder.LITTLE_ENDIAN);
}