Fixed issues with parsing large ushort values

This commit is contained in:
Trevor Payne
2019-11-09 21:14:39 -06:00
parent 03b1808186
commit c59608d7b9

View File

@@ -141,14 +141,11 @@ namespace PepperDash.Core.JsonToSimpl
void ProcessUshortPath(ushort index) {
string response;
if (Process(UshortPaths[index], out response)) {
ushort returnVal;
short val;
try { val = Convert.ToInt16(response); }
ushort val;
try { val = Convert.ToInt32(response) < 0 ? (ushort)(Convert.ToInt16(response) + 65536) : Convert.ToUInt16(response); }
catch { val = 0; }
returnVal = val < 0 ? (ushort)(val + 65536) : (ushort)val;
OnUShortChange(returnVal, index, JsonToSimplConstants.UshortValueChange);
OnUShortChange(val, index, JsonToSimplConstants.UshortValueChange);
}
else { }
// OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange);