Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. TGXByteBuffer.GetInt64 Returns Wrong Result

TGXByteBuffer.GetInt64 returns wrong result

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By DSRinger , 3 February, 2020
Forums
Gurux.DLMS

Hey.
Sorry for the bad English, I use Google translator.

The TGXByteBuffer.GetInt64 function returns an incorrect result due to the use of the Swap procedure.
For example, the value of Int64 (00 00 00 00 00 00 00 00 20) is returned as 0. I solved the problem by adding a new function from the Internet
function Swap64 (Value: Int64): Int64;
{$ IFDEF CPUX86}
var Lo, Hi: Cardinal;
begin
  Lo: = Int64Rec (Value) .Hi;
  Hi: = Int64Rec (Value) .Lo;
  Int64Rec (Result) .Hi: = (Hi shr 24) or (Hi shl 24) or ((Hi and $ 00FF0000) shr 8) or ((Hi and $ 0000FF00) shl 8);
  Int64Rec (Result) .Lo: = (Lo shr 24) or (Lo shl 24) or ((Lo and $ 00FF0000) shr 8) or ((Lo and $ 0000FF00) shl 8);
end;
{$ ENDIF CPUX86}
{$ IFDEF CPUX64}
asm
  // -> RCX Value
  // <- RAX Result
  MOV RAX, RCX
  BSWAP RAX
end;
{$ ENDIF CPUX64}

function TGXByteBuffer.GetInt64 (): Int64;
begin
  System.Move (FData [FPosition], Result, 8);
  Result: = Swap64 (Result); // in the original - Result: = Swap (Result);
  FPosition: = FPosition + 8;
end;

I think it will be useful for those who are faced with the problem of getting Int64 values.

Profile picture for user Kurumi

Kurumi

6 years 4 months ago

Hi,

Hi,
Thank you for this info. We'll check this.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin