4601 I-V Meter Operation Manual
6.5.5 Binary Output Format
6-21
Definite Length Block Response Data Format
Output example
As the Windows systems use the little endian ordering, the endian of each data needs to be reversed. Oth-
erwise, the received binary data is not returned to the original floating point.
Example of converting binary data to double-precision floating-point format
.NET)
Array.Reverse(byteArray, i, 8)’
Reverses the target data bytearray to an 8-byte unit.
’The double type consists of 8 bytes.
System.BitConverter.ToDouble(byteArray, i).ToString()
’Converts the byte array to double.
VBA)
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any,
Source As Any, ByVal Length As Long)
Function ByteArrayToDouble(ByRef bytArray() As Byte) As Double
Dim dblVal As Double
Dim bytWork(0 To 7) As Byte
Dim v As Variant
Dim n As Integer
n = 7
For Each v In bytArray
bytWork(n) = v
n = n - 1
Next
Call CopyMemory(dblVal, bytWork(0), 8)
ByteArrayToDouble = dblVal
End Function
# n m • • • m ddddddd • • • dddddddd
m:
Specifies how many data bytes will follow.
n:
Specifies how many digits are contained.
Specifies the beginning (“#” fixed)
d:
data
#208<B><B><B><B><B><B><B><B>
<B>: 1-byte data