Skip to content
Merged
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
27 changes: 16 additions & 11 deletions DeviceProgramming/Dfu/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ private Status SeErase(uint address)
private static readonly Regex SeMemoryLayoutRegex = new Regex(
@"^@(?<name>[\w\s]*[\w]+)\s*
/0x(?<address>[A-F0-9]{1,8})
/(\d+)\*(\d+)([\x20KM]{1})([a-g]{1})(?:,(\d+)\*(\d+)([\x20KM]{1})([a-g]{1}))*$",
/(\d+)\*(\d+)([\x20KM]?)([a-g]{1})(?:,(\d+)\*(\d+)([\x20KM]?)([a-g]{1}))*$",
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);

/// <summary>
Expand Down Expand Up @@ -671,17 +671,22 @@ private NamedLayout ParseLayout(string dfuSeFormat)
uint blockNo = UInt32.Parse(result.Groups[groupoff + 1].Captures[i].Value);
uint blockSize = UInt32.Parse(result.Groups[groupoff + 2].Captures[i].Value);

// size modifiers (K for kilo-, M for Mega)
switch (result.Groups[groupoff + 3].Captures[i].Value[0])
string sizeModifier = result.Groups[groupoff + 3].Captures[i].Value;

if (!string.IsNullOrEmpty(sizeModifier))
{
case 'K':
blockSize <<= 10;
break;
case 'M':
blockSize <<= 20;
break;
default:
break;
// size modifiers (K for kilo-, M for Mega)
switch (sizeModifier[0])
{
case 'K':
blockSize <<= 10;
break;
case 'M':
blockSize <<= 20;
break;
default:
break;
}
}
Comment thread
benedekkupper marked this conversation as resolved.

// the permissions are encoded in the lowest 3 bits of the ASCII character...
Expand Down
Loading