public static byte[] DataToByte(CalibrationData object_0) { int num = Marshal.SizeOf(typeof(CalibrationData)); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(object_0, intPtr, false); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return(array); }
public static byte[] DataToByte(CalibrationData calData) { // DAC Osc value is 10 bit signed if (calData.DACOscRefTune < 0) { calData.DACOscRefTune = (short)(1024 + calData.DACOscRefTune); } int num = Marshal.SizeOf(typeof(CalibrationData)); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(calData, intPtr, false); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return(array); }
private CalibrationData ByteToData(byte[] byte_0) { int num = Marshal.SizeOf(typeof(CalibrationData)); IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.Copy(byte_0, 0, intPtr, num); object result = Marshal.PtrToStructure(intPtr, typeof(CalibrationData)); Marshal.FreeHGlobal(intPtr); CalibrationData calData = (CalibrationData)result; // DAC Osc value is 10 bit signed if (calData.DACOscRefTune > 511) { calData.DACOscRefTune = (short)(calData.DACOscRefTune - 1024); } return(calData); }