Skip to content

Commit

Permalink
Added 64 bit formats
Browse files Browse the repository at this point in the history
  • Loading branch information
uholeschak committed Dec 9, 2024
1 parent 7e0ec2c commit 09e991c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
43 changes: 34 additions & 9 deletions EdiabasLib/ApiInternal/ApiInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,18 +586,25 @@ public bool apiResultLongLong(out long buffer, string result, ushort rset)
}

setLocalError(EDIABAS_ERR_NONE);
if (!getResultInt64(out Int64 int64Buffer, out EdiabasLib.EdiabasNet.ResultType resultType, result, rset))
if (!getResultInt64(out Int64 int64Buffer, out EdiabasNet.ResultType resultType, result, rset))
{
return false;
}

if (resultType == EdiabasNet.ResultType.TypeD)
switch (resultType)
{
buffer = (uint)int64Buffer;
}
else
{
buffer = (int)int64Buffer;
case EdiabasNet.ResultType.TypeQ:
case EdiabasNet.ResultType.TypeLL:
buffer = int64Buffer;
break;

case EdiabasNet.ResultType.TypeD:
buffer = (uint)int64Buffer;
break;

default:
buffer = (int)int64Buffer;
break;
}

logFormat(ApiLogLevel.Normal, "={0} ({1})", true, buffer);
Expand All @@ -616,12 +623,22 @@ public bool apiResultQWord(out ulong buffer, string result, ushort rset)
}

setLocalError(EDIABAS_ERR_NONE);
if (!getResultInt64(out Int64 int64Buffer, out EdiabasLib.EdiabasNet.ResultType resultType, result, rset))
if (!getResultInt64(out Int64 int64Buffer, out EdiabasNet.ResultType resultType, result, rset))
{
return false;
}

buffer = (uint)int64Buffer;
switch (resultType)
{
case EdiabasNet.ResultType.TypeQ:
case EdiabasNet.ResultType.TypeLL:
buffer = (ulong)int64Buffer;
break;

default:
buffer = (uint)int64Buffer;
break;
}

logFormat(ApiLogLevel.Normal, "={0} ({1})", true, buffer);
return true;
Expand Down Expand Up @@ -839,6 +856,10 @@ public bool apiResultFormat(out int buffer, string result, ushort rset)
buffer = APIFORMAT_DWORD;
break;

case EdiabasNet.ResultType.TypeQ:
buffer = APIFORMAT_QWORD;
break;

case EdiabasNet.ResultType.TypeC:
buffer = APIFORMAT_CHAR;
break;
Expand All @@ -851,6 +872,10 @@ public bool apiResultFormat(out int buffer, string result, ushort rset)
buffer = APIFORMAT_LONG;
break;

case EdiabasNet.ResultType.TypeLL:
buffer = APIFORMAT_LONGLONG;
break;

case EdiabasNet.ResultType.TypeR:
buffer = APIFORMAT_REAL;
break;
Expand Down
2 changes: 2 additions & 0 deletions EdiabasLib/EdiabasLib/EdiabasNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,9 +1411,11 @@ public enum ResultType : byte
TypeB, // 8 bit
TypeW, // 16 bit
TypeD, // 32 bit
TypeQ, // 64 bit
TypeC, // 8 bit char
TypeI, // 16 bit signed
TypeL, // 32 bit signed
TypeLL, // 64 bit signed
TypeR, // float
TypeS, // string
TypeY, // array
Expand Down
8 changes: 8 additions & 0 deletions EdiabasLib/EdiabasTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ static void PrintResults(List<string> formatList, bool printAllTypes, List<Dicti
sbResult.Append(string.Format(Culture, "L: {0} 0x{1:X08}", value, (UInt32)value));
break;

case EdiabasNet.ResultType.TypeQ: // 64 bit
sbResult.Append(string.Format(Culture, "QW: {0} 0x{1:X016}", value, (UInt64)value));
break;

case EdiabasNet.ResultType.TypeLL: // 64 bit signed
sbResult.Append(string.Format(Culture, "L: {0} 0x{1:X016}", value, (UInt64)value));
break;

default:
sbResult.Append("?");
break;
Expand Down
8 changes: 4 additions & 4 deletions EdiabasLib/Test/EdiabasCall/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static void PrintResults(List<string> formatList, bool printAllTypes)
__api32ResultLongLong(_apiHandle, out resultLong, resultName, set);
if (apiResultLL)
{
sbResult.Append(string.Format(Culture, "LL: {0}", resultLong));
sbResult.Append(string.Format(Culture, "LL: {0} 0x{0:X016}", resultLong));
}
}
catch (Exception ex)
Expand All @@ -490,7 +490,7 @@ static void PrintResults(List<string> formatList, bool printAllTypes)
__api32ResultQWord(_apiHandle, out resultUlong, resultName, set);
if (apiResultQW)
{
sbResult.Append(string.Format(Culture, "QW: {0}", resultUlong));
sbResult.Append(string.Format(Culture, "QW: {0} 0x{0:X016}", resultUlong));
}
}
catch (Exception ex)
Expand All @@ -504,7 +504,7 @@ static void PrintResults(List<string> formatList, bool printAllTypes)
{
if (API.apiResultLongLong(out long resultLong, resultName, set))
{
sbResult.Append(string.Format(Culture, "LL: {0}", resultLong));
sbResult.Append(string.Format(Culture, "LL: {0} 0x{0:X016}", resultLong));
}
break;
}
Expand All @@ -513,7 +513,7 @@ static void PrintResults(List<string> formatList, bool printAllTypes)
{
if (API.apiResultQWord(out ulong resultUlong, resultName, set))
{
sbResult.Append(string.Format(Culture, "QW: {0}", resultUlong));
sbResult.Append(string.Format(Culture, "QW: {0} 0x{0:X016}", resultUlong));
}
break;
}
Expand Down

0 comments on commit 09e991c

Please sign in to comment.