M Mostez Well-Known Member Licensed User Longtime User Sep 19, 2016 #1 Hello, I've got reversed bytes order (low-byte and high-byte) when I assign the return value of UintsFromBytes function to an Uint variable, i.e. B4X: Dim CurrentPageID As UInt CurrentPageID = BC.UIntsFromBytes(DWIN_INCOMING_DATA)(0) 'CurrentPageID = 0x7800 instead of 0x0078 I logged DWIN_INCOMING_DATA to check data, it is correct '0x0078' but variable low, high bytes are reversed. Any ideas? Thanks
Hello, I've got reversed bytes order (low-byte and high-byte) when I assign the return value of UintsFromBytes function to an Uint variable, i.e. B4X: Dim CurrentPageID As UInt CurrentPageID = BC.UIntsFromBytes(DWIN_INCOMING_DATA)(0) 'CurrentPageID = 0x7800 instead of 0x0078 I logged DWIN_INCOMING_DATA to check data, it is correct '0x0078' but variable low, high bytes are reversed. Any ideas? Thanks
Erel B4X founder Staff member Licensed User Longtime User Sep 19, 2016 #2 Use RandomAccessFile instead of ByteConverter. It allows you to set the endianess. Upvote 0
M Mostez Well-Known Member Licensed User Longtime User Sep 19, 2016 #3 may I ask for little example? Thanks so much Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 19, 2016 #4 B4X: Dim raf As RandomAccessFile raf.Initialize(DWIN_INCOMING_DATA, False) 'second parameter is the endianess Dim currentPageId As UInt = raf.ReadUInt16(raf.CurrentPosition) Upvote 0
B4X: Dim raf As RandomAccessFile raf.Initialize(DWIN_INCOMING_DATA, False) 'second parameter is the endianess Dim currentPageId As UInt = raf.ReadUInt16(raf.CurrentPosition)
M Mostez Well-Known Member Licensed User Longtime User Sep 19, 2016 #5 it works like a charm, thanks Erel Upvote 0