Weighing: Fix scale L320 for Baden
This commit is contained in:
@ -58,11 +58,19 @@ namespace Elwig.Helpers.Weighing {
|
||||
}
|
||||
|
||||
protected async Task<WeighingResult?> Receive() {
|
||||
var line = await Reader.ReadUntilAsync("\r\n");
|
||||
var line = "";
|
||||
while (line.Length < 33) {
|
||||
var ch = Reader.Read();
|
||||
if (ch == -1) {
|
||||
return null;
|
||||
} else if (line.Length > 0 || ch == ' ') {
|
||||
line += char.ToString((char)ch);
|
||||
}
|
||||
}
|
||||
if (LogPath != null) await File.AppendAllTextAsync(LogPath, line);
|
||||
if (line == null || line == "") {
|
||||
return null;
|
||||
} else if (line.Length != 35 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') {
|
||||
} else if (line.Length != 33 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') {
|
||||
throw new IOException($"Invalid event from scale: '{line}'");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user