diff --git a/src/core/Utils.js b/src/core/Utils.js index 6d80c21b..16f581b3 100755 --- a/src/core/Utils.js +++ b/src/core/Utils.js @@ -718,10 +718,10 @@ const Utils = { * Utils.fromHex("0a:14:1e", "Colon"); */ fromHex: function(data, delim, byteLen) { - delim = delim || (data.indexOf(" ") >= 0 ? "Space" : "None"); + delim = delim || "Auto"; byteLen = byteLen || 2; if (delim !== "None") { - const delimRegex = Utils.regexRep[delim]; + const delimRegex = delim === "Auto" ? /[^a-f\d]/gi : Utils.regexRep[delim]; data = data.replace(delimRegex, ""); } diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index d27ca3a6..9c33d3d0 100644 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -624,7 +624,7 @@ const OperationConfig = { { name: "Delimiter", type: "option", - value: ByteRepr.HEX_DELIM_OPTIONS + value: ByteRepr.FROM_HEX_DELIM_OPTIONS } ] }, @@ -639,7 +639,7 @@ const OperationConfig = { { name: "Delimiter", type: "option", - value: ByteRepr.HEX_DELIM_OPTIONS + value: ByteRepr.TO_HEX_DELIM_OPTIONS } ] }, diff --git a/src/core/operations/ByteRepr.js b/src/core/operations/ByteRepr.js index 5546a22c..607e6b0e 100755 --- a/src/core/operations/ByteRepr.js +++ b/src/core/operations/ByteRepr.js @@ -21,7 +21,12 @@ const ByteRepr = { * @constant * @default */ - HEX_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"], + TO_HEX_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"], + /** + * @constant + * @default + */ + FROM_HEX_DELIM_OPTIONS: ["Auto", "Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"], /** * @constant * @default