Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3fa2dbb

Browse files
committedDec 19, 2018
FIX: tab operation - setting Ultralight vs Classic crashed if uid was wrong size
FIX: tab operation - clear button now sets CLOSED FIX: tab operation - apply button now refreshes the slots that was updated. (memsize will now show correct)
1 parent 3efef76 commit 3fa2dbb

File tree

7 files changed

+76
-74
lines changed

7 files changed

+76
-74
lines changed
 

‎ChameleonMiniGUI/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<value>English</value>
3131
</setting>
3232
<setting name="version" serializeAs="String">
33-
<value>v1.2.0.8</value>
33+
<value>v1.2.0.9</value>
3434
</setting>
3535
</ChameleonMiniGUI.Properties.Settings>
3636
</userSettings>

‎ChameleonMiniGUI/ChameleonMiniGUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<MinimumRequiredVersion>1.2.0.0</MinimumRequiredVersion>
3434
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
3535
<WebPage>publish.htm</WebPage>
36-
<ApplicationRevision>9</ApplicationRevision>
36+
<ApplicationRevision>10</ApplicationRevision>
3737
<ApplicationVersion>1.2.0.%2a</ApplicationVersion>
3838
<UseApplicationTrust>false</UseApplicationTrust>
3939
<CreateDesktopShortcut>true</CreateDesktopShortcut>

‎ChameleonMiniGUI/FrmMain.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ChameleonMiniGUI/FrmMain.cs

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,14 @@ private void btn_apply_Click(object sender, EventArgs e)
274274
var tagslotIndex = int.Parse(cb.Name.Substring(cb.Name.Length - 1));
275275
if (tagslotIndex <= 0) continue;
276276

277-
//SETTINGMY=tagslotIndex-1
278277
SendCommandWithoutResult($"SETTING{_cmdExtension}=" + (tagslotIndex - _tagslotIndexOffset));
279278

280-
//SETTINGMY? -> SHOULD BE "NO."+tagslotIndex
281-
var selectedSlot = SendCommand($"SETTING{_cmdExtension}?").ToString();
282-
if (!selectedSlot.Contains((tagslotIndex - _tagslotIndexOffset).ToString()))
283-
{
284-
this.Cursor = Cursors.Default;
285-
return;
286-
}
287-
288279
var selectedMode = string.Empty;
289-
290-
var cb_mode = FindControls<ComboBox>(Controls, $"cb_mode{tagslotIndex}").FirstOrDefault();
291-
if (cb_mode != null)
280+
var mode = FindControls<ComboBox>(Controls, $"cb_mode{tagslotIndex}").FirstOrDefault();
281+
if (mode != null)
292282
{
293-
SendCommandWithoutResult($"CONFIG{_cmdExtension}={cb_mode.SelectedItem}");
294-
selectedMode = cb_mode.SelectedItem.ToString();
283+
SendCommandWithoutResult($"CONFIG{_cmdExtension}={mode.SelectedItem}");
284+
selectedMode = mode.SelectedItem.ToString();
295285
}
296286

297287
switch (_CurrentDevType)
@@ -318,21 +308,34 @@ private void btn_apply_Click(object sender, EventArgs e)
318308
var txtUid = FindControls<TextBox>(Controls, $"txt_uid{tagslotIndex}").FirstOrDefault();
319309
if (txtUid != null)
320310
{
321-
string uid = txtUid.Text;
311+
var uid = txtUid.Text;
322312
// always set UID, either with user provided or random. Is that acceptable?
323313
if (!string.IsNullOrEmpty(uid) && !string.IsNullOrEmpty(selectedMode) && IsUidValid(uid, selectedMode))
324314
{
325315
SendCommandWithoutResult($"UID{_cmdExtension}={uid}");
326316
}
327317
else
328318
{
329-
// set a random UID
330-
SendCommandWithoutResult($"UID{_cmdExtension}=?");
319+
var tmpuid = "11223344";
320+
if (selectedMode.StartsWith("MF_ULTRALIGHT"))
321+
{
322+
tmpuid = "11223344556677";
323+
}
324+
SendCommandWithoutResult($"UID{_cmdExtension}={tmpuid}");
331325
}
332326
}
333-
}
334327

328+
// Set MEMSIZE
329+
var slotMemSize = SendCommand($"MEMSIZE{_cmdExtension}?").ToString();
330+
if (!string.IsNullOrEmpty(slotMemSize) && !slotMemSize.StartsWith("202:"))
331+
{
332+
FindControls<TextBox>(Controls, $"txt_size{tagslotIndex}").ForEach(a => a.Text = slotMemSize);
333+
}
334+
335+
RefreshSlot(tagslotIndex);
336+
}
335337
RestoreActiveSlot();
338+
336339
this.Cursor = Cursors.Default;
337340
}
338341

@@ -496,7 +499,7 @@ private void btn_download_Click(object sender, EventArgs e)
496499
else
497500
{
498501
// Get UID first
499-
var uid = SendCommand("UID" + _cmdExtension + "?").ToString();
502+
var uid = SendCommand($"UID{_cmdExtension}?").ToString();
500503

501504
if (!string.IsNullOrEmpty(uid))
502505
{
@@ -554,56 +557,49 @@ private void btn_clear_Click(object sender, EventArgs e)
554557
// Get all selected indices
555558
foreach (var cb in FindControls<CheckBox>(Controls, "checkBox"))
556559
{
557-
if (cb.Checked)
558-
{
559-
var tagslotIndex = int.Parse(cb.Name.Substring(cb.Name.Length - 1));
560-
if (tagslotIndex <= 0)
561-
{
562-
this.Cursor = Cursors.Default;
563-
return;
564-
}
565-
566-
//SETTINGMY=tagslotIndex-1
567-
SendCommandWithoutResult($"SETTING{_cmdExtension}=" + (tagslotIndex - _tagslotIndexOffset));
568-
569-
SendCommandWithoutResult($"DETECTION{_cmdExtension}=CLOSED");
560+
if (!cb.Checked) continue;
570561

571-
SendCommandWithoutResult($"CLEAR{_cmdExtension}");
562+
var tagslotIndex = int.Parse(cb.Name.Substring(cb.Name.Length - 1));
563+
if (tagslotIndex <= 0) continue;
564+
565+
SendCommandWithoutResult($"SETTING{_cmdExtension}={tagslotIndex - _tagslotIndexOffset}");
566+
SendCommandWithoutResult($"CLEAR{_cmdExtension}");
572567

573-
// Set every field to a default value
574-
FindControls<ComboBox>(Controls, $"cb_mode{tagslotIndex}").ForEach( a => SendCommandWithoutResult($"CONFIG{_cmdExtension}={a.Items[0]}"));
568+
// Set every field to a default value
569+
570+
FindControls<ComboBox>(Controls, $"cb_mode{tagslotIndex}").ForEach( a => SendCommandWithoutResult($"CONFIG{_cmdExtension}=CLOSED"));
575571

576-
switch (_CurrentDevType)
572+
switch (_CurrentDevType)
573+
{
574+
case DeviceType.RevG:
577575
{
578-
case DeviceType.RevG:
579-
{
580-
FindControls<ComboBox>(Controls, $"cb_Lbutton{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LBUTTON{_cmdExtension}={a.Items[0]}"));
581-
FindControls<ComboBox>(Controls, $"cb_Lbuttonlong{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LBUTTON_LONG{_cmdExtension}={a.Items[0]}"));
582-
FindControls<ComboBox>(Controls, $"cb_Rbutton{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"RBUTTON{_cmdExtension}={a.Items[0]}"));
583-
FindControls<ComboBox>(Controls, $"cb_Rbuttonlong{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"RBUTTON_LONG{_cmdExtension}={a.Items[0]}"));
584-
FindControls<ComboBox>(Controls, $"cb_ledgreen{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LEDGREEN{_cmdExtension}={a.Items[0]}"));
585-
FindControls<ComboBox>(Controls, $"cb_ledred{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LEDRED{_cmdExtension}={a.Items[0]}"));
586-
break;
587-
}
588-
default:
576+
FindControls<ComboBox>(Controls, $"cb_Lbutton{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LBUTTON{_cmdExtension}={a.Items[0]}"));
577+
FindControls<ComboBox>(Controls, $"cb_Lbuttonlong{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LBUTTON_LONG{_cmdExtension}={a.Items[0]}"));
578+
FindControls<ComboBox>(Controls, $"cb_Rbutton{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"RBUTTON{_cmdExtension}={a.Items[0]}"));
579+
FindControls<ComboBox>(Controls, $"cb_Rbuttonlong{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"RBUTTON_LONG{_cmdExtension}={a.Items[0]}"));
580+
FindControls<ComboBox>(Controls, $"cb_ledgreen{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LEDGREEN{_cmdExtension}={a.Items[0]}"));
581+
FindControls<ComboBox>(Controls, $"cb_ledred{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"LEDRED{_cmdExtension}={a.Items[0]}"));
582+
break;
583+
}
584+
default:
585+
{
586+
FindControls<ComboBox>(Controls, $"cb_Lbutton{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"BUTTON{_cmdExtension}=SWITCHCARD"));
587+
FindControls<ComboBox>(Controls, $"cb_Lbuttonlong{tagslotIndex}").ForEach( a =>
588+
{
589+
if (a.Items.Count > 0)
589590
{
590-
FindControls<ComboBox>(Controls, $"cb_Lbutton{tagslotIndex}").ForEach(a => SendCommandWithoutResult($"BUTTON{_cmdExtension}={a.Items[0]}"));
591-
FindControls<ComboBox>(Controls, $"cb_Lbuttonlong{tagslotIndex}").ForEach(a =>
592-
{
593-
if (a.Items.Count > 0)
594-
{
595-
SendCommandWithoutResult($"BUTTON_LONG{_cmdExtension}={a.Items[0]}");
596-
}
597-
598-
});
599-
break;
591+
SendCommandWithoutResult($"BUTTON_LONG{_cmdExtension}={a.Items[0]}");
600592
}
593+
594+
});
595+
break;
601596
}
602-
RefreshSlot(tagslotIndex);
603597
}
604598
}
605-
606599
RestoreActiveSlot();
600+
601+
RefreshAllSlots();
602+
607603
this.Cursor = Cursors.Default;
608604
}
609605

@@ -1309,7 +1305,7 @@ private void OpenChameleonSerialPort()
13091305

13101306

13111307
// try without the "MY" extension first
1312-
FirmwareVersion = SendCommand("VERSION?") as string;
1308+
FirmwareVersion = SendCommand("VERSION?").ToString();
13131309
if (!string.IsNullOrEmpty(_firmwareVersion) && _firmwareVersion.Contains("Chameleon"))
13141310
{
13151311
_cmdExtension = string.Empty;
@@ -1319,7 +1315,7 @@ private void OpenChameleonSerialPort()
13191315
return;
13201316
}
13211317

1322-
FirmwareVersion = SendCommand("VERSIONMY?") as string;
1318+
FirmwareVersion = SendCommand("VERSIONMY?").ToString();
13231319
if (!string.IsNullOrEmpty(_firmwareVersion) && _firmwareVersion.Contains("Chameleon"))
13241320
{
13251321
_cmdExtension = "MY";
@@ -1363,7 +1359,7 @@ private void OpenChameleonSerialPort()
13631359
_CurrentDevType = DeviceType.Unknown;
13641360
_tagslotIndexOffset = 1;
13651361

1366-
FirmwareVersion = SendCommand("VERSION?") as string;
1362+
FirmwareVersion = SendCommand("VERSION?").ToString();
13671363
if (!string.IsNullOrEmpty(_firmwareVersion) && _firmwareVersion.Contains("Chameleon"))
13681364
{
13691365
_cmdExtension = string.Empty;
@@ -1376,7 +1372,7 @@ private void OpenChameleonSerialPort()
13761372
return;
13771373
}
13781374

1379-
FirmwareVersion = SendCommand("VERSIONMY?") as string;
1375+
FirmwareVersion = SendCommand("VERSIONMY?").ToString();
13801376
if (!string.IsNullOrEmpty(_firmwareVersion) && _firmwareVersion.Contains("Chameleon"))
13811377
{
13821378
_cmdExtension = "MY";
@@ -2047,19 +2043,19 @@ internal void UploadDump(string filename)
20472043
internal void DownloadAndSaveDump(string filename)
20482044
{
20492045
// First get the current memory size of the slot
2050-
var memsizeStr = SendCommand($"MEMSIZE{_cmdExtension}?");
2046+
var memsizeStr = SendCommand($"MEMSIZE{_cmdExtension}?").ToString();
20512047

20522048
// Default value
20532049
int memsize = 4096;
20542050

2055-
if (!string.IsNullOrEmpty((string)memsizeStr))
2051+
if (!string.IsNullOrEmpty(memsizeStr))
20562052
{
2057-
int.TryParse((string)memsizeStr, out memsize);
2053+
int.TryParse(memsizeStr, out memsize);
20582054
}
20592055

20602056
// Also check if the tag is UL to save the counters too
2061-
var configStr = SendCommand($"CONFIG{_cmdExtension}?") as string;
2062-
if ((configStr != null) && (configStr.Contains("ULTRALIGHT")))
2057+
var configStr = SendCommand($"CONFIG{_cmdExtension}?").ToString();
2058+
if (!string.IsNullOrWhiteSpace(configStr) && (configStr.Contains("ULTRALIGHT")))
20632059
{
20642060
if (memsize < 4069)
20652061
{
@@ -2555,5 +2551,10 @@ private void RestoreActiveSlot()
25552551
HighlightActiveSlot();
25562552
}
25572553
#endregion
2554+
2555+
private void cb_mode1_SelectedIndexChanged(object sender, EventArgs e)
2556+
{
2557+
2558+
}
25582559
}
25592560
}

‎ChameleonMiniGUI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.0.8")]
36-
[assembly: AssemblyFileVersion("1.2.0.8")]
35+
[assembly: AssemblyVersion("1.2.0.9")]
36+
[assembly: AssemblyFileVersion("1.2.0.9")]

‎ChameleonMiniGUI/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ChameleonMiniGUI/Properties/Settings.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Value Profile="(Default)">English</Value>
1616
</Setting>
1717
<Setting Name="version" Type="System.String" Scope="User">
18-
<Value Profile="(Default)">v1.2.0.8</Value>
18+
<Value Profile="(Default)">v1.2.0.9</Value>
1919
</Setting>
2020
</Settings>
2121
</SettingsFile>

0 commit comments

Comments
 (0)
Please sign in to comment.