Skip to content

Commit 02d2924

Browse files
committed
Integrated commands and button settings for the RevE boards into the app.
1 parent 894160a commit 02d2924

21 files changed

+249
-98
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId "com.maxieds.chameleonminilivedebugger"
2727
minSdkVersion 21
2828
targetSdkVersion 27
29-
versionCode 40
30-
versionName "0.4.0"
29+
versionCode 41
30+
versionName "0.4.1"
3131
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3232
multiDexEnabled true
3333
}

app/src/main/java/com/maxieds/chameleonminilivedebugger/ChameleonIO.java

Lines changed: 77 additions & 40 deletions
Large diffs are not rendered by default.

app/src/main/java/com/maxieds/chameleonminilivedebugger/LiveLoggerActivity.java

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import android.widget.ScrollView;
4949
import android.widget.Spinner;
5050
import android.widget.SpinnerAdapter;
51+
import android.widget.Switch;
5152
import android.widget.TextView;
5253
import android.widget.Toolbar;
5354

@@ -105,6 +106,7 @@ public class LiveLoggerActivity extends AppCompatActivity {
105106
public static SpinnerAdapter spinnerLButtonLongAdapter;
106107
public static SpinnerAdapter spinnerLEDRedAdapter;
107108
public static SpinnerAdapter spinnerLEDGreenAdapter;
109+
public static SpinnerAdapter spinnerButtonMyAdapter;
108110
public static SpinnerAdapter spinnerLogModeAdapter;
109111
public static SpinnerAdapter spinnerCmdShellAdapter;
110112
public static MenuItem selectedThemeMenuItem;
@@ -595,6 +597,12 @@ public UsbSerialDevice configureSerialPort(UsbSerialDevice serialPort, UsbSerial
595597
int deviceVID = device.getVendorId();
596598
int devicePID = device.getProductId();
597599
if(deviceVID == ChameleonIO.CMUSB_VENDORID && devicePID == ChameleonIO.CMUSB_PRODUCTID) {
600+
ChameleonIO.REVE_BOARD = false;
601+
connection = usbManager.openDevice(device);
602+
break;
603+
}
604+
else if(deviceVID == ChameleonIO.CMUSB_REVE_VENDORID && devicePID == ChameleonIO.CMUSB_REVE_PRODUCTID) {
605+
ChameleonIO.REVE_BOARD = true;
598606
connection = usbManager.openDevice(device);
599607
break;
600608
}
@@ -740,22 +748,30 @@ public void actionButtonRestorePeripheralDefaults(View view) {
740748
R.id.LButtonSpinner,
741749
R.id.LButtonLongSpinner,
742750
R.id.LEDRedSpinner,
743-
R.id.LEDGreenSpinner
751+
R.id.LEDGreenSpinner,
752+
R.id.ButtonMyRevEBoardSpinner
744753
};
745754
String[] queryCmds = {
746755
"RBUTTON?",
747756
"RBUTTON_LONG?",
748757
"LBUTTON?",
749758
"LBUTTON_LONG?",
750759
"LEDRED?",
751-
"LEDGREEN?"
760+
"LEDGREEN?",
761+
"buttonmy?"
752762
};
753763
for (int i = 0; i < spinnerIDs.length; i++) {
754764
Log.i(TAG, queryCmds[i]);
755765
Spinner curSpinner = (Spinner) LiveLoggerActivity.runningActivity.findViewById(spinnerIDs[i]);
756766
String deviceSetting = getSettingFromDevice(LiveLoggerActivity.serialPort, queryCmds[i]);
757767
curSpinner.setSelection(((ArrayAdapter<String>) curSpinner.getAdapter()).getPosition(deviceSetting));
758768
}
769+
// handle FIELD and READ-ONLY switches:
770+
String fieldSetting = getSettingFromDevice(LiveLoggerActivity.serialPort, "FIELD?");
771+
((Switch) findViewById(R.id.fieldOnOffSwitch)).setChecked(fieldSetting.equals("0") ? false : true);
772+
String roQueryCmd = ChameleonIO.REVE_BOARD ? "readonlymy?" : "READONLY?";
773+
String roSetting = getSettingFromDevice(LiveLoggerActivity.serialPort, roQueryCmd);
774+
((Switch) findViewById(R.id.readonlyOnOffSwitch)).setChecked(roSetting.equals("0") ? false : true);
759775
}
760776

761777
}
@@ -847,17 +863,26 @@ else if(createCmd.equals("SNIFFER")) {
847863
return;
848864
}
849865
else if(createCmd.equals("ULTRALIGHT")) {
850-
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_ULTRALIGHT", ChameleonIO.TIMEOUT);
866+
if(!ChameleonIO.REVE_BOARD)
867+
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_ULTRALIGHT", ChameleonIO.TIMEOUT);
868+
else
869+
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=MF_ULTRALIGHT", ChameleonIO.TIMEOUT);
851870
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
852871
return;
853872
}
854873
else if(createCmd.equals("CLASSIC-1K")) {
855-
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_1K", ChameleonIO.TIMEOUT);
874+
if(!ChameleonIO.REVE_BOARD)
875+
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_1K", ChameleonIO.TIMEOUT);
876+
else
877+
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=MF_CLASSIC_1K", ChameleonIO.TIMEOUT);
856878
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
857879
return;
858880
}
859881
else if(createCmd.equals("CLASSIC-4K")) {
860-
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_4K", ChameleonIO.TIMEOUT);
882+
if(!ChameleonIO.REVE_BOARD)
883+
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_4K", ChameleonIO.TIMEOUT);
884+
else
885+
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=MF_CLASSIC_4K", ChameleonIO.TIMEOUT);
861886
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
862887
return;
863888
}
@@ -887,21 +912,25 @@ else if(createCmd.equals("MFU-EV1-164B")) {
887912
return;
888913
}
889914
else if(createCmd.equals("CFGNONE")) {
890-
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=NONE", ChameleonIO.TIMEOUT);
915+
if(!ChameleonIO.REVE_BOARD)
916+
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=NONE", ChameleonIO.TIMEOUT);
917+
else
918+
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=NONE", ChameleonIO.TIMEOUT);
891919
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
892920
return;
893921
}
894-
else if(createCmd.equals("RESET")) { // need to re-establish the usb connection:
895-
ChameleonIO.executeChameleonMiniCommand(serialPort, "RESET", ChameleonIO.TIMEOUT);
922+
else if(createCmd.equals("RESET") || createCmd.equals("resetmy")) { // need to re-establish the usb connection:
923+
ChameleonIO.executeChameleonMiniCommand(serialPort, createCmd, ChameleonIO.TIMEOUT);
896924
ChameleonIO.deviceStatus.statsUpdateHandler.removeCallbacks(ChameleonIO.deviceStatus.statsUpdateRunnable);
897925
closeSerialPort(serialPort);
898926
configureSerialPort(null, usbReaderCallback);
899927
ChameleonIO.deviceStatus.updateAllStatusAndPost(true);
900928
return;
901929
}
902930
else if(createCmd.equals("RANDOM UID")) {
931+
String uidCmd = ChameleonIO.REVE_BOARD ? "uidmy=" : "UID=";
903932
byte[] randomBytes = Utils.getRandomBytes(ChameleonIO.deviceStatus.UIDSIZE);
904-
String sendCmd = "UID=" + Utils.bytes2Hex(randomBytes).replace(" ", "");
933+
String sendCmd = uidCmd + Utils.bytes2Hex(randomBytes).replace(" ", "");
905934
ChameleonIO.executeChameleonMiniCommand(serialPort, sendCmd, ChameleonIO.TIMEOUT);
906935
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
907936
}
@@ -924,7 +953,8 @@ else if(createCmd.equals("ONCLICK")) {
924953
msgParam = "SYSTICK Millis := " + getSettingFromDevice(serialPort, "SYSTICK?");
925954
}
926955
else if(createCmd.equals("GETUID")) {
927-
String rParam = getSettingFromDevice(serialPort, "GETUID");
956+
String queryCmd = ChameleonIO.REVE_BOARD ? "uidmy?" : "GETUID";
957+
String rParam = getSettingFromDevice(serialPort, queryCmd);
928958
msgParam = "GETUID: " + rParam;
929959
}
930960
else if(createCmd.equals("SEND") || createCmd.equals("SEND_RAW")) {
@@ -1071,7 +1101,8 @@ else if(uidAction.equals("SHIFT_LEFT")){
10711101
System.arraycopy(uid, 0, nextUID, 1, uid.length - 1);
10721102
uid = nextUID;
10731103
}
1074-
getSettingFromDevice(serialPort, String.format(Locale.ENGLISH, "UID=%s", Utils.bytes2Hex(uid).replace(" ", "")));
1104+
String uidCmd = ChameleonIO.REVE_BOARD ? "uidmy" : "UID";
1105+
getSettingFromDevice(serialPort, String.format(Locale.ENGLISH, "%s=%s", uidCmd, Utils.bytes2Hex(uid).replace(" ", "")));
10751106
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
10761107
appendNewLog(LogEntryMetadataRecord.createDefaultEventRecord("UID", "Next device UID set to " + Utils.bytes2Hex(uid).replace(" ", ":")));
10771108
}
@@ -1327,8 +1358,10 @@ public void actionButtonExportLogDownload(View view) {
13271358
ExportTools.downloadByXModem("LOGDOWNLOAD", "devicelog", false);
13281359
else if(action.equals("LOGDOWNLOAD2LIVE"))
13291360
ExportTools.downloadByXModem("LOGDOWNLOAD", "devicelog", true);
1330-
else if(action.equals("DOWNLOAD"))
1331-
ExportTools.downloadByXModem("DOWNLOAD", "carddata-" + ChameleonIO.deviceStatus.CONFIG, false);
1361+
else if(action.equals("DOWNLOAD")) {
1362+
String dldCmd = ChameleonIO.REVE_BOARD ? "downloadmy" : "DOWNLOAD";
1363+
ExportTools.downloadByXModem(dldCmd, "carddata-" + ChameleonIO.deviceStatus.CONFIG, false);
1364+
}
13321365
}
13331366

13341367
/**

app/src/main/java/com/maxieds/chameleonminilivedebugger/TabFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ else if(tabNumber == TAB_TOOLS && LiveLoggerActivity.spinnerRButtonLongAdapter =
227227
connectPeripheralSpinnerAdapter(view, R.id.LButtonLongSpinner, R.array.LButtonLongOptions, LiveLoggerActivity.spinnerLButtonLongAdapter, "LBUTTON_LONG?");
228228
connectPeripheralSpinnerAdapter(view, R.id.LEDRedSpinner, R.array.LEDRedOptions, LiveLoggerActivity.spinnerLEDRedAdapter, "LEDRED?");
229229
connectPeripheralSpinnerAdapter(view, R.id.LEDGreenSpinner, R.array.LEDGreenOptions, LiveLoggerActivity.spinnerLEDGreenAdapter, "LEDGREEN?");
230+
connectPeripheralSpinnerAdapter(view, R.id.ButtonMyRevEBoardSpinner, R.array.ButtonMyRevEBoards, LiveLoggerActivity.spinnerButtonMyAdapter, "buttonmy?");
230231
connectPeripheralSpinnerAdapter(view, R.id.LogModeSpinner, R.array.LogModeOptions, LiveLoggerActivity.spinnerLogModeAdapter, "LOGMODE?");
231232
connectCommandListSpinnerAdapter(view, R.id.FullCmdListSpinner, R.array.FullCommandList, LiveLoggerActivity.spinnerCmdShellAdapter, "");
232233

@@ -283,7 +284,8 @@ public void onStopTrackingTouch(SeekBar seekBar) {
283284
@Override
284285
public void onScrollStateChange(NumberPicker numberPicker, int scrollState) {
285286
if (scrollState == NumberPicker.OnScrollListener.SCROLL_STATE_IDLE) {
286-
LiveLoggerActivity.getSettingFromDevice(LiveLoggerActivity.serialPort, "SETTING=" + numberPicker.getValue());
287+
String settingCmd = ChameleonIO.REVE_BOARD ? "settingmy=" : "SETTING=";
288+
LiveLoggerActivity.getSettingFromDevice(LiveLoggerActivity.serialPort, settingCmd + numberPicker.getValue());
287289
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
288290
}
289291
}
442 Bytes
Loading
728 Bytes
Loading
684 Bytes
Loading
430 Bytes
Loading
917 Bytes
Loading
745 Bytes
Loading

0 commit comments

Comments
 (0)