Ensure bit size

This commit is contained in:
Peter Butzhammer
2024-02-08 16:47:10 +01:00
parent 1001303b8c
commit fdc25d2817

View File

@@ -145,6 +145,11 @@ internal class S7VariableNameParser : IS7VariableNameParser
if (!byte.TryParse(match.Groups["bitOrLength"].Value, out var result))
throw new InvalidS7AddressException($"\"{match.Groups["bitOrLength"].Value}\" is an invalid bit number in \"{input}\"", input);
if (result > 7)
throw new InvalidS7AddressException($"Bit must be between 0 and 7 but is {result} in \"{input}\"", input);
return result;
}
}