Hi, I know there have been some topics but I'm curious if there is a more efficient solution to my problem.
As most of you probably know in VB6 CopyMemory is a very fast and efficient way to copy bytes between different data types.
I use it frequently to fill arrays with data or get data out of arrays into variables.
One of my use cases would be sth. like this:
VB6 CopyMemory:
Public Function DecodeFullHPS3DMessage(ByRef MessagePayload() As Byte, ByRef AvgDist As Long, ByRef MaxDist As Long, ByRef MinDist As Long, ByRef DepthData() As Byte)
AvgDist = 0
CopyMemory AvgDist, MessagePayload(2), 2
MaxDist = 0
CopyMemory MaxDist, MessagePayload(12), 2
MinDist = 0
CopyMemory MinDist, MessagePayload(14), 2
ReDim DepthData(19199)
CopyMemory DepthData(0), MessagePayload(24), 19200
End Function
As you can see it is super simple to split data from a serial stream (held in a byte array) into its components.
In B4X I'm not sure what the best way to do this would be, I'm trying sth. like this, which works but is kind of a mess:
Thanks for the reply. I will have a closer look at RandomAccessFile.Initialize3 .
I have to interface numerous devices that I don't have control over, so changing the protocol is impossible.
There is no way to implement anything similar to CopyMemory as a very efficient data transfer method between all kinds of variables?
In this example I get about one Megabyte of data per second so it should not be too inefficient.
There is no way to implement anything similar to CopyMemory as a very efficient data transfer method between all kinds of variables?
In this example I get about one Megabyte of data per second so it should not be too inefficient.