Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [] = OPLogConvert(varargin)
- %% Define indices and arrays of structures to hold data
- % THIS FILE IS AUTOMATICALLY GENERATED.
- wrongSyncByte=0;
- wrongMessageByte=0;
- lastWrongSyncByte=0;
- lastWrongMessageByte=0;
- str1=[];
- str2=[];
- str3=[];
- str4=[];
- str5=[];
- fprintf('\n\n***OpenPilot log parser***\n\n');
- outputType='mat'; %Default output is a .mat file
- checkCRC = false;
- global crc_table;
- crc_table = [ ...
- hex2dec('00'),hex2dec('07'),hex2dec('0e'),hex2dec('09'),hex2dec('1c'),hex2dec('1b'),hex2dec('12'),hex2dec('15'),hex2dec('38'),hex2dec('3f'),hex2dec('36'),hex2dec('31'),hex2dec('24'),hex2dec('23'),hex2dec('2a'),hex2dec('2d'), ...
- hex2dec('70'),hex2dec('77'),hex2dec('7e'),hex2dec('79'),hex2dec('6c'),hex2dec('6b'),hex2dec('62'),hex2dec('65'),hex2dec('48'),hex2dec('4f'),hex2dec('46'),hex2dec('41'),hex2dec('54'),hex2dec('53'),hex2dec('5a'),hex2dec('5d'), ...
- hex2dec('e0'),hex2dec('e7'),hex2dec('ee'),hex2dec('e9'),hex2dec('fc'),hex2dec('fb'),hex2dec('f2'),hex2dec('f5'),hex2dec('d8'),hex2dec('df'),hex2dec('d6'),hex2dec('d1'),hex2dec('c4'),hex2dec('c3'),hex2dec('ca'),hex2dec('cd'), ...
- hex2dec('90'),hex2dec('97'),hex2dec('9e'),hex2dec('99'),hex2dec('8c'),hex2dec('8b'),hex2dec('82'),hex2dec('85'),hex2dec('a8'),hex2dec('af'),hex2dec('a6'),hex2dec('a1'),hex2dec('b4'),hex2dec('b3'),hex2dec('ba'),hex2dec('bd'), ...
- hex2dec('c7'),hex2dec('c0'),hex2dec('c9'),hex2dec('ce'),hex2dec('db'),hex2dec('dc'),hex2dec('d5'),hex2dec('d2'),hex2dec('ff'),hex2dec('f8'),hex2dec('f1'),hex2dec('f6'),hex2dec('e3'),hex2dec('e4'),hex2dec('ed'),hex2dec('ea'), ...
- hex2dec('b7'),hex2dec('b0'),hex2dec('b9'),hex2dec('be'),hex2dec('ab'),hex2dec('ac'),hex2dec('a5'),hex2dec('a2'),hex2dec('8f'),hex2dec('88'),hex2dec('81'),hex2dec('86'),hex2dec('93'),hex2dec('94'),hex2dec('9d'),hex2dec('9a'), ...
- hex2dec('27'),hex2dec('20'),hex2dec('29'),hex2dec('2e'),hex2dec('3b'),hex2dec('3c'),hex2dec('35'),hex2dec('32'),hex2dec('1f'),hex2dec('18'),hex2dec('11'),hex2dec('16'),hex2dec('03'),hex2dec('04'),hex2dec('0d'),hex2dec('0a'), ...
- hex2dec('57'),hex2dec('50'),hex2dec('59'),hex2dec('5e'),hex2dec('4b'),hex2dec('4c'),hex2dec('45'),hex2dec('42'),hex2dec('6f'),hex2dec('68'),hex2dec('61'),hex2dec('66'),hex2dec('73'),hex2dec('74'),hex2dec('7d'),hex2dec('7a'), ...
- hex2dec('89'),hex2dec('8e'),hex2dec('87'),hex2dec('80'),hex2dec('95'),hex2dec('92'),hex2dec('9b'),hex2dec('9c'),hex2dec('b1'),hex2dec('b6'),hex2dec('bf'),hex2dec('b8'),hex2dec('ad'),hex2dec('aa'),hex2dec('a3'),hex2dec('a4'), ...
- hex2dec('f9'),hex2dec('fe'),hex2dec('f7'),hex2dec('f0'),hex2dec('e5'),hex2dec('e2'),hex2dec('eb'),hex2dec('ec'),hex2dec('c1'),hex2dec('c6'),hex2dec('cf'),hex2dec('c8'),hex2dec('dd'),hex2dec('da'),hex2dec('d3'),hex2dec('d4'), ...
- hex2dec('69'),hex2dec('6e'),hex2dec('67'),hex2dec('60'),hex2dec('75'),hex2dec('72'),hex2dec('7b'),hex2dec('7c'),hex2dec('51'),hex2dec('56'),hex2dec('5f'),hex2dec('58'),hex2dec('4d'),hex2dec('4a'),hex2dec('43'),hex2dec('44'), ...
- hex2dec('19'),hex2dec('1e'),hex2dec('17'),hex2dec('10'),hex2dec('05'),hex2dec('02'),hex2dec('0b'),hex2dec('0c'),hex2dec('21'),hex2dec('26'),hex2dec('2f'),hex2dec('28'),hex2dec('3d'),hex2dec('3a'),hex2dec('33'),hex2dec('34'), ...
- hex2dec('4e'),hex2dec('49'),hex2dec('40'),hex2dec('47'),hex2dec('52'),hex2dec('55'),hex2dec('5c'),hex2dec('5b'),hex2dec('76'),hex2dec('71'),hex2dec('78'),hex2dec('7f'),hex2dec('6a'),hex2dec('6d'),hex2dec('64'),hex2dec('63'), ...
- hex2dec('3e'),hex2dec('39'),hex2dec('30'),hex2dec('37'),hex2dec('22'),hex2dec('25'),hex2dec('2c'),hex2dec('2b'),hex2dec('06'),hex2dec('01'),hex2dec('08'),hex2dec('0f'),hex2dec('1a'),hex2dec('1d'),hex2dec('14'),hex2dec('13'), ...
- hex2dec('ae'),hex2dec('a9'),hex2dec('a0'),hex2dec('a7'),hex2dec('b2'),hex2dec('b5'),hex2dec('bc'),hex2dec('bb'),hex2dec('96'),hex2dec('91'),hex2dec('98'),hex2dec('9f'),hex2dec('8a'),hex2dec('8d'),hex2dec('84'),hex2dec('83'), ...
- hex2dec('de'),hex2dec('d9'),hex2dec('d0'),hex2dec('d7'),hex2dec('c2'),hex2dec('c5'),hex2dec('cc'),hex2dec('cb'),hex2dec('e6'),hex2dec('e1'),hex2dec('e8'),hex2dec('ef'),hex2dec('fa'),hex2dec('fd'),hex2dec('f4'),hex2dec('f3') ...
- ];
- if nargin==0
- %%
- if (exist('uigetfile')) %#ok<EXIST>
- [FileName, PathName]=uigetfile('*.opl');
- logfile=fullfile(PathName, FileName);
- else
- error('Your technical computing program does not support file choosers. Please input the file name in the argument. ')
- end
- elseif nargin>0
- logfile=varargin{1};
- if nargin>1
- outputType=varargin{2};
- end
- end
- if ~strcmpi(outputType,'mat') && ~strcmpi(outputType,'csv')
- error('Incorrect file format specified. Second argument must be ''mat'' or ''csv''.');
- end
- accelsIdx = 0;
- Accels=struct('timestamp', 0,...
- 'x', 0,...
- 'y', 0,...
- 'z', 0,...
- 'temperature', 0);
- ACCELS_OBJID=3718078400;
- accessorydesiredIdx = 0;
- AccessoryDesired=struct('timestamp', 0,...
- 'instanceID', 0,...
- 'AccessoryVal', 0);
- ACCESSORYDESIRED_OBJID=3288963162;
- actuatorcommandIdx = 0;
- ActuatorCommand=struct('timestamp', 0,...
- 'Channel', zeros(10,1),...
- 'MaxUpdateTime', 0,...
- 'UpdateTime', 0,...
- 'NumFailedUpdates', 0);
- ACTUATORCOMMAND_OBJID=87182520;
- actuatordesiredIdx = 0;
- ActuatorDesired=struct('timestamp', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0,...
- 'Throttle', 0,...
- 'UpdateTime', 0,...
- 'NumLongUpdates', 0);
- ACTUATORDESIRED_OBJID=3393963172;
- actuatorsettingsIdx = 0;
- ActuatorSettings=struct('timestamp', 0,...
- 'ChannelUpdateFreq', zeros(4,1),...
- 'ChannelMax', zeros(10,1),...
- 'ChannelNeutral', zeros(10,1),...
- 'ChannelMin', zeros(10,1),...
- 'FixedWingRoll1', 0,...
- 'FixedWingRoll2', 0,...
- 'FixedWingPitch1', 0,...
- 'FixedWingPitch2', 0,...
- 'FixedWingYaw1', 0,...
- 'FixedWingYaw2', 0,...
- 'FixedWingThrottle', 0,...
- 'VTOLMotorN', 0,...
- 'VTOLMotorNE', 0,...
- 'VTOLMotorE', 0,...
- 'VTOLMotorSE', 0,...
- 'VTOLMotorS', 0,...
- 'VTOLMotorSW', 0,...
- 'VTOLMotorW', 0,...
- 'VTOLMotorNW', 0,...
- 'ChannelType', zeros(10,1),...
- 'ChannelAddr', zeros(10,1),...
- 'MotorsSpinWhileArmed', 0);
- ACTUATORSETTINGS_OBJID=4068955974;
- altholdsmoothedIdx = 0;
- AltHoldSmoothed=struct('timestamp', 0,...
- 'Altitude', 0,...
- 'Velocity', 0,...
- 'Accel', 0);
- ALTHOLDSMOOTHED_OBJID=734443986;
- altitudeholddesiredIdx = 0;
- AltitudeHoldDesired=struct('timestamp', 0,...
- 'Altitude', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0);
- ALTITUDEHOLDDESIRED_OBJID=1230744942;
- altitudeholdsettingsIdx = 0;
- AltitudeHoldSettings=struct('timestamp', 0,...
- 'Kp', 0,...
- 'Ki', 0,...
- 'Kd', 0,...
- 'Ka', 0,...
- 'PressureNoise', 0,...
- 'AccelNoise', 0,...
- 'AccelDrift', 0);
- ALTITUDEHOLDSETTINGS_OBJID=4274346818;
- attitudeactualIdx = 0;
- AttitudeActual=struct('timestamp', 0,...
- 'q1', 0,...
- 'q2', 0,...
- 'q3', 0,...
- 'q4', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0);
- ATTITUDEACTUAL_OBJID=869979622;
- attitudesettingsIdx = 0;
- AttitudeSettings=struct('timestamp', 0,...
- 'GyroGain', 0,...
- 'AccelKp', 0,...
- 'AccelKi', 0,...
- 'YawBiasRate', 0,...
- 'AccelBias', zeros(3,1),...
- 'GyroBias', zeros(3,1),...
- 'BoardRotation', zeros(3,1),...
- 'ZeroDuringArming', 0,...
- 'BiasCorrectGyro', 0,...
- 'TrimFlight', 0);
- ATTITUDESETTINGS_OBJID=3272064074;
- baroaltitudeIdx = 0;
- BaroAltitude=struct('timestamp', 0,...
- 'Altitude', 0,...
- 'Temperature', 0,...
- 'Pressure', 0);
- BAROALTITUDE_OBJID=2573348458;
- cameradesiredIdx = 0;
- CameraDesired=struct('timestamp', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0);
- CAMERADESIRED_OBJID=1394562126;
- camerastabsettingsIdx = 0;
- CameraStabSettings=struct('timestamp', 0,...
- 'MaxAxisLockRate', 0,...
- 'ResponseTime', zeros(3,1),...
- 'Input', zeros(3,1),...
- 'InputRange', zeros(3,1),...
- 'InputRate', zeros(3,1),...
- 'StabilizationMode', zeros(3,1),...
- 'OutputRange', zeros(3,1));
- CAMERASTABSETTINGS_OBJID=999677370;
- faultsettingsIdx = 0;
- FaultSettings=struct('timestamp', 0,...
- 'ActivateFault', 0);
- FAULTSETTINGS_OBJID=662223420;
- firmwareiapobjIdx = 0;
- FirmwareIAPObj=struct('timestamp', 0,...
- 'crc', 0,...
- 'Command', 0,...
- 'BoardRevision', 0,...
- 'Description', zeros(40,1),...
- 'CPUSerial', zeros(12,1),...
- 'BoardType', 0,...
- 'ArmReset', 0);
- FIRMWAREIAPOBJ_OBJID=1020132200;
- flightbatterysettingsIdx = 0;
- FlightBatterySettings=struct('timestamp', 0,...
- 'Capacity', 0,...
- 'VoltageThresholds', zeros(2,1),...
- 'SensorCalibrations', zeros(2,1),...
- 'Type', 0,...
- 'NbCells', 0,...
- 'SensorType', 0);
- FLIGHTBATTERYSETTINGS_OBJID=4050828056;
- flightbatterystateIdx = 0;
- FlightBatteryState=struct('timestamp', 0,...
- 'Voltage', 0,...
- 'Current', 0,...
- 'PeakCurrent', 0,...
- 'AvgCurrent', 0,...
- 'ConsumedEnergy', 0,...
- 'EstimatedFlightTime', 0);
- FLIGHTBATTERYSTATE_OBJID=146855766;
- flightplancontrolIdx = 0;
- FlightPlanControl=struct('timestamp', 0,...
- 'Command', 0);
- FLIGHTPLANCONTROL_OBJID=1407447424;
- flightplansettingsIdx = 0;
- FlightPlanSettings=struct('timestamp', 0,...
- 'Test', 0);
- FLIGHTPLANSETTINGS_OBJID=2464808822;
- flightplanstatusIdx = 0;
- FlightPlanStatus=struct('timestamp', 0,...
- 'ErrorFileID', 0,...
- 'ErrorLineNum', 0,...
- 'Debug', zeros(2,1),...
- 'Status', 0,...
- 'ErrorType', 0);
- FLIGHTPLANSTATUS_OBJID=570879558;
- flightstatusIdx = 0;
- FlightStatus=struct('timestamp', 0,...
- 'Armed', 0,...
- 'FlightMode', 0);
- FLIGHTSTATUS_OBJID=3886315226;
- flighttelemetrystatsIdx = 0;
- FlightTelemetryStats=struct('timestamp', 0,...
- 'TxDataRate', 0,...
- 'RxDataRate', 0,...
- 'TxFailures', 0,...
- 'RxFailures', 0,...
- 'TxRetries', 0,...
- 'Status', 0);
- FLIGHTTELEMETRYSTATS_OBJID=796797186;
- gcsreceiverIdx = 0;
- GCSReceiver=struct('timestamp', 0,...
- 'Channel', zeros(6,1));
- GCSRECEIVER_OBJID=3430820796;
- gcstelemetrystatsIdx = 0;
- GCSTelemetryStats=struct('timestamp', 0,...
- 'TxDataRate', 0,...
- 'RxDataRate', 0,...
- 'TxFailures', 0,...
- 'RxFailures', 0,...
- 'TxRetries', 0,...
- 'Status', 0);
- GCSTELEMETRYSTATS_OBJID=2881955652;
- gpspositionIdx = 0;
- GPSPosition=struct('timestamp', 0,...
- 'Latitude', 0,...
- 'Longitude', 0,...
- 'Altitude', 0,...
- 'GeoidSeparation', 0,...
- 'Heading', 0,...
- 'Groundspeed', 0,...
- 'PDOP', 0,...
- 'HDOP', 0,...
- 'VDOP', 0,...
- 'Status', 0,...
- 'Satellites', 0);
- GPSPOSITION_OBJID=3802342326;
- gpssatellitesIdx = 0;
- GPSSatellites=struct('timestamp', 0,...
- 'Elevation', zeros(16,1),...
- 'Azimuth', zeros(16,1),...
- 'SatsInView', 0,...
- 'PRN', zeros(16,1),...
- 'SNR', zeros(16,1));
- GPSSATELLITES_OBJID=153147800;
- gpstimeIdx = 0;
- GPSTime=struct('timestamp', 0,...
- 'Year', 0,...
- 'Month', 0,...
- 'Day', 0,...
- 'Hour', 0,...
- 'Minute', 0,...
- 'Second', 0);
- GPSTIME_OBJID=3561455748;
- guidancesettingsIdx = 0;
- GuidanceSettings=struct('timestamp', 0,...
- 'HorizontalPosPI', zeros(3,1),...
- 'HorizontalVelPID', zeros(4,1),...
- 'VerticalPosPI', zeros(3,1),...
- 'VerticalVelPID', zeros(4,1),...
- 'MaxRollPitch', 0,...
- 'UpdatePeriod', 0,...
- 'HorizontalVelMax', 0,...
- 'VerticalVelMax', 0,...
- 'GuidanceMode', 0,...
- 'ThrottleControl', 0);
- GUIDANCESETTINGS_OBJID=1856479156;
- gyrosIdx = 0;
- Gyros=struct('timestamp', 0,...
- 'x', 0,...
- 'y', 0,...
- 'z', 0,...
- 'temperature', 0);
- GYROS_OBJID=69372662;
- gyrosbiasIdx = 0;
- GyrosBias=struct('timestamp', 0,...
- 'x', 0,...
- 'y', 0,...
- 'z', 0);
- GYROSBIAS_OBJID=3837196672;
- homelocationIdx = 0;
- HomeLocation=struct('timestamp', 0,...
- 'Latitude', 0,...
- 'Longitude', 0,...
- 'Altitude', 0,...
- 'ECEF', zeros(3,1),...
- 'RNE', zeros(9,1),...
- 'Be', zeros(3,1),...
- 'g_e', 0,...
- 'Set', 0);
- HOMELOCATION_OBJID=1538502396;
- hwsettingsIdx = 0;
- HwSettings=struct('timestamp', 0,...
- 'CC_RcvrPort', 0,...
- 'CC_MainPort', 0,...
- 'CC_FlexiPort', 0,...
- 'OP_RcvrPort', 0,...
- 'OP_MainPort', 0,...
- 'OP_FlexiPort', 0,...
- 'TelemetrySpeed', 0,...
- 'GPSSpeed', 0,...
- 'ComUsbBridgeSpeed', 0,...
- 'USB_DeviceType', 0,...
- 'USB_HIDPort', 0,...
- 'USB_VCPPort', 0,...
- 'OptionalModules', zeros(5,1),...
- 'DSMxBind', 0);
- HWSETTINGS_OBJID=786847578;
- i2cstatsIdx = 0;
- I2CStats=struct('timestamp', 0,...
- 'evirq_log', zeros(5,1),...
- 'erirq_log', zeros(5,1),...
- 'event_errors', 0,...
- 'fsm_errors', 0,...
- 'irq_errors', 0,...
- 'nacks', 0,...
- 'timeouts', 0,...
- 'last_error_type', 0,...
- 'event_log', zeros(5,1),...
- 'state_log', zeros(5,1));
- I2CSTATS_OBJID=3071574590;
- magnetometerIdx = 0;
- Magnetometer=struct('timestamp', 0,...
- 'x', 0,...
- 'y', 0,...
- 'z', 0);
- MAGNETOMETER_OBJID=2168149470;
- manualcontrolcommandIdx = 0;
- ManualControlCommand=struct('timestamp', 0,...
- 'Throttle', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0,...
- 'Collective', 0,...
- 'Channel', zeros(9,1),...
- 'Connected', 0);
- MANUALCONTROLCOMMAND_OBJID=511886034;
- manualcontrolsettingsIdx = 0;
- ManualControlSettings=struct('timestamp', 0,...
- 'ChannelMin', zeros(9,1),...
- 'ChannelNeutral', zeros(9,1),...
- 'ChannelMax', zeros(9,1),...
- 'ArmedTimeout', 0,...
- 'ChannelGroups', zeros(9,1),...
- 'ChannelNumber', zeros(9,1),...
- 'Arming', 0,...
- 'Stabilization1Settings', zeros(3,1),...
- 'Stabilization2Settings', zeros(3,1),...
- 'Stabilization3Settings', zeros(3,1),...
- 'FlightModePosition', zeros(3,1));
- MANUALCONTROLSETTINGS_OBJID=2139802646;
- mixersettingsIdx = 0;
- MixerSettings=struct('timestamp', 0,...
- 'MaxAccel', 0,...
- 'FeedForward', 0,...
- 'AccelTime', 0,...
- 'DecelTime', 0,...
- 'ThrottleCurve1', zeros(5,1),...
- 'ThrottleCurve2', zeros(5,1),...
- 'Curve2Source', 0,...
- 'Mixer1Type', 0,...
- 'Mixer1Vector', zeros(5,1),...
- 'Mixer2Type', 0,...
- 'Mixer2Vector', zeros(5,1),...
- 'Mixer3Type', 0,...
- 'Mixer3Vector', zeros(5,1),...
- 'Mixer4Type', 0,...
- 'Mixer4Vector', zeros(5,1),...
- 'Mixer5Type', 0,...
- 'Mixer5Vector', zeros(5,1),...
- 'Mixer6Type', 0,...
- 'Mixer6Vector', zeros(5,1),...
- 'Mixer7Type', 0,...
- 'Mixer7Vector', zeros(5,1),...
- 'Mixer8Type', 0,...
- 'Mixer8Vector', zeros(5,1),...
- 'Mixer9Type', 0,...
- 'Mixer9Vector', zeros(5,1),...
- 'Mixer10Type', 0,...
- 'Mixer10Vector', zeros(5,1));
- MIXERSETTINGS_OBJID=1561777860;
- mixerstatusIdx = 0;
- MixerStatus=struct('timestamp', 0,...
- 'Mixer1', 0,...
- 'Mixer2', 0,...
- 'Mixer3', 0,...
- 'Mixer4', 0,...
- 'Mixer5', 0,...
- 'Mixer6', 0,...
- 'Mixer7', 0,...
- 'Mixer8', 0);
- MIXERSTATUS_OBJID=298824934;
- nedaccelIdx = 0;
- NedAccel=struct('timestamp', 0,...
- 'North', 0,...
- 'East', 0,...
- 'Down', 0);
- NEDACCEL_OBJID=2088721344;
- objectpersistenceIdx = 0;
- ObjectPersistence=struct('timestamp', 0,...
- 'ObjectID', 0,...
- 'InstanceID', 0,...
- 'Operation', 0,...
- 'Selection', 0);
- OBJECTPERSISTENCE_OBJID=4137343160;
- overosyncstatsIdx = 0;
- OveroSyncStats=struct('timestamp', 0,...
- 'Send', 0,...
- 'Received', 0,...
- 'DroppedUpdates', 0,...
- 'Connected', 0);
- OVEROSYNCSTATS_OBJID=948201656;
- positionactualIdx = 0;
- PositionActual=struct('timestamp', 0,...
- 'North', 0,...
- 'East', 0,...
- 'Down', 0);
- POSITIONACTUAL_OBJID=4204670274;
- positiondesiredIdx = 0;
- PositionDesired=struct('timestamp', 0,...
- 'North', 0,...
- 'East', 0,...
- 'Down', 0);
- POSITIONDESIRED_OBJID=2005777956;
- ratedesiredIdx = 0;
- RateDesired=struct('timestamp', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0);
- RATEDESIRED_OBJID=216582182;
- receiveractivityIdx = 0;
- ReceiverActivity=struct('timestamp', 0,...
- 'ActiveGroup', 0,...
- 'ActiveChannel', 0);
- RECEIVERACTIVITY_OBJID=511464410;
- revocalibrationIdx = 0;
- RevoCalibration=struct('timestamp', 0,...
- 'accel_bias', zeros(3,1),...
- 'accel_scale', zeros(3,1),...
- 'accel_var', zeros(3,1),...
- 'gyro_bias', zeros(3,1),...
- 'gyro_scale', zeros(3,1),...
- 'gyro_var', zeros(3,1),...
- 'gyro_tempcoeff', zeros(3,1),...
- 'mag_bias', zeros(3,1),...
- 'mag_scale', zeros(3,1),...
- 'mag_var', zeros(3,1),...
- 'BiasCorrectedRaw', 0);
- REVOCALIBRATION_OBJID=3261937586;
- sonaraltitudeIdx = 0;
- SonarAltitude=struct('timestamp', 0,...
- 'Altitude', 0);
- SONARALTITUDE_OBJID=1817840828;
- stabilizationdesiredIdx = 0;
- StabilizationDesired=struct('timestamp', 0,...
- 'Roll', 0,...
- 'Pitch', 0,...
- 'Yaw', 0,...
- 'Throttle', 0,...
- 'StabilizationMode', zeros(3,1));
- STABILIZATIONDESIRED_OBJID=3683646524;
- stabilizationsettingsIdx = 0;
- StabilizationSettings=struct('timestamp', 0,...
- 'ManualRate', zeros(3,1),...
- 'MaximumRate', zeros(3,1),...
- 'RollRatePID', zeros(4,1),...
- 'PitchRatePID', zeros(4,1),...
- 'YawRatePID', zeros(4,1),...
- 'RollPI', zeros(3,1),...
- 'PitchPI', zeros(3,1),...
- 'YawPI', zeros(3,1),...
- 'GyroTau', 0,...
- 'WeakLevelingKp', 0,...
- 'RollMax', 0,...
- 'PitchMax', 0,...
- 'YawMax', 0,...
- 'MaxAxisLock', 0,...
- 'MaxAxisLockRate', 0,...
- 'MaxWeakLevelingRate', 0,...
- 'LowThrottleZeroIntegral', 0);
- STABILIZATIONSETTINGS_OBJID=1601750302;
- systemalarmsIdx = 0;
- SystemAlarms=struct('timestamp', 0,...
- 'Alarm', zeros(18,1));
- SYSTEMALARMS_OBJID=164088830;
- systemsettingsIdx = 0;
- SystemSettings=struct('timestamp', 0,...
- 'GUIConfigData', zeros(2,1),...
- 'AirframeType', 0);
- SYSTEMSETTINGS_OBJID=817716604;
- systemstatsIdx = 0;
- SystemStats=struct('timestamp', 0,...
- 'FlightTime', 0,...
- 'HeapRemaining', 0,...
- 'IRQStackRemaining', 0,...
- 'CPULoad', 0,...
- 'CPUTemp', 0);
- SYSTEMSTATS_OBJID=3591414000;
- taskinfoIdx = 0;
- TaskInfo=struct('timestamp', 0,...
- 'StackRemaining', zeros(17,1),...
- 'Running', zeros(17,1),...
- 'RunningTime', zeros(17,1));
- TASKINFO_OBJID=1360472970;
- velocityactualIdx = 0;
- VelocityActual=struct('timestamp', 0,...
- 'North', 0,...
- 'East', 0,...
- 'Down', 0);
- VELOCITYACTUAL_OBJID=1510536730;
- velocitydesiredIdx = 0;
- VelocityDesired=struct('timestamp', 0,...
- 'North', 0,...
- 'East', 0,...
- 'Down', 0);
- VELOCITYDESIRED_OBJID=2660526482;
- watchdogstatusIdx = 0;
- WatchdogStatus=struct('timestamp', 0,...
- 'BootupFlags', 0,...
- 'ActiveFlags', 0);
- WATCHDOGSTATUS_OBJID=2718431868;
- fid = fopen(logfile);
- correctMsgByte=hex2dec('20');
- correctSyncByte=hex2dec('3C');
- % Parse log file, entry by entry
- prebuf = fread(fid, 12, 'uint8');
- log_size = dir(logfile);
- log_size = log_size.bytes;
- last_print = 0;
- startTime=clock;
- while (1)
- if (feof(fid)); break; end
- %% Read message header
- % get sync field (0x3C, 1 byte)
- sync = fread(fid, 1, 'uint8');
- if sync ~= correctSyncByte
- prebuf = [prebuf(2:end); sync];
- wrongSyncByte=wrongSyncByte+1;
- % disp ('Wrong sync byte');
- continue
- end
- %% Process header if we are aligned
- timestamp = typecast(uint8(prebuf(1:4)), 'uint32');
- datasize = typecast(uint8(prebuf(5:12)), 'uint64');
- % get msg type (quint8 1 byte ) should be 0x20, ignore the rest?
- msgType = fread(fid, 1, 'uint8');
- if msgType ~= correctMsgByte
- % disp ('Wrong msgType');
- wrongMessageByte=wrongMessageByte+1;
- continue
- end
- % get msg size (quint16 2 bytes) excludes crc, include msg header and data payload
- msgSize = fread(fid, 1, 'uint16'); %#ok<NASGU>
- % get obj id (quint32 4 bytes)
- objID = fread(fid, 1, 'uint32');
- if (isempty(objID)) %End of file
- break;
- end
- %% Read object
- try
- switch objID
- case ACCELS_OBJID
- accelsIdx = accelsIdx + 1;
- Accels= ReadAccelsObject(fid, timestamp, checkCRC, Accels, accelsIdx);
- if accelsIdx >= length(Accels.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(Accels);
- for i=1:length(FieldNames) %Grow structure
- Accels.(FieldNames{i})(:,accelsIdx*2+1) = 0;
- end;
- end
- case ACCESSORYDESIRED_OBJID
- accessorydesiredIdx = accessorydesiredIdx + 1;
- AccessoryDesired= ReadAccessoryDesiredObject(fid, timestamp, checkCRC, AccessoryDesired, accessorydesiredIdx);
- if accessorydesiredIdx >= length(AccessoryDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(AccessoryDesired);
- for i=1:length(FieldNames) %Grow structure
- AccessoryDesired.(FieldNames{i})(:,accessorydesiredIdx*2+1) = 0;
- end;
- end
- case ACTUATORCOMMAND_OBJID
- actuatorcommandIdx = actuatorcommandIdx + 1;
- ActuatorCommand= ReadActuatorCommandObject(fid, timestamp, checkCRC, ActuatorCommand, actuatorcommandIdx);
- if actuatorcommandIdx >= length(ActuatorCommand.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ActuatorCommand);
- for i=1:length(FieldNames) %Grow structure
- ActuatorCommand.(FieldNames{i})(:,actuatorcommandIdx*2+1) = 0;
- end;
- end
- case ACTUATORDESIRED_OBJID
- actuatordesiredIdx = actuatordesiredIdx + 1;
- ActuatorDesired= ReadActuatorDesiredObject(fid, timestamp, checkCRC, ActuatorDesired, actuatordesiredIdx);
- if actuatordesiredIdx >= length(ActuatorDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ActuatorDesired);
- for i=1:length(FieldNames) %Grow structure
- ActuatorDesired.(FieldNames{i})(:,actuatordesiredIdx*2+1) = 0;
- end;
- end
- case ACTUATORSETTINGS_OBJID
- actuatorsettingsIdx = actuatorsettingsIdx + 1;
- ActuatorSettings= ReadActuatorSettingsObject(fid, timestamp, checkCRC, ActuatorSettings, actuatorsettingsIdx);
- if actuatorsettingsIdx >= length(ActuatorSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ActuatorSettings);
- for i=1:length(FieldNames) %Grow structure
- ActuatorSettings.(FieldNames{i})(:,actuatorsettingsIdx*2+1) = 0;
- end;
- end
- case ALTHOLDSMOOTHED_OBJID
- altholdsmoothedIdx = altholdsmoothedIdx + 1;
- AltHoldSmoothed= ReadAltHoldSmoothedObject(fid, timestamp, checkCRC, AltHoldSmoothed, altholdsmoothedIdx);
- if altholdsmoothedIdx >= length(AltHoldSmoothed.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(AltHoldSmoothed);
- for i=1:length(FieldNames) %Grow structure
- AltHoldSmoothed.(FieldNames{i})(:,altholdsmoothedIdx*2+1) = 0;
- end;
- end
- case ALTITUDEHOLDDESIRED_OBJID
- altitudeholddesiredIdx = altitudeholddesiredIdx + 1;
- AltitudeHoldDesired= ReadAltitudeHoldDesiredObject(fid, timestamp, checkCRC, AltitudeHoldDesired, altitudeholddesiredIdx);
- if altitudeholddesiredIdx >= length(AltitudeHoldDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(AltitudeHoldDesired);
- for i=1:length(FieldNames) %Grow structure
- AltitudeHoldDesired.(FieldNames{i})(:,altitudeholddesiredIdx*2+1) = 0;
- end;
- end
- case ALTITUDEHOLDSETTINGS_OBJID
- altitudeholdsettingsIdx = altitudeholdsettingsIdx + 1;
- AltitudeHoldSettings= ReadAltitudeHoldSettingsObject(fid, timestamp, checkCRC, AltitudeHoldSettings, altitudeholdsettingsIdx);
- if altitudeholdsettingsIdx >= length(AltitudeHoldSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(AltitudeHoldSettings);
- for i=1:length(FieldNames) %Grow structure
- AltitudeHoldSettings.(FieldNames{i})(:,altitudeholdsettingsIdx*2+1) = 0;
- end;
- end
- case ATTITUDEACTUAL_OBJID
- attitudeactualIdx = attitudeactualIdx + 1;
- AttitudeActual= ReadAttitudeActualObject(fid, timestamp, checkCRC, AttitudeActual, attitudeactualIdx);
- if attitudeactualIdx >= length(AttitudeActual.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(AttitudeActual);
- for i=1:length(FieldNames) %Grow structure
- AttitudeActual.(FieldNames{i})(:,attitudeactualIdx*2+1) = 0;
- end;
- end
- case ATTITUDESETTINGS_OBJID
- attitudesettingsIdx = attitudesettingsIdx + 1;
- AttitudeSettings= ReadAttitudeSettingsObject(fid, timestamp, checkCRC, AttitudeSettings, attitudesettingsIdx);
- if attitudesettingsIdx >= length(AttitudeSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(AttitudeSettings);
- for i=1:length(FieldNames) %Grow structure
- AttitudeSettings.(FieldNames{i})(:,attitudesettingsIdx*2+1) = 0;
- end;
- end
- case BAROALTITUDE_OBJID
- baroaltitudeIdx = baroaltitudeIdx + 1;
- BaroAltitude= ReadBaroAltitudeObject(fid, timestamp, checkCRC, BaroAltitude, baroaltitudeIdx);
- if baroaltitudeIdx >= length(BaroAltitude.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(BaroAltitude);
- for i=1:length(FieldNames) %Grow structure
- BaroAltitude.(FieldNames{i})(:,baroaltitudeIdx*2+1) = 0;
- end;
- end
- case CAMERADESIRED_OBJID
- cameradesiredIdx = cameradesiredIdx + 1;
- CameraDesired= ReadCameraDesiredObject(fid, timestamp, checkCRC, CameraDesired, cameradesiredIdx);
- if cameradesiredIdx >= length(CameraDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(CameraDesired);
- for i=1:length(FieldNames) %Grow structure
- CameraDesired.(FieldNames{i})(:,cameradesiredIdx*2+1) = 0;
- end;
- end
- case CAMERASTABSETTINGS_OBJID
- camerastabsettingsIdx = camerastabsettingsIdx + 1;
- CameraStabSettings= ReadCameraStabSettingsObject(fid, timestamp, checkCRC, CameraStabSettings, camerastabsettingsIdx);
- if camerastabsettingsIdx >= length(CameraStabSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(CameraStabSettings);
- for i=1:length(FieldNames) %Grow structure
- CameraStabSettings.(FieldNames{i})(:,camerastabsettingsIdx*2+1) = 0;
- end;
- end
- case FAULTSETTINGS_OBJID
- faultsettingsIdx = faultsettingsIdx + 1;
- FaultSettings= ReadFaultSettingsObject(fid, timestamp, checkCRC, FaultSettings, faultsettingsIdx);
- if faultsettingsIdx >= length(FaultSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FaultSettings);
- for i=1:length(FieldNames) %Grow structure
- FaultSettings.(FieldNames{i})(:,faultsettingsIdx*2+1) = 0;
- end;
- end
- case FIRMWAREIAPOBJ_OBJID
- firmwareiapobjIdx = firmwareiapobjIdx + 1;
- FirmwareIAPObj= ReadFirmwareIAPObjObject(fid, timestamp, checkCRC, FirmwareIAPObj, firmwareiapobjIdx);
- if firmwareiapobjIdx >= length(FirmwareIAPObj.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FirmwareIAPObj);
- for i=1:length(FieldNames) %Grow structure
- FirmwareIAPObj.(FieldNames{i})(:,firmwareiapobjIdx*2+1) = 0;
- end;
- end
- case FLIGHTBATTERYSETTINGS_OBJID
- flightbatterysettingsIdx = flightbatterysettingsIdx + 1;
- FlightBatterySettings= ReadFlightBatterySettingsObject(fid, timestamp, checkCRC, FlightBatterySettings, flightbatterysettingsIdx);
- if flightbatterysettingsIdx >= length(FlightBatterySettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightBatterySettings);
- for i=1:length(FieldNames) %Grow structure
- FlightBatterySettings.(FieldNames{i})(:,flightbatterysettingsIdx*2+1) = 0;
- end;
- end
- case FLIGHTBATTERYSTATE_OBJID
- flightbatterystateIdx = flightbatterystateIdx + 1;
- FlightBatteryState= ReadFlightBatteryStateObject(fid, timestamp, checkCRC, FlightBatteryState, flightbatterystateIdx);
- if flightbatterystateIdx >= length(FlightBatteryState.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightBatteryState);
- for i=1:length(FieldNames) %Grow structure
- FlightBatteryState.(FieldNames{i})(:,flightbatterystateIdx*2+1) = 0;
- end;
- end
- case FLIGHTPLANCONTROL_OBJID
- flightplancontrolIdx = flightplancontrolIdx + 1;
- FlightPlanControl= ReadFlightPlanControlObject(fid, timestamp, checkCRC, FlightPlanControl, flightplancontrolIdx);
- if flightplancontrolIdx >= length(FlightPlanControl.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightPlanControl);
- for i=1:length(FieldNames) %Grow structure
- FlightPlanControl.(FieldNames{i})(:,flightplancontrolIdx*2+1) = 0;
- end;
- end
- case FLIGHTPLANSETTINGS_OBJID
- flightplansettingsIdx = flightplansettingsIdx + 1;
- FlightPlanSettings= ReadFlightPlanSettingsObject(fid, timestamp, checkCRC, FlightPlanSettings, flightplansettingsIdx);
- if flightplansettingsIdx >= length(FlightPlanSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightPlanSettings);
- for i=1:length(FieldNames) %Grow structure
- FlightPlanSettings.(FieldNames{i})(:,flightplansettingsIdx*2+1) = 0;
- end;
- end
- case FLIGHTPLANSTATUS_OBJID
- flightplanstatusIdx = flightplanstatusIdx + 1;
- FlightPlanStatus= ReadFlightPlanStatusObject(fid, timestamp, checkCRC, FlightPlanStatus, flightplanstatusIdx);
- if flightplanstatusIdx >= length(FlightPlanStatus.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightPlanStatus);
- for i=1:length(FieldNames) %Grow structure
- FlightPlanStatus.(FieldNames{i})(:,flightplanstatusIdx*2+1) = 0;
- end;
- end
- case FLIGHTSTATUS_OBJID
- flightstatusIdx = flightstatusIdx + 1;
- FlightStatus= ReadFlightStatusObject(fid, timestamp, checkCRC, FlightStatus, flightstatusIdx);
- if flightstatusIdx >= length(FlightStatus.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightStatus);
- for i=1:length(FieldNames) %Grow structure
- FlightStatus.(FieldNames{i})(:,flightstatusIdx*2+1) = 0;
- end;
- end
- case FLIGHTTELEMETRYSTATS_OBJID
- flighttelemetrystatsIdx = flighttelemetrystatsIdx + 1;
- FlightTelemetryStats= ReadFlightTelemetryStatsObject(fid, timestamp, checkCRC, FlightTelemetryStats, flighttelemetrystatsIdx);
- if flighttelemetrystatsIdx >= length(FlightTelemetryStats.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(FlightTelemetryStats);
- for i=1:length(FieldNames) %Grow structure
- FlightTelemetryStats.(FieldNames{i})(:,flighttelemetrystatsIdx*2+1) = 0;
- end;
- end
- case GCSRECEIVER_OBJID
- gcsreceiverIdx = gcsreceiverIdx + 1;
- GCSReceiver= ReadGCSReceiverObject(fid, timestamp, checkCRC, GCSReceiver, gcsreceiverIdx);
- if gcsreceiverIdx >= length(GCSReceiver.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GCSReceiver);
- for i=1:length(FieldNames) %Grow structure
- GCSReceiver.(FieldNames{i})(:,gcsreceiverIdx*2+1) = 0;
- end;
- end
- case GCSTELEMETRYSTATS_OBJID
- gcstelemetrystatsIdx = gcstelemetrystatsIdx + 1;
- GCSTelemetryStats= ReadGCSTelemetryStatsObject(fid, timestamp, checkCRC, GCSTelemetryStats, gcstelemetrystatsIdx);
- if gcstelemetrystatsIdx >= length(GCSTelemetryStats.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GCSTelemetryStats);
- for i=1:length(FieldNames) %Grow structure
- GCSTelemetryStats.(FieldNames{i})(:,gcstelemetrystatsIdx*2+1) = 0;
- end;
- end
- case GPSPOSITION_OBJID
- gpspositionIdx = gpspositionIdx + 1;
- GPSPosition= ReadGPSPositionObject(fid, timestamp, checkCRC, GPSPosition, gpspositionIdx);
- if gpspositionIdx >= length(GPSPosition.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GPSPosition);
- for i=1:length(FieldNames) %Grow structure
- GPSPosition.(FieldNames{i})(:,gpspositionIdx*2+1) = 0;
- end;
- end
- case GPSSATELLITES_OBJID
- gpssatellitesIdx = gpssatellitesIdx + 1;
- GPSSatellites= ReadGPSSatellitesObject(fid, timestamp, checkCRC, GPSSatellites, gpssatellitesIdx);
- if gpssatellitesIdx >= length(GPSSatellites.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GPSSatellites);
- for i=1:length(FieldNames) %Grow structure
- GPSSatellites.(FieldNames{i})(:,gpssatellitesIdx*2+1) = 0;
- end;
- end
- case GPSTIME_OBJID
- gpstimeIdx = gpstimeIdx + 1;
- GPSTime= ReadGPSTimeObject(fid, timestamp, checkCRC, GPSTime, gpstimeIdx);
- if gpstimeIdx >= length(GPSTime.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GPSTime);
- for i=1:length(FieldNames) %Grow structure
- GPSTime.(FieldNames{i})(:,gpstimeIdx*2+1) = 0;
- end;
- end
- case GUIDANCESETTINGS_OBJID
- guidancesettingsIdx = guidancesettingsIdx + 1;
- GuidanceSettings= ReadGuidanceSettingsObject(fid, timestamp, checkCRC, GuidanceSettings, guidancesettingsIdx);
- if guidancesettingsIdx >= length(GuidanceSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GuidanceSettings);
- for i=1:length(FieldNames) %Grow structure
- GuidanceSettings.(FieldNames{i})(:,guidancesettingsIdx*2+1) = 0;
- end;
- end
- case GYROS_OBJID
- gyrosIdx = gyrosIdx + 1;
- Gyros= ReadGyrosObject(fid, timestamp, checkCRC, Gyros, gyrosIdx);
- if gyrosIdx >= length(Gyros.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(Gyros);
- for i=1:length(FieldNames) %Grow structure
- Gyros.(FieldNames{i})(:,gyrosIdx*2+1) = 0;
- end;
- end
- case GYROSBIAS_OBJID
- gyrosbiasIdx = gyrosbiasIdx + 1;
- GyrosBias= ReadGyrosBiasObject(fid, timestamp, checkCRC, GyrosBias, gyrosbiasIdx);
- if gyrosbiasIdx >= length(GyrosBias.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(GyrosBias);
- for i=1:length(FieldNames) %Grow structure
- GyrosBias.(FieldNames{i})(:,gyrosbiasIdx*2+1) = 0;
- end;
- end
- case HOMELOCATION_OBJID
- homelocationIdx = homelocationIdx + 1;
- HomeLocation= ReadHomeLocationObject(fid, timestamp, checkCRC, HomeLocation, homelocationIdx);
- if homelocationIdx >= length(HomeLocation.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(HomeLocation);
- for i=1:length(FieldNames) %Grow structure
- HomeLocation.(FieldNames{i})(:,homelocationIdx*2+1) = 0;
- end;
- end
- case HWSETTINGS_OBJID
- hwsettingsIdx = hwsettingsIdx + 1;
- HwSettings= ReadHwSettingsObject(fid, timestamp, checkCRC, HwSettings, hwsettingsIdx);
- if hwsettingsIdx >= length(HwSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(HwSettings);
- for i=1:length(FieldNames) %Grow structure
- HwSettings.(FieldNames{i})(:,hwsettingsIdx*2+1) = 0;
- end;
- end
- case I2CSTATS_OBJID
- i2cstatsIdx = i2cstatsIdx + 1;
- I2CStats= ReadI2CStatsObject(fid, timestamp, checkCRC, I2CStats, i2cstatsIdx);
- if i2cstatsIdx >= length(I2CStats.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(I2CStats);
- for i=1:length(FieldNames) %Grow structure
- I2CStats.(FieldNames{i})(:,i2cstatsIdx*2+1) = 0;
- end;
- end
- case MAGNETOMETER_OBJID
- magnetometerIdx = magnetometerIdx + 1;
- Magnetometer= ReadMagnetometerObject(fid, timestamp, checkCRC, Magnetometer, magnetometerIdx);
- if magnetometerIdx >= length(Magnetometer.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(Magnetometer);
- for i=1:length(FieldNames) %Grow structure
- Magnetometer.(FieldNames{i})(:,magnetometerIdx*2+1) = 0;
- end;
- end
- case MANUALCONTROLCOMMAND_OBJID
- manualcontrolcommandIdx = manualcontrolcommandIdx + 1;
- ManualControlCommand= ReadManualControlCommandObject(fid, timestamp, checkCRC, ManualControlCommand, manualcontrolcommandIdx);
- if manualcontrolcommandIdx >= length(ManualControlCommand.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ManualControlCommand);
- for i=1:length(FieldNames) %Grow structure
- ManualControlCommand.(FieldNames{i})(:,manualcontrolcommandIdx*2+1) = 0;
- end;
- end
- case MANUALCONTROLSETTINGS_OBJID
- manualcontrolsettingsIdx = manualcontrolsettingsIdx + 1;
- ManualControlSettings= ReadManualControlSettingsObject(fid, timestamp, checkCRC, ManualControlSettings, manualcontrolsettingsIdx);
- if manualcontrolsettingsIdx >= length(ManualControlSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ManualControlSettings);
- for i=1:length(FieldNames) %Grow structure
- ManualControlSettings.(FieldNames{i})(:,manualcontrolsettingsIdx*2+1) = 0;
- end;
- end
- case MIXERSETTINGS_OBJID
- mixersettingsIdx = mixersettingsIdx + 1;
- MixerSettings= ReadMixerSettingsObject(fid, timestamp, checkCRC, MixerSettings, mixersettingsIdx);
- if mixersettingsIdx >= length(MixerSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(MixerSettings);
- for i=1:length(FieldNames) %Grow structure
- MixerSettings.(FieldNames{i})(:,mixersettingsIdx*2+1) = 0;
- end;
- end
- case MIXERSTATUS_OBJID
- mixerstatusIdx = mixerstatusIdx + 1;
- MixerStatus= ReadMixerStatusObject(fid, timestamp, checkCRC, MixerStatus, mixerstatusIdx);
- if mixerstatusIdx >= length(MixerStatus.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(MixerStatus);
- for i=1:length(FieldNames) %Grow structure
- MixerStatus.(FieldNames{i})(:,mixerstatusIdx*2+1) = 0;
- end;
- end
- case NEDACCEL_OBJID
- nedaccelIdx = nedaccelIdx + 1;
- NedAccel= ReadNedAccelObject(fid, timestamp, checkCRC, NedAccel, nedaccelIdx);
- if nedaccelIdx >= length(NedAccel.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(NedAccel);
- for i=1:length(FieldNames) %Grow structure
- NedAccel.(FieldNames{i})(:,nedaccelIdx*2+1) = 0;
- end;
- end
- case OBJECTPERSISTENCE_OBJID
- objectpersistenceIdx = objectpersistenceIdx + 1;
- ObjectPersistence= ReadObjectPersistenceObject(fid, timestamp, checkCRC, ObjectPersistence, objectpersistenceIdx);
- if objectpersistenceIdx >= length(ObjectPersistence.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ObjectPersistence);
- for i=1:length(FieldNames) %Grow structure
- ObjectPersistence.(FieldNames{i})(:,objectpersistenceIdx*2+1) = 0;
- end;
- end
- case OVEROSYNCSTATS_OBJID
- overosyncstatsIdx = overosyncstatsIdx + 1;
- OveroSyncStats= ReadOveroSyncStatsObject(fid, timestamp, checkCRC, OveroSyncStats, overosyncstatsIdx);
- if overosyncstatsIdx >= length(OveroSyncStats.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(OveroSyncStats);
- for i=1:length(FieldNames) %Grow structure
- OveroSyncStats.(FieldNames{i})(:,overosyncstatsIdx*2+1) = 0;
- end;
- end
- case POSITIONACTUAL_OBJID
- positionactualIdx = positionactualIdx + 1;
- PositionActual= ReadPositionActualObject(fid, timestamp, checkCRC, PositionActual, positionactualIdx);
- if positionactualIdx >= length(PositionActual.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(PositionActual);
- for i=1:length(FieldNames) %Grow structure
- PositionActual.(FieldNames{i})(:,positionactualIdx*2+1) = 0;
- end;
- end
- case POSITIONDESIRED_OBJID
- positiondesiredIdx = positiondesiredIdx + 1;
- PositionDesired= ReadPositionDesiredObject(fid, timestamp, checkCRC, PositionDesired, positiondesiredIdx);
- if positiondesiredIdx >= length(PositionDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(PositionDesired);
- for i=1:length(FieldNames) %Grow structure
- PositionDesired.(FieldNames{i})(:,positiondesiredIdx*2+1) = 0;
- end;
- end
- case RATEDESIRED_OBJID
- ratedesiredIdx = ratedesiredIdx + 1;
- RateDesired= ReadRateDesiredObject(fid, timestamp, checkCRC, RateDesired, ratedesiredIdx);
- if ratedesiredIdx >= length(RateDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(RateDesired);
- for i=1:length(FieldNames) %Grow structure
- RateDesired.(FieldNames{i})(:,ratedesiredIdx*2+1) = 0;
- end;
- end
- case RECEIVERACTIVITY_OBJID
- receiveractivityIdx = receiveractivityIdx + 1;
- ReceiverActivity= ReadReceiverActivityObject(fid, timestamp, checkCRC, ReceiverActivity, receiveractivityIdx);
- if receiveractivityIdx >= length(ReceiverActivity.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(ReceiverActivity);
- for i=1:length(FieldNames) %Grow structure
- ReceiverActivity.(FieldNames{i})(:,receiveractivityIdx*2+1) = 0;
- end;
- end
- case REVOCALIBRATION_OBJID
- revocalibrationIdx = revocalibrationIdx + 1;
- RevoCalibration= ReadRevoCalibrationObject(fid, timestamp, checkCRC, RevoCalibration, revocalibrationIdx);
- if revocalibrationIdx >= length(RevoCalibration.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(RevoCalibration);
- for i=1:length(FieldNames) %Grow structure
- RevoCalibration.(FieldNames{i})(:,revocalibrationIdx*2+1) = 0;
- end;
- end
- case SONARALTITUDE_OBJID
- sonaraltitudeIdx = sonaraltitudeIdx + 1;
- SonarAltitude= ReadSonarAltitudeObject(fid, timestamp, checkCRC, SonarAltitude, sonaraltitudeIdx);
- if sonaraltitudeIdx >= length(SonarAltitude.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(SonarAltitude);
- for i=1:length(FieldNames) %Grow structure
- SonarAltitude.(FieldNames{i})(:,sonaraltitudeIdx*2+1) = 0;
- end;
- end
- case STABILIZATIONDESIRED_OBJID
- stabilizationdesiredIdx = stabilizationdesiredIdx + 1;
- StabilizationDesired= ReadStabilizationDesiredObject(fid, timestamp, checkCRC, StabilizationDesired, stabilizationdesiredIdx);
- if stabilizationdesiredIdx >= length(StabilizationDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(StabilizationDesired);
- for i=1:length(FieldNames) %Grow structure
- StabilizationDesired.(FieldNames{i})(:,stabilizationdesiredIdx*2+1) = 0;
- end;
- end
- case STABILIZATIONSETTINGS_OBJID
- stabilizationsettingsIdx = stabilizationsettingsIdx + 1;
- StabilizationSettings= ReadStabilizationSettingsObject(fid, timestamp, checkCRC, StabilizationSettings, stabilizationsettingsIdx);
- if stabilizationsettingsIdx >= length(StabilizationSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(StabilizationSettings);
- for i=1:length(FieldNames) %Grow structure
- StabilizationSettings.(FieldNames{i})(:,stabilizationsettingsIdx*2+1) = 0;
- end;
- end
- case SYSTEMALARMS_OBJID
- systemalarmsIdx = systemalarmsIdx + 1;
- SystemAlarms= ReadSystemAlarmsObject(fid, timestamp, checkCRC, SystemAlarms, systemalarmsIdx);
- if systemalarmsIdx >= length(SystemAlarms.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(SystemAlarms);
- for i=1:length(FieldNames) %Grow structure
- SystemAlarms.(FieldNames{i})(:,systemalarmsIdx*2+1) = 0;
- end;
- end
- case SYSTEMSETTINGS_OBJID
- systemsettingsIdx = systemsettingsIdx + 1;
- SystemSettings= ReadSystemSettingsObject(fid, timestamp, checkCRC, SystemSettings, systemsettingsIdx);
- if systemsettingsIdx >= length(SystemSettings.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(SystemSettings);
- for i=1:length(FieldNames) %Grow structure
- SystemSettings.(FieldNames{i})(:,systemsettingsIdx*2+1) = 0;
- end;
- end
- case SYSTEMSTATS_OBJID
- systemstatsIdx = systemstatsIdx + 1;
- SystemStats= ReadSystemStatsObject(fid, timestamp, checkCRC, SystemStats, systemstatsIdx);
- if systemstatsIdx >= length(SystemStats.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(SystemStats);
- for i=1:length(FieldNames) %Grow structure
- SystemStats.(FieldNames{i})(:,systemstatsIdx*2+1) = 0;
- end;
- end
- case TASKINFO_OBJID
- taskinfoIdx = taskinfoIdx + 1;
- TaskInfo= ReadTaskInfoObject(fid, timestamp, checkCRC, TaskInfo, taskinfoIdx);
- if taskinfoIdx >= length(TaskInfo.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(TaskInfo);
- for i=1:length(FieldNames) %Grow structure
- TaskInfo.(FieldNames{i})(:,taskinfoIdx*2+1) = 0;
- end;
- end
- case VELOCITYACTUAL_OBJID
- velocityactualIdx = velocityactualIdx + 1;
- VelocityActual= ReadVelocityActualObject(fid, timestamp, checkCRC, VelocityActual, velocityactualIdx);
- if velocityactualIdx >= length(VelocityActual.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(VelocityActual);
- for i=1:length(FieldNames) %Grow structure
- VelocityActual.(FieldNames{i})(:,velocityactualIdx*2+1) = 0;
- end;
- end
- case VELOCITYDESIRED_OBJID
- velocitydesiredIdx = velocitydesiredIdx + 1;
- VelocityDesired= ReadVelocityDesiredObject(fid, timestamp, checkCRC, VelocityDesired, velocitydesiredIdx);
- if velocitydesiredIdx >= length(VelocityDesired.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(VelocityDesired);
- for i=1:length(FieldNames) %Grow structure
- VelocityDesired.(FieldNames{i})(:,velocitydesiredIdx*2+1) = 0;
- end;
- end
- case WATCHDOGSTATUS_OBJID
- watchdogstatusIdx = watchdogstatusIdx + 1;
- WatchdogStatus= ReadWatchdogStatusObject(fid, timestamp, checkCRC, WatchdogStatus, watchdogstatusIdx);
- if watchdogstatusIdx >= length(WatchdogStatus.timestamp) %Check to see if pre-allocated memory is exhausted
- FieldNames= fieldnames(WatchdogStatus);
- for i=1:length(FieldNames) %Grow structure
- WatchdogStatus.(FieldNames{i})(:,watchdogstatusIdx*2+1) = 0;
- end;
- end
- otherwise
- % disp(['Unknown object ID: 0x' dec2hex(objID)]);
- msgBytesLeft = datasize - 1 - 1 - 2 - 4;
- if msgBytesLeft > 255
- msgBytesLeft = 0;
- end
- fread(fid, msgBytesLeft, 'uint8');
- end
- catch ME %#ok<NASGU>
- % One of the reads failed - indicates EOF
- break;
- end
- if 1 && (wrongSyncByte ~= lastWrongSyncByte || wrongMessageByte~=lastWrongMessageByte ) ||...
- (ftell(fid) / log_size - last_print) > 0.01
- lastWrongSyncByte=wrongSyncByte;
- lastWrongMessageByte=wrongMessageByte;
- str1=[];
- for i=1:length([str2 str3 str4 str5]);
- str1=[str1 sprintf('\b')];
- end
- str2=sprintf('wrongSyncByte instances: % 10d\n', wrongSyncByte );
- str3=sprintf('wrongMessageByte instances: % 10d\n\n', wrongMessageByte );
- str4=sprintf('Completed bytes: % 9d of % 9d\n', ftell(fid), log_size);
- estTimeRemaining=(log_size-ftell(fid))/(ftell(fid)/etime(clock,startTime));
- h=floor(estTimeRemaining/3600);
- m=floor((estTimeRemaining-h*3600)/60);
- s=ceil(estTimeRemaining-h*3600-m*60);
- str5=sprintf('Est. time remaining, %02dh:%02dm:%02ds \n', h,m,s);
- last_print = ftell(fid) / log_size;
- fprintf([str1 str2 str3 str4 str5]);
- % if etime(clock,startTime) > 5
- % break;
- % end
- % else
- % toc
- % tic
- end
- prebuf = fread(fid, 12, 'uint8');
- end
- fprintf('%d records in %0.2f seconds.\n', ftell(fid), etime(clock,startTime))
- %% Clean Up and Save mat file
- fclose(fid);
- % Trim output structs
- Accels=PruneStructOfArrays(Accels,accelsIdx);
- AccessoryDesired=PruneStructOfArrays(AccessoryDesired,accessorydesiredIdx);
- ActuatorCommand=PruneStructOfArrays(ActuatorCommand,actuatorcommandIdx);
- ActuatorDesired=PruneStructOfArrays(ActuatorDesired,actuatordesiredIdx);
- ActuatorSettings=PruneStructOfArrays(ActuatorSettings,actuatorsettingsIdx);
- AltHoldSmoothed=PruneStructOfArrays(AltHoldSmoothed,altholdsmoothedIdx);
- AltitudeHoldDesired=PruneStructOfArrays(AltitudeHoldDesired,altitudeholddesiredIdx);
- AltitudeHoldSettings=PruneStructOfArrays(AltitudeHoldSettings,altitudeholdsettingsIdx);
- AttitudeActual=PruneStructOfArrays(AttitudeActual,attitudeactualIdx);
- AttitudeSettings=PruneStructOfArrays(AttitudeSettings,attitudesettingsIdx);
- BaroAltitude=PruneStructOfArrays(BaroAltitude,baroaltitudeIdx);
- CameraDesired=PruneStructOfArrays(CameraDesired,cameradesiredIdx);
- CameraStabSettings=PruneStructOfArrays(CameraStabSettings,camerastabsettingsIdx);
- FaultSettings=PruneStructOfArrays(FaultSettings,faultsettingsIdx);
- FirmwareIAPObj=PruneStructOfArrays(FirmwareIAPObj,firmwareiapobjIdx);
- FlightBatterySettings=PruneStructOfArrays(FlightBatterySettings,flightbatterysettingsIdx);
- FlightBatteryState=PruneStructOfArrays(FlightBatteryState,flightbatterystateIdx);
- FlightPlanControl=PruneStructOfArrays(FlightPlanControl,flightplancontrolIdx);
- FlightPlanSettings=PruneStructOfArrays(FlightPlanSettings,flightplansettingsIdx);
- FlightPlanStatus=PruneStructOfArrays(FlightPlanStatus,flightplanstatusIdx);
- FlightStatus=PruneStructOfArrays(FlightStatus,flightstatusIdx);
- FlightTelemetryStats=PruneStructOfArrays(FlightTelemetryStats,flighttelemetrystatsIdx);
- GCSReceiver=PruneStructOfArrays(GCSReceiver,gcsreceiverIdx);
- GCSTelemetryStats=PruneStructOfArrays(GCSTelemetryStats,gcstelemetrystatsIdx);
- GPSPosition=PruneStructOfArrays(GPSPosition,gpspositionIdx);
- GPSSatellites=PruneStructOfArrays(GPSSatellites,gpssatellitesIdx);
- GPSTime=PruneStructOfArrays(GPSTime,gpstimeIdx);
- GuidanceSettings=PruneStructOfArrays(GuidanceSettings,guidancesettingsIdx);
- Gyros=PruneStructOfArrays(Gyros,gyrosIdx);
- GyrosBias=PruneStructOfArrays(GyrosBias,gyrosbiasIdx);
- HomeLocation=PruneStructOfArrays(HomeLocation,homelocationIdx);
- HwSettings=PruneStructOfArrays(HwSettings,hwsettingsIdx);
- I2CStats=PruneStructOfArrays(I2CStats,i2cstatsIdx);
- Magnetometer=PruneStructOfArrays(Magnetometer,magnetometerIdx);
- ManualControlCommand=PruneStructOfArrays(ManualControlCommand,manualcontrolcommandIdx);
- ManualControlSettings=PruneStructOfArrays(ManualControlSettings,manualcontrolsettingsIdx);
- MixerSettings=PruneStructOfArrays(MixerSettings,mixersettingsIdx);
- MixerStatus=PruneStructOfArrays(MixerStatus,mixerstatusIdx);
- NedAccel=PruneStructOfArrays(NedAccel,nedaccelIdx);
- ObjectPersistence=PruneStructOfArrays(ObjectPersistence,objectpersistenceIdx);
- OveroSyncStats=PruneStructOfArrays(OveroSyncStats,overosyncstatsIdx);
- PositionActual=PruneStructOfArrays(PositionActual,positionactualIdx);
- PositionDesired=PruneStructOfArrays(PositionDesired,positiondesiredIdx);
- RateDesired=PruneStructOfArrays(RateDesired,ratedesiredIdx);
- ReceiverActivity=PruneStructOfArrays(ReceiverActivity,receiveractivityIdx);
- RevoCalibration=PruneStructOfArrays(RevoCalibration,revocalibrationIdx);
- SonarAltitude=PruneStructOfArrays(SonarAltitude,sonaraltitudeIdx);
- StabilizationDesired=PruneStructOfArrays(StabilizationDesired,stabilizationdesiredIdx);
- StabilizationSettings=PruneStructOfArrays(StabilizationSettings,stabilizationsettingsIdx);
- SystemAlarms=PruneStructOfArrays(SystemAlarms,systemalarmsIdx);
- SystemSettings=PruneStructOfArrays(SystemSettings,systemsettingsIdx);
- SystemStats=PruneStructOfArrays(SystemStats,systemstatsIdx);
- TaskInfo=PruneStructOfArrays(TaskInfo,taskinfoIdx);
- VelocityActual=PruneStructOfArrays(VelocityActual,velocityactualIdx);
- VelocityDesired=PruneStructOfArrays(VelocityDesired,velocitydesiredIdx);
- WatchdogStatus=PruneStructOfArrays(WatchdogStatus,watchdogstatusIdx);
- if strcmpi(outputType,'mat')
- matfile = strrep(logfile,'opl','mat');
- save(matfile ,'Accels','AccessoryDesired','ActuatorCommand','ActuatorDesired','ActuatorSettings','AltHoldSmoothed','AltitudeHoldDesired','AltitudeHoldSettings','AttitudeActual','AttitudeSettings','BaroAltitude','CameraDesired','CameraStabSettings','FaultSettings','FirmwareIAPObj','FlightBatterySettings','FlightBatteryState','FlightPlanControl','FlightPlanSettings','FlightPlanStatus','FlightStatus','FlightTelemetryStats','GCSReceiver','GCSTelemetryStats','GPSPosition','GPSSatellites','GPSTime','GuidanceSettings','Gyros','GyrosBias','HomeLocation','HwSettings','I2CStats','Magnetometer','ManualControlCommand','ManualControlSettings','MixerSettings','MixerStatus','NedAccel','ObjectPersistence','OveroSyncStats','PositionActual','PositionDesired','RateDesired','ReceiverActivity','RevoCalibration','SonarAltitude','StabilizationDesired','StabilizationSettings','SystemAlarms','SystemSettings','SystemStats','TaskInfo','VelocityActual','VelocityDesired','WatchdogStatus');
- else
- OPLog2csv(Accels, 'Accels', logfile);
- OPLog2csv(AccessoryDesired, 'AccessoryDesired', logfile);
- OPLog2csv(ActuatorCommand, 'ActuatorCommand', logfile);
- OPLog2csv(ActuatorDesired, 'ActuatorDesired', logfile);
- OPLog2csv(ActuatorSettings, 'ActuatorSettings', logfile);
- OPLog2csv(AltHoldSmoothed, 'AltHoldSmoothed', logfile);
- OPLog2csv(AltitudeHoldDesired, 'AltitudeHoldDesired', logfile);
- OPLog2csv(AltitudeHoldSettings, 'AltitudeHoldSettings', logfile);
- OPLog2csv(AttitudeActual, 'AttitudeActual', logfile);
- OPLog2csv(AttitudeSettings, 'AttitudeSettings', logfile);
- OPLog2csv(BaroAltitude, 'BaroAltitude', logfile);
- OPLog2csv(CameraDesired, 'CameraDesired', logfile);
- OPLog2csv(CameraStabSettings, 'CameraStabSettings', logfile);
- OPLog2csv(FaultSettings, 'FaultSettings', logfile);
- OPLog2csv(FirmwareIAPObj, 'FirmwareIAPObj', logfile);
- OPLog2csv(FlightBatterySettings, 'FlightBatterySettings', logfile);
- OPLog2csv(FlightBatteryState, 'FlightBatteryState', logfile);
- OPLog2csv(FlightPlanControl, 'FlightPlanControl', logfile);
- OPLog2csv(FlightPlanSettings, 'FlightPlanSettings', logfile);
- OPLog2csv(FlightPlanStatus, 'FlightPlanStatus', logfile);
- OPLog2csv(FlightStatus, 'FlightStatus', logfile);
- OPLog2csv(FlightTelemetryStats, 'FlightTelemetryStats', logfile);
- OPLog2csv(GCSReceiver, 'GCSReceiver', logfile);
- OPLog2csv(GCSTelemetryStats, 'GCSTelemetryStats', logfile);
- OPLog2csv(GPSPosition, 'GPSPosition', logfile);
- OPLog2csv(GPSSatellites, 'GPSSatellites', logfile);
- OPLog2csv(GPSTime, 'GPSTime', logfile);
- OPLog2csv(GuidanceSettings, 'GuidanceSettings', logfile);
- OPLog2csv(Gyros, 'Gyros', logfile);
- OPLog2csv(GyrosBias, 'GyrosBias', logfile);
- OPLog2csv(HomeLocation, 'HomeLocation', logfile);
- OPLog2csv(HwSettings, 'HwSettings', logfile);
- OPLog2csv(I2CStats, 'I2CStats', logfile);
- OPLog2csv(Magnetometer, 'Magnetometer', logfile);
- OPLog2csv(ManualControlCommand, 'ManualControlCommand', logfile);
- OPLog2csv(ManualControlSettings, 'ManualControlSettings', logfile);
- OPLog2csv(MixerSettings, 'MixerSettings', logfile);
- OPLog2csv(MixerStatus, 'MixerStatus', logfile);
- OPLog2csv(NedAccel, 'NedAccel', logfile);
- OPLog2csv(ObjectPersistence, 'ObjectPersistence', logfile);
- OPLog2csv(OveroSyncStats, 'OveroSyncStats', logfile);
- OPLog2csv(PositionActual, 'PositionActual', logfile);
- OPLog2csv(PositionDesired, 'PositionDesired', logfile);
- OPLog2csv(RateDesired, 'RateDesired', logfile);
- OPLog2csv(ReceiverActivity, 'ReceiverActivity', logfile);
- OPLog2csv(RevoCalibration, 'RevoCalibration', logfile);
- OPLog2csv(SonarAltitude, 'SonarAltitude', logfile);
- OPLog2csv(StabilizationDesired, 'StabilizationDesired', logfile);
- OPLog2csv(StabilizationSettings, 'StabilizationSettings', logfile);
- OPLog2csv(SystemAlarms, 'SystemAlarms', logfile);
- OPLog2csv(SystemSettings, 'SystemSettings', logfile);
- OPLog2csv(SystemStats, 'SystemStats', logfile);
- OPLog2csv(TaskInfo, 'TaskInfo', logfile);
- OPLog2csv(VelocityActual, 'VelocityActual', logfile);
- OPLog2csv(VelocityDesired, 'VelocityDesired', logfile);
- OPLog2csv(WatchdogStatus, 'WatchdogStatus', logfile);
- end
- %% Object reading functions
- %%
- % Accels read function
- function [Accels] = ReadAccelsObject(fid, timestamp, checkCRC, Accels, accelsIdx)
- Accels.timestamp(accelsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- Accels.instanceID(accelsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- Accels.x(accelsIdx) = double(fread(fid, 1, 'float32'));
- Accels.y(accelsIdx) = double(fread(fid, 1, 'float32'));
- Accels.z(accelsIdx) = double(fread(fid, 1, 'float32'));
- Accels.temperature(accelsIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- accelsIdx = accelsIdx - 1;
- end
- end
- %%
- % AccessoryDesired read function
- function [AccessoryDesired] = ReadAccessoryDesiredObject(fid, timestamp, checkCRC, AccessoryDesired, accessorydesiredIdx)
- AccessoryDesired.timestamp(accessorydesiredIdx)= timestamp;
- if 0
- headerSize = 8;
- else
- AccessoryDesired.instanceID(accessorydesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- AccessoryDesired.AccessoryVal(accessorydesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- accessorydesiredIdx = accessorydesiredIdx - 1;
- end
- end
- %%
- % ActuatorCommand read function
- function [ActuatorCommand] = ReadActuatorCommandObject(fid, timestamp, checkCRC, ActuatorCommand, actuatorcommandIdx)
- ActuatorCommand.timestamp(actuatorcommandIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ActuatorCommand.instanceID(actuatorcommandIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ActuatorCommand.Channel(:,actuatorcommandIdx) = double(fread(fid, 10, 'int16'));
- ActuatorCommand.MaxUpdateTime(actuatorcommandIdx) = double(fread(fid, 1, 'uint16'));
- ActuatorCommand.UpdateTime(actuatorcommandIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorCommand.NumFailedUpdates(actuatorcommandIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- actuatorcommandIdx = actuatorcommandIdx - 1;
- end
- end
- %%
- % ActuatorDesired read function
- function [ActuatorDesired] = ReadActuatorDesiredObject(fid, timestamp, checkCRC, ActuatorDesired, actuatordesiredIdx)
- ActuatorDesired.timestamp(actuatordesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ActuatorDesired.instanceID(actuatordesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ActuatorDesired.Roll(actuatordesiredIdx) = double(fread(fid, 1, 'float32'));
- ActuatorDesired.Pitch(actuatordesiredIdx) = double(fread(fid, 1, 'float32'));
- ActuatorDesired.Yaw(actuatordesiredIdx) = double(fread(fid, 1, 'float32'));
- ActuatorDesired.Throttle(actuatordesiredIdx) = double(fread(fid, 1, 'float32'));
- ActuatorDesired.UpdateTime(actuatordesiredIdx) = double(fread(fid, 1, 'float32'));
- ActuatorDesired.NumLongUpdates(actuatordesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- actuatordesiredIdx = actuatordesiredIdx - 1;
- end
- end
- %%
- % ActuatorSettings read function
- function [ActuatorSettings] = ReadActuatorSettingsObject(fid, timestamp, checkCRC, ActuatorSettings, actuatorsettingsIdx)
- ActuatorSettings.timestamp(actuatorsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ActuatorSettings.instanceID(actuatorsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ActuatorSettings.ChannelUpdateFreq(:,actuatorsettingsIdx) = double(fread(fid, 4, 'uint16'));
- ActuatorSettings.ChannelMax(:,actuatorsettingsIdx) = double(fread(fid, 10, 'int16'));
- ActuatorSettings.ChannelNeutral(:,actuatorsettingsIdx) = double(fread(fid, 10, 'int16'));
- ActuatorSettings.ChannelMin(:,actuatorsettingsIdx) = double(fread(fid, 10, 'int16'));
- ActuatorSettings.FixedWingRoll1(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.FixedWingRoll2(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.FixedWingPitch1(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.FixedWingPitch2(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.FixedWingYaw1(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.FixedWingYaw2(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.FixedWingThrottle(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorN(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorNE(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorE(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorSE(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorS(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorSW(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorW(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.VTOLMotorNW(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ActuatorSettings.ChannelType(:,actuatorsettingsIdx) = double(fread(fid, 10, 'uint8'));
- ActuatorSettings.ChannelAddr(:,actuatorsettingsIdx) = double(fread(fid, 10, 'uint8'));
- ActuatorSettings.MotorsSpinWhileArmed(actuatorsettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- actuatorsettingsIdx = actuatorsettingsIdx - 1;
- end
- end
- %%
- % AltHoldSmoothed read function
- function [AltHoldSmoothed] = ReadAltHoldSmoothedObject(fid, timestamp, checkCRC, AltHoldSmoothed, altholdsmoothedIdx)
- AltHoldSmoothed.timestamp(altholdsmoothedIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- AltHoldSmoothed.instanceID(altholdsmoothedIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- AltHoldSmoothed.Altitude(altholdsmoothedIdx) = double(fread(fid, 1, 'float32'));
- AltHoldSmoothed.Velocity(altholdsmoothedIdx) = double(fread(fid, 1, 'float32'));
- AltHoldSmoothed.Accel(altholdsmoothedIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- altholdsmoothedIdx = altholdsmoothedIdx - 1;
- end
- end
- %%
- % AltitudeHoldDesired read function
- function [AltitudeHoldDesired] = ReadAltitudeHoldDesiredObject(fid, timestamp, checkCRC, AltitudeHoldDesired, altitudeholddesiredIdx)
- AltitudeHoldDesired.timestamp(altitudeholddesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- AltitudeHoldDesired.instanceID(altitudeholddesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- AltitudeHoldDesired.Altitude(altitudeholddesiredIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldDesired.Roll(altitudeholddesiredIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldDesired.Pitch(altitudeholddesiredIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldDesired.Yaw(altitudeholddesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- altitudeholddesiredIdx = altitudeholddesiredIdx - 1;
- end
- end
- %%
- % AltitudeHoldSettings read function
- function [AltitudeHoldSettings] = ReadAltitudeHoldSettingsObject(fid, timestamp, checkCRC, AltitudeHoldSettings, altitudeholdsettingsIdx)
- AltitudeHoldSettings.timestamp(altitudeholdsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- AltitudeHoldSettings.instanceID(altitudeholdsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- AltitudeHoldSettings.Kp(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldSettings.Ki(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldSettings.Kd(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldSettings.Ka(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldSettings.PressureNoise(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldSettings.AccelNoise(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- AltitudeHoldSettings.AccelDrift(altitudeholdsettingsIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- altitudeholdsettingsIdx = altitudeholdsettingsIdx - 1;
- end
- end
- %%
- % AttitudeActual read function
- function [AttitudeActual] = ReadAttitudeActualObject(fid, timestamp, checkCRC, AttitudeActual, attitudeactualIdx)
- AttitudeActual.timestamp(attitudeactualIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- AttitudeActual.instanceID(attitudeactualIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- AttitudeActual.q1(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- AttitudeActual.q2(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- AttitudeActual.q3(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- AttitudeActual.q4(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- AttitudeActual.Roll(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- AttitudeActual.Pitch(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- AttitudeActual.Yaw(attitudeactualIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- attitudeactualIdx = attitudeactualIdx - 1;
- end
- end
- %%
- % AttitudeSettings read function
- function [AttitudeSettings] = ReadAttitudeSettingsObject(fid, timestamp, checkCRC, AttitudeSettings, attitudesettingsIdx)
- AttitudeSettings.timestamp(attitudesettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- AttitudeSettings.instanceID(attitudesettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- AttitudeSettings.GyroGain(attitudesettingsIdx) = double(fread(fid, 1, 'float32'));
- AttitudeSettings.AccelKp(attitudesettingsIdx) = double(fread(fid, 1, 'float32'));
- AttitudeSettings.AccelKi(attitudesettingsIdx) = double(fread(fid, 1, 'float32'));
- AttitudeSettings.YawBiasRate(attitudesettingsIdx) = double(fread(fid, 1, 'float32'));
- AttitudeSettings.AccelBias(:,attitudesettingsIdx) = double(fread(fid, 3, 'int16'));
- AttitudeSettings.GyroBias(:,attitudesettingsIdx) = double(fread(fid, 3, 'int16'));
- AttitudeSettings.BoardRotation(:,attitudesettingsIdx) = double(fread(fid, 3, 'int16'));
- AttitudeSettings.ZeroDuringArming(attitudesettingsIdx) = double(fread(fid, 1, 'uint8'));
- AttitudeSettings.BiasCorrectGyro(attitudesettingsIdx) = double(fread(fid, 1, 'uint8'));
- AttitudeSettings.TrimFlight(attitudesettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- attitudesettingsIdx = attitudesettingsIdx - 1;
- end
- end
- %%
- % BaroAltitude read function
- function [BaroAltitude] = ReadBaroAltitudeObject(fid, timestamp, checkCRC, BaroAltitude, baroaltitudeIdx)
- BaroAltitude.timestamp(baroaltitudeIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- BaroAltitude.instanceID(baroaltitudeIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- BaroAltitude.Altitude(baroaltitudeIdx) = double(fread(fid, 1, 'float32'));
- BaroAltitude.Temperature(baroaltitudeIdx) = double(fread(fid, 1, 'float32'));
- BaroAltitude.Pressure(baroaltitudeIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- baroaltitudeIdx = baroaltitudeIdx - 1;
- end
- end
- %%
- % CameraDesired read function
- function [CameraDesired] = ReadCameraDesiredObject(fid, timestamp, checkCRC, CameraDesired, cameradesiredIdx)
- CameraDesired.timestamp(cameradesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- CameraDesired.instanceID(cameradesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- CameraDesired.Roll(cameradesiredIdx) = double(fread(fid, 1, 'float32'));
- CameraDesired.Pitch(cameradesiredIdx) = double(fread(fid, 1, 'float32'));
- CameraDesired.Yaw(cameradesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- cameradesiredIdx = cameradesiredIdx - 1;
- end
- end
- %%
- % CameraStabSettings read function
- function [CameraStabSettings] = ReadCameraStabSettingsObject(fid, timestamp, checkCRC, CameraStabSettings, camerastabsettingsIdx)
- CameraStabSettings.timestamp(camerastabsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- CameraStabSettings.instanceID(camerastabsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- CameraStabSettings.MaxAxisLockRate(camerastabsettingsIdx) = double(fread(fid, 1, 'float32'));
- CameraStabSettings.ResponseTime(:,camerastabsettingsIdx) = double(fread(fid, 3, 'uint16'));
- CameraStabSettings.Input(:,camerastabsettingsIdx) = double(fread(fid, 3, 'uint8'));
- CameraStabSettings.InputRange(:,camerastabsettingsIdx) = double(fread(fid, 3, 'uint8'));
- CameraStabSettings.InputRate(:,camerastabsettingsIdx) = double(fread(fid, 3, 'uint8'));
- CameraStabSettings.StabilizationMode(:,camerastabsettingsIdx) = double(fread(fid, 3, 'uint8'));
- CameraStabSettings.OutputRange(:,camerastabsettingsIdx) = double(fread(fid, 3, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- camerastabsettingsIdx = camerastabsettingsIdx - 1;
- end
- end
- %%
- % FaultSettings read function
- function [FaultSettings] = ReadFaultSettingsObject(fid, timestamp, checkCRC, FaultSettings, faultsettingsIdx)
- FaultSettings.timestamp(faultsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FaultSettings.instanceID(faultsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FaultSettings.ActivateFault(faultsettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- faultsettingsIdx = faultsettingsIdx - 1;
- end
- end
- %%
- % FirmwareIAPObj read function
- function [FirmwareIAPObj] = ReadFirmwareIAPObjObject(fid, timestamp, checkCRC, FirmwareIAPObj, firmwareiapobjIdx)
- FirmwareIAPObj.timestamp(firmwareiapobjIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FirmwareIAPObj.instanceID(firmwareiapobjIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FirmwareIAPObj.crc(firmwareiapobjIdx) = double(fread(fid, 1, 'uint32'));
- FirmwareIAPObj.Command(firmwareiapobjIdx) = double(fread(fid, 1, 'uint16'));
- FirmwareIAPObj.BoardRevision(firmwareiapobjIdx) = double(fread(fid, 1, 'uint16'));
- FirmwareIAPObj.Description(:,firmwareiapobjIdx) = double(fread(fid, 40, 'uint8'));
- FirmwareIAPObj.CPUSerial(:,firmwareiapobjIdx) = double(fread(fid, 12, 'uint8'));
- FirmwareIAPObj.BoardType(firmwareiapobjIdx) = double(fread(fid, 1, 'uint8'));
- FirmwareIAPObj.ArmReset(firmwareiapobjIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- firmwareiapobjIdx = firmwareiapobjIdx - 1;
- end
- end
- %%
- % FlightBatterySettings read function
- function [FlightBatterySettings] = ReadFlightBatterySettingsObject(fid, timestamp, checkCRC, FlightBatterySettings, flightbatterysettingsIdx)
- FlightBatterySettings.timestamp(flightbatterysettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightBatterySettings.instanceID(flightbatterysettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightBatterySettings.Capacity(flightbatterysettingsIdx) = double(fread(fid, 1, 'uint32'));
- FlightBatterySettings.VoltageThresholds(:,flightbatterysettingsIdx) = double(fread(fid, 2, 'float32'));
- FlightBatterySettings.SensorCalibrations(:,flightbatterysettingsIdx) = double(fread(fid, 2, 'float32'));
- FlightBatterySettings.Type(flightbatterysettingsIdx) = double(fread(fid, 1, 'uint8'));
- FlightBatterySettings.NbCells(flightbatterysettingsIdx) = double(fread(fid, 1, 'uint8'));
- FlightBatterySettings.SensorType(flightbatterysettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flightbatterysettingsIdx = flightbatterysettingsIdx - 1;
- end
- end
- %%
- % FlightBatteryState read function
- function [FlightBatteryState] = ReadFlightBatteryStateObject(fid, timestamp, checkCRC, FlightBatteryState, flightbatterystateIdx)
- FlightBatteryState.timestamp(flightbatterystateIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightBatteryState.instanceID(flightbatterystateIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightBatteryState.Voltage(flightbatterystateIdx) = double(fread(fid, 1, 'float32'));
- FlightBatteryState.Current(flightbatterystateIdx) = double(fread(fid, 1, 'float32'));
- FlightBatteryState.PeakCurrent(flightbatterystateIdx) = double(fread(fid, 1, 'float32'));
- FlightBatteryState.AvgCurrent(flightbatterystateIdx) = double(fread(fid, 1, 'float32'));
- FlightBatteryState.ConsumedEnergy(flightbatterystateIdx) = double(fread(fid, 1, 'float32'));
- FlightBatteryState.EstimatedFlightTime(flightbatterystateIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flightbatterystateIdx = flightbatterystateIdx - 1;
- end
- end
- %%
- % FlightPlanControl read function
- function [FlightPlanControl] = ReadFlightPlanControlObject(fid, timestamp, checkCRC, FlightPlanControl, flightplancontrolIdx)
- FlightPlanControl.timestamp(flightplancontrolIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightPlanControl.instanceID(flightplancontrolIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightPlanControl.Command(flightplancontrolIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flightplancontrolIdx = flightplancontrolIdx - 1;
- end
- end
- %%
- % FlightPlanSettings read function
- function [FlightPlanSettings] = ReadFlightPlanSettingsObject(fid, timestamp, checkCRC, FlightPlanSettings, flightplansettingsIdx)
- FlightPlanSettings.timestamp(flightplansettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightPlanSettings.instanceID(flightplansettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightPlanSettings.Test(flightplansettingsIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flightplansettingsIdx = flightplansettingsIdx - 1;
- end
- end
- %%
- % FlightPlanStatus read function
- function [FlightPlanStatus] = ReadFlightPlanStatusObject(fid, timestamp, checkCRC, FlightPlanStatus, flightplanstatusIdx)
- FlightPlanStatus.timestamp(flightplanstatusIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightPlanStatus.instanceID(flightplanstatusIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightPlanStatus.ErrorFileID(flightplanstatusIdx) = double(fread(fid, 1, 'uint32'));
- FlightPlanStatus.ErrorLineNum(flightplanstatusIdx) = double(fread(fid, 1, 'uint32'));
- FlightPlanStatus.Debug(:,flightplanstatusIdx) = double(fread(fid, 2, 'float32'));
- FlightPlanStatus.Status(flightplanstatusIdx) = double(fread(fid, 1, 'uint8'));
- FlightPlanStatus.ErrorType(flightplanstatusIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flightplanstatusIdx = flightplanstatusIdx - 1;
- end
- end
- %%
- % FlightStatus read function
- function [FlightStatus] = ReadFlightStatusObject(fid, timestamp, checkCRC, FlightStatus, flightstatusIdx)
- FlightStatus.timestamp(flightstatusIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightStatus.instanceID(flightstatusIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightStatus.Armed(flightstatusIdx) = double(fread(fid, 1, 'uint8'));
- FlightStatus.FlightMode(flightstatusIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flightstatusIdx = flightstatusIdx - 1;
- end
- end
- %%
- % FlightTelemetryStats read function
- function [FlightTelemetryStats] = ReadFlightTelemetryStatsObject(fid, timestamp, checkCRC, FlightTelemetryStats, flighttelemetrystatsIdx)
- FlightTelemetryStats.timestamp(flighttelemetrystatsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- FlightTelemetryStats.instanceID(flighttelemetrystatsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- FlightTelemetryStats.TxDataRate(flighttelemetrystatsIdx) = double(fread(fid, 1, 'float32'));
- FlightTelemetryStats.RxDataRate(flighttelemetrystatsIdx) = double(fread(fid, 1, 'float32'));
- FlightTelemetryStats.TxFailures(flighttelemetrystatsIdx) = double(fread(fid, 1, 'uint32'));
- FlightTelemetryStats.RxFailures(flighttelemetrystatsIdx) = double(fread(fid, 1, 'uint32'));
- FlightTelemetryStats.TxRetries(flighttelemetrystatsIdx) = double(fread(fid, 1, 'uint32'));
- FlightTelemetryStats.Status(flighttelemetrystatsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- flighttelemetrystatsIdx = flighttelemetrystatsIdx - 1;
- end
- end
- %%
- % GCSReceiver read function
- function [GCSReceiver] = ReadGCSReceiverObject(fid, timestamp, checkCRC, GCSReceiver, gcsreceiverIdx)
- GCSReceiver.timestamp(gcsreceiverIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GCSReceiver.instanceID(gcsreceiverIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GCSReceiver.Channel(:,gcsreceiverIdx) = double(fread(fid, 6, 'uint16'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gcsreceiverIdx = gcsreceiverIdx - 1;
- end
- end
- %%
- % GCSTelemetryStats read function
- function [GCSTelemetryStats] = ReadGCSTelemetryStatsObject(fid, timestamp, checkCRC, GCSTelemetryStats, gcstelemetrystatsIdx)
- GCSTelemetryStats.timestamp(gcstelemetrystatsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GCSTelemetryStats.instanceID(gcstelemetrystatsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GCSTelemetryStats.TxDataRate(gcstelemetrystatsIdx) = double(fread(fid, 1, 'float32'));
- GCSTelemetryStats.RxDataRate(gcstelemetrystatsIdx) = double(fread(fid, 1, 'float32'));
- GCSTelemetryStats.TxFailures(gcstelemetrystatsIdx) = double(fread(fid, 1, 'uint32'));
- GCSTelemetryStats.RxFailures(gcstelemetrystatsIdx) = double(fread(fid, 1, 'uint32'));
- GCSTelemetryStats.TxRetries(gcstelemetrystatsIdx) = double(fread(fid, 1, 'uint32'));
- GCSTelemetryStats.Status(gcstelemetrystatsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gcstelemetrystatsIdx = gcstelemetrystatsIdx - 1;
- end
- end
- %%
- % GPSPosition read function
- function [GPSPosition] = ReadGPSPositionObject(fid, timestamp, checkCRC, GPSPosition, gpspositionIdx)
- GPSPosition.timestamp(gpspositionIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GPSPosition.instanceID(gpspositionIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GPSPosition.Latitude(gpspositionIdx) = double(fread(fid, 1, 'int32'));
- GPSPosition.Longitude(gpspositionIdx) = double(fread(fid, 1, 'int32'));
- GPSPosition.Altitude(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.GeoidSeparation(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.Heading(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.Groundspeed(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.PDOP(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.HDOP(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.VDOP(gpspositionIdx) = double(fread(fid, 1, 'float32'));
- GPSPosition.Status(gpspositionIdx) = double(fread(fid, 1, 'uint8'));
- GPSPosition.Satellites(gpspositionIdx) = double(fread(fid, 1, 'int8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gpspositionIdx = gpspositionIdx - 1;
- end
- end
- %%
- % GPSSatellites read function
- function [GPSSatellites] = ReadGPSSatellitesObject(fid, timestamp, checkCRC, GPSSatellites, gpssatellitesIdx)
- GPSSatellites.timestamp(gpssatellitesIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GPSSatellites.instanceID(gpssatellitesIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GPSSatellites.Elevation(:,gpssatellitesIdx) = double(fread(fid, 16, 'float32'));
- GPSSatellites.Azimuth(:,gpssatellitesIdx) = double(fread(fid, 16, 'float32'));
- GPSSatellites.SatsInView(gpssatellitesIdx) = double(fread(fid, 1, 'int8'));
- GPSSatellites.PRN(:,gpssatellitesIdx) = double(fread(fid, 16, 'int8'));
- GPSSatellites.SNR(:,gpssatellitesIdx) = double(fread(fid, 16, 'int8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gpssatellitesIdx = gpssatellitesIdx - 1;
- end
- end
- %%
- % GPSTime read function
- function [GPSTime] = ReadGPSTimeObject(fid, timestamp, checkCRC, GPSTime, gpstimeIdx)
- GPSTime.timestamp(gpstimeIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GPSTime.instanceID(gpstimeIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GPSTime.Year(gpstimeIdx) = double(fread(fid, 1, 'int16'));
- GPSTime.Month(gpstimeIdx) = double(fread(fid, 1, 'int8'));
- GPSTime.Day(gpstimeIdx) = double(fread(fid, 1, 'int8'));
- GPSTime.Hour(gpstimeIdx) = double(fread(fid, 1, 'int8'));
- GPSTime.Minute(gpstimeIdx) = double(fread(fid, 1, 'int8'));
- GPSTime.Second(gpstimeIdx) = double(fread(fid, 1, 'int8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gpstimeIdx = gpstimeIdx - 1;
- end
- end
- %%
- % GuidanceSettings read function
- function [GuidanceSettings] = ReadGuidanceSettingsObject(fid, timestamp, checkCRC, GuidanceSettings, guidancesettingsIdx)
- GuidanceSettings.timestamp(guidancesettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GuidanceSettings.instanceID(guidancesettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GuidanceSettings.HorizontalPosPI(:,guidancesettingsIdx) = double(fread(fid, 3, 'float32'));
- GuidanceSettings.HorizontalVelPID(:,guidancesettingsIdx) = double(fread(fid, 4, 'float32'));
- GuidanceSettings.VerticalPosPI(:,guidancesettingsIdx) = double(fread(fid, 3, 'float32'));
- GuidanceSettings.VerticalVelPID(:,guidancesettingsIdx) = double(fread(fid, 4, 'float32'));
- GuidanceSettings.MaxRollPitch(guidancesettingsIdx) = double(fread(fid, 1, 'float32'));
- GuidanceSettings.UpdatePeriod(guidancesettingsIdx) = double(fread(fid, 1, 'int32'));
- GuidanceSettings.HorizontalVelMax(guidancesettingsIdx) = double(fread(fid, 1, 'uint16'));
- GuidanceSettings.VerticalVelMax(guidancesettingsIdx) = double(fread(fid, 1, 'uint16'));
- GuidanceSettings.GuidanceMode(guidancesettingsIdx) = double(fread(fid, 1, 'uint8'));
- GuidanceSettings.ThrottleControl(guidancesettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- guidancesettingsIdx = guidancesettingsIdx - 1;
- end
- end
- %%
- % Gyros read function
- function [Gyros] = ReadGyrosObject(fid, timestamp, checkCRC, Gyros, gyrosIdx)
- Gyros.timestamp(gyrosIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- Gyros.instanceID(gyrosIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- Gyros.x(gyrosIdx) = double(fread(fid, 1, 'float32'));
- Gyros.y(gyrosIdx) = double(fread(fid, 1, 'float32'));
- Gyros.z(gyrosIdx) = double(fread(fid, 1, 'float32'));
- Gyros.temperature(gyrosIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gyrosIdx = gyrosIdx - 1;
- end
- end
- %%
- % GyrosBias read function
- function [GyrosBias] = ReadGyrosBiasObject(fid, timestamp, checkCRC, GyrosBias, gyrosbiasIdx)
- GyrosBias.timestamp(gyrosbiasIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- GyrosBias.instanceID(gyrosbiasIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- GyrosBias.x(gyrosbiasIdx) = double(fread(fid, 1, 'float32'));
- GyrosBias.y(gyrosbiasIdx) = double(fread(fid, 1, 'float32'));
- GyrosBias.z(gyrosbiasIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- gyrosbiasIdx = gyrosbiasIdx - 1;
- end
- end
- %%
- % HomeLocation read function
- function [HomeLocation] = ReadHomeLocationObject(fid, timestamp, checkCRC, HomeLocation, homelocationIdx)
- HomeLocation.timestamp(homelocationIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- HomeLocation.instanceID(homelocationIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- HomeLocation.Latitude(homelocationIdx) = double(fread(fid, 1, 'int32'));
- HomeLocation.Longitude(homelocationIdx) = double(fread(fid, 1, 'int32'));
- HomeLocation.Altitude(homelocationIdx) = double(fread(fid, 1, 'float32'));
- HomeLocation.ECEF(:,homelocationIdx) = double(fread(fid, 3, 'int32'));
- HomeLocation.RNE(:,homelocationIdx) = double(fread(fid, 9, 'float32'));
- HomeLocation.Be(:,homelocationIdx) = double(fread(fid, 3, 'float32'));
- HomeLocation.g_e(homelocationIdx) = double(fread(fid, 1, 'float32'));
- HomeLocation.Set(homelocationIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- homelocationIdx = homelocationIdx - 1;
- end
- end
- %%
- % HwSettings read function
- function [HwSettings] = ReadHwSettingsObject(fid, timestamp, checkCRC, HwSettings, hwsettingsIdx)
- HwSettings.timestamp(hwsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- HwSettings.instanceID(hwsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- HwSettings.CC_RcvrPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.CC_MainPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.CC_FlexiPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.OP_RcvrPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.OP_MainPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.OP_FlexiPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.TelemetrySpeed(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.GPSSpeed(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.ComUsbBridgeSpeed(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.USB_DeviceType(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.USB_HIDPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.USB_VCPPort(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- HwSettings.OptionalModules(:,hwsettingsIdx) = double(fread(fid, 5, 'uint8'));
- HwSettings.DSMxBind(hwsettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- hwsettingsIdx = hwsettingsIdx - 1;
- end
- end
- %%
- % I2CStats read function
- function [I2CStats] = ReadI2CStatsObject(fid, timestamp, checkCRC, I2CStats, i2cstatsIdx)
- I2CStats.timestamp(i2cstatsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- I2CStats.instanceID(i2cstatsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- I2CStats.evirq_log(:,i2cstatsIdx) = double(fread(fid, 5, 'uint32'));
- I2CStats.erirq_log(:,i2cstatsIdx) = double(fread(fid, 5, 'uint32'));
- I2CStats.event_errors(i2cstatsIdx) = double(fread(fid, 1, 'uint8'));
- I2CStats.fsm_errors(i2cstatsIdx) = double(fread(fid, 1, 'uint8'));
- I2CStats.irq_errors(i2cstatsIdx) = double(fread(fid, 1, 'uint8'));
- I2CStats.nacks(i2cstatsIdx) = double(fread(fid, 1, 'uint8'));
- I2CStats.timeouts(i2cstatsIdx) = double(fread(fid, 1, 'uint8'));
- I2CStats.last_error_type(i2cstatsIdx) = double(fread(fid, 1, 'uint8'));
- I2CStats.event_log(:,i2cstatsIdx) = double(fread(fid, 5, 'uint8'));
- I2CStats.state_log(:,i2cstatsIdx) = double(fread(fid, 5, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- i2cstatsIdx = i2cstatsIdx - 1;
- end
- end
- %%
- % Magnetometer read function
- function [Magnetometer] = ReadMagnetometerObject(fid, timestamp, checkCRC, Magnetometer, magnetometerIdx)
- Magnetometer.timestamp(magnetometerIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- Magnetometer.instanceID(magnetometerIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- Magnetometer.x(magnetometerIdx) = double(fread(fid, 1, 'float32'));
- Magnetometer.y(magnetometerIdx) = double(fread(fid, 1, 'float32'));
- Magnetometer.z(magnetometerIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- magnetometerIdx = magnetometerIdx - 1;
- end
- end
- %%
- % ManualControlCommand read function
- function [ManualControlCommand] = ReadManualControlCommandObject(fid, timestamp, checkCRC, ManualControlCommand, manualcontrolcommandIdx)
- ManualControlCommand.timestamp(manualcontrolcommandIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ManualControlCommand.instanceID(manualcontrolcommandIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ManualControlCommand.Throttle(manualcontrolcommandIdx) = double(fread(fid, 1, 'float32'));
- ManualControlCommand.Roll(manualcontrolcommandIdx) = double(fread(fid, 1, 'float32'));
- ManualControlCommand.Pitch(manualcontrolcommandIdx) = double(fread(fid, 1, 'float32'));
- ManualControlCommand.Yaw(manualcontrolcommandIdx) = double(fread(fid, 1, 'float32'));
- ManualControlCommand.Collective(manualcontrolcommandIdx) = double(fread(fid, 1, 'float32'));
- ManualControlCommand.Channel(:,manualcontrolcommandIdx) = double(fread(fid, 9, 'uint16'));
- ManualControlCommand.Connected(manualcontrolcommandIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- manualcontrolcommandIdx = manualcontrolcommandIdx - 1;
- end
- end
- %%
- % ManualControlSettings read function
- function [ManualControlSettings] = ReadManualControlSettingsObject(fid, timestamp, checkCRC, ManualControlSettings, manualcontrolsettingsIdx)
- ManualControlSettings.timestamp(manualcontrolsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ManualControlSettings.instanceID(manualcontrolsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ManualControlSettings.ChannelMin(:,manualcontrolsettingsIdx) = double(fread(fid, 9, 'int16'));
- ManualControlSettings.ChannelNeutral(:,manualcontrolsettingsIdx) = double(fread(fid, 9, 'int16'));
- ManualControlSettings.ChannelMax(:,manualcontrolsettingsIdx) = double(fread(fid, 9, 'int16'));
- ManualControlSettings.ArmedTimeout(manualcontrolsettingsIdx) = double(fread(fid, 1, 'uint16'));
- ManualControlSettings.ChannelGroups(:,manualcontrolsettingsIdx) = double(fread(fid, 9, 'uint8'));
- ManualControlSettings.ChannelNumber(:,manualcontrolsettingsIdx) = double(fread(fid, 9, 'uint8'));
- ManualControlSettings.Arming(manualcontrolsettingsIdx) = double(fread(fid, 1, 'uint8'));
- ManualControlSettings.Stabilization1Settings(:,manualcontrolsettingsIdx) = double(fread(fid, 3, 'uint8'));
- ManualControlSettings.Stabilization2Settings(:,manualcontrolsettingsIdx) = double(fread(fid, 3, 'uint8'));
- ManualControlSettings.Stabilization3Settings(:,manualcontrolsettingsIdx) = double(fread(fid, 3, 'uint8'));
- ManualControlSettings.FlightModePosition(:,manualcontrolsettingsIdx) = double(fread(fid, 3, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- manualcontrolsettingsIdx = manualcontrolsettingsIdx - 1;
- end
- end
- %%
- % MixerSettings read function
- function [MixerSettings] = ReadMixerSettingsObject(fid, timestamp, checkCRC, MixerSettings, mixersettingsIdx)
- MixerSettings.timestamp(mixersettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- MixerSettings.instanceID(mixersettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- MixerSettings.MaxAccel(mixersettingsIdx) = double(fread(fid, 1, 'float32'));
- MixerSettings.FeedForward(mixersettingsIdx) = double(fread(fid, 1, 'float32'));
- MixerSettings.AccelTime(mixersettingsIdx) = double(fread(fid, 1, 'float32'));
- MixerSettings.DecelTime(mixersettingsIdx) = double(fread(fid, 1, 'float32'));
- MixerSettings.ThrottleCurve1(:,mixersettingsIdx) = double(fread(fid, 5, 'float32'));
- MixerSettings.ThrottleCurve2(:,mixersettingsIdx) = double(fread(fid, 5, 'float32'));
- MixerSettings.Curve2Source(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer1Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer1Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer2Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer2Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer3Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer3Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer4Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer4Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer5Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer5Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer6Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer6Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer7Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer7Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer8Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer8Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer9Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer9Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- MixerSettings.Mixer10Type(mixersettingsIdx) = double(fread(fid, 1, 'uint8'));
- MixerSettings.Mixer10Vector(:,mixersettingsIdx) = double(fread(fid, 5, 'int8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- mixersettingsIdx = mixersettingsIdx - 1;
- end
- end
- %%
- % MixerStatus read function
- function [MixerStatus] = ReadMixerStatusObject(fid, timestamp, checkCRC, MixerStatus, mixerstatusIdx)
- MixerStatus.timestamp(mixerstatusIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- MixerStatus.instanceID(mixerstatusIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- MixerStatus.Mixer1(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer2(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer3(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer4(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer5(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer6(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer7(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- MixerStatus.Mixer8(mixerstatusIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- mixerstatusIdx = mixerstatusIdx - 1;
- end
- end
- %%
- % NedAccel read function
- function [NedAccel] = ReadNedAccelObject(fid, timestamp, checkCRC, NedAccel, nedaccelIdx)
- NedAccel.timestamp(nedaccelIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- NedAccel.instanceID(nedaccelIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- NedAccel.North(nedaccelIdx) = double(fread(fid, 1, 'float32'));
- NedAccel.East(nedaccelIdx) = double(fread(fid, 1, 'float32'));
- NedAccel.Down(nedaccelIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- nedaccelIdx = nedaccelIdx - 1;
- end
- end
- %%
- % ObjectPersistence read function
- function [ObjectPersistence] = ReadObjectPersistenceObject(fid, timestamp, checkCRC, ObjectPersistence, objectpersistenceIdx)
- ObjectPersistence.timestamp(objectpersistenceIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ObjectPersistence.instanceID(objectpersistenceIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ObjectPersistence.ObjectID(objectpersistenceIdx) = double(fread(fid, 1, 'uint32'));
- ObjectPersistence.InstanceID(objectpersistenceIdx) = double(fread(fid, 1, 'uint32'));
- ObjectPersistence.Operation(objectpersistenceIdx) = double(fread(fid, 1, 'uint8'));
- ObjectPersistence.Selection(objectpersistenceIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- objectpersistenceIdx = objectpersistenceIdx - 1;
- end
- end
- %%
- % OveroSyncStats read function
- function [OveroSyncStats] = ReadOveroSyncStatsObject(fid, timestamp, checkCRC, OveroSyncStats, overosyncstatsIdx)
- OveroSyncStats.timestamp(overosyncstatsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- OveroSyncStats.instanceID(overosyncstatsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- OveroSyncStats.Send(overosyncstatsIdx) = double(fread(fid, 1, 'uint32'));
- OveroSyncStats.Received(overosyncstatsIdx) = double(fread(fid, 1, 'uint32'));
- OveroSyncStats.DroppedUpdates(overosyncstatsIdx) = double(fread(fid, 1, 'uint32'));
- OveroSyncStats.Connected(overosyncstatsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- overosyncstatsIdx = overosyncstatsIdx - 1;
- end
- end
- %%
- % PositionActual read function
- function [PositionActual] = ReadPositionActualObject(fid, timestamp, checkCRC, PositionActual, positionactualIdx)
- PositionActual.timestamp(positionactualIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- PositionActual.instanceID(positionactualIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- PositionActual.North(positionactualIdx) = double(fread(fid, 1, 'float32'));
- PositionActual.East(positionactualIdx) = double(fread(fid, 1, 'float32'));
- PositionActual.Down(positionactualIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- positionactualIdx = positionactualIdx - 1;
- end
- end
- %%
- % PositionDesired read function
- function [PositionDesired] = ReadPositionDesiredObject(fid, timestamp, checkCRC, PositionDesired, positiondesiredIdx)
- PositionDesired.timestamp(positiondesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- PositionDesired.instanceID(positiondesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- PositionDesired.North(positiondesiredIdx) = double(fread(fid, 1, 'float32'));
- PositionDesired.East(positiondesiredIdx) = double(fread(fid, 1, 'float32'));
- PositionDesired.Down(positiondesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- positiondesiredIdx = positiondesiredIdx - 1;
- end
- end
- %%
- % RateDesired read function
- function [RateDesired] = ReadRateDesiredObject(fid, timestamp, checkCRC, RateDesired, ratedesiredIdx)
- RateDesired.timestamp(ratedesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- RateDesired.instanceID(ratedesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- RateDesired.Roll(ratedesiredIdx) = double(fread(fid, 1, 'float32'));
- RateDesired.Pitch(ratedesiredIdx) = double(fread(fid, 1, 'float32'));
- RateDesired.Yaw(ratedesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- ratedesiredIdx = ratedesiredIdx - 1;
- end
- end
- %%
- % ReceiverActivity read function
- function [ReceiverActivity] = ReadReceiverActivityObject(fid, timestamp, checkCRC, ReceiverActivity, receiveractivityIdx)
- ReceiverActivity.timestamp(receiveractivityIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- ReceiverActivity.instanceID(receiveractivityIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- ReceiverActivity.ActiveGroup(receiveractivityIdx) = double(fread(fid, 1, 'uint8'));
- ReceiverActivity.ActiveChannel(receiveractivityIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- receiveractivityIdx = receiveractivityIdx - 1;
- end
- end
- %%
- % RevoCalibration read function
- function [RevoCalibration] = ReadRevoCalibrationObject(fid, timestamp, checkCRC, RevoCalibration, revocalibrationIdx)
- RevoCalibration.timestamp(revocalibrationIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- RevoCalibration.instanceID(revocalibrationIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- RevoCalibration.accel_bias(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.accel_scale(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.accel_var(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.gyro_bias(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.gyro_scale(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.gyro_var(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.gyro_tempcoeff(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.mag_bias(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.mag_scale(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.mag_var(:,revocalibrationIdx) = double(fread(fid, 3, 'float32'));
- RevoCalibration.BiasCorrectedRaw(revocalibrationIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- revocalibrationIdx = revocalibrationIdx - 1;
- end
- end
- %%
- % SonarAltitude read function
- function [SonarAltitude] = ReadSonarAltitudeObject(fid, timestamp, checkCRC, SonarAltitude, sonaraltitudeIdx)
- SonarAltitude.timestamp(sonaraltitudeIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- SonarAltitude.instanceID(sonaraltitudeIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- SonarAltitude.Altitude(sonaraltitudeIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- sonaraltitudeIdx = sonaraltitudeIdx - 1;
- end
- end
- %%
- % StabilizationDesired read function
- function [StabilizationDesired] = ReadStabilizationDesiredObject(fid, timestamp, checkCRC, StabilizationDesired, stabilizationdesiredIdx)
- StabilizationDesired.timestamp(stabilizationdesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- StabilizationDesired.instanceID(stabilizationdesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- StabilizationDesired.Roll(stabilizationdesiredIdx) = double(fread(fid, 1, 'float32'));
- StabilizationDesired.Pitch(stabilizationdesiredIdx) = double(fread(fid, 1, 'float32'));
- StabilizationDesired.Yaw(stabilizationdesiredIdx) = double(fread(fid, 1, 'float32'));
- StabilizationDesired.Throttle(stabilizationdesiredIdx) = double(fread(fid, 1, 'float32'));
- StabilizationDesired.StabilizationMode(:,stabilizationdesiredIdx) = double(fread(fid, 3, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- stabilizationdesiredIdx = stabilizationdesiredIdx - 1;
- end
- end
- %%
- % StabilizationSettings read function
- function [StabilizationSettings] = ReadStabilizationSettingsObject(fid, timestamp, checkCRC, StabilizationSettings, stabilizationsettingsIdx)
- StabilizationSettings.timestamp(stabilizationsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- StabilizationSettings.instanceID(stabilizationsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- StabilizationSettings.ManualRate(:,stabilizationsettingsIdx) = double(fread(fid, 3, 'float32'));
- StabilizationSettings.MaximumRate(:,stabilizationsettingsIdx) = double(fread(fid, 3, 'float32'));
- StabilizationSettings.RollRatePID(:,stabilizationsettingsIdx) = double(fread(fid, 4, 'float32'));
- StabilizationSettings.PitchRatePID(:,stabilizationsettingsIdx) = double(fread(fid, 4, 'float32'));
- StabilizationSettings.YawRatePID(:,stabilizationsettingsIdx) = double(fread(fid, 4, 'float32'));
- StabilizationSettings.RollPI(:,stabilizationsettingsIdx) = double(fread(fid, 3, 'float32'));
- StabilizationSettings.PitchPI(:,stabilizationsettingsIdx) = double(fread(fid, 3, 'float32'));
- StabilizationSettings.YawPI(:,stabilizationsettingsIdx) = double(fread(fid, 3, 'float32'));
- StabilizationSettings.GyroTau(stabilizationsettingsIdx) = double(fread(fid, 1, 'float32'));
- StabilizationSettings.WeakLevelingKp(stabilizationsettingsIdx) = double(fread(fid, 1, 'float32'));
- StabilizationSettings.RollMax(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- StabilizationSettings.PitchMax(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- StabilizationSettings.YawMax(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- StabilizationSettings.MaxAxisLock(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- StabilizationSettings.MaxAxisLockRate(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- StabilizationSettings.MaxWeakLevelingRate(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- StabilizationSettings.LowThrottleZeroIntegral(stabilizationsettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- stabilizationsettingsIdx = stabilizationsettingsIdx - 1;
- end
- end
- %%
- % SystemAlarms read function
- function [SystemAlarms] = ReadSystemAlarmsObject(fid, timestamp, checkCRC, SystemAlarms, systemalarmsIdx)
- SystemAlarms.timestamp(systemalarmsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- SystemAlarms.instanceID(systemalarmsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- SystemAlarms.Alarm(:,systemalarmsIdx) = double(fread(fid, 18, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- systemalarmsIdx = systemalarmsIdx - 1;
- end
- end
- %%
- % SystemSettings read function
- function [SystemSettings] = ReadSystemSettingsObject(fid, timestamp, checkCRC, SystemSettings, systemsettingsIdx)
- SystemSettings.timestamp(systemsettingsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- SystemSettings.instanceID(systemsettingsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- SystemSettings.GUIConfigData(:,systemsettingsIdx) = double(fread(fid, 2, 'uint32'));
- SystemSettings.AirframeType(systemsettingsIdx) = double(fread(fid, 1, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- systemsettingsIdx = systemsettingsIdx - 1;
- end
- end
- %%
- % SystemStats read function
- function [SystemStats] = ReadSystemStatsObject(fid, timestamp, checkCRC, SystemStats, systemstatsIdx)
- SystemStats.timestamp(systemstatsIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- SystemStats.instanceID(systemstatsIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- SystemStats.FlightTime(systemstatsIdx) = double(fread(fid, 1, 'uint32'));
- SystemStats.HeapRemaining(systemstatsIdx) = double(fread(fid, 1, 'uint16'));
- SystemStats.IRQStackRemaining(systemstatsIdx) = double(fread(fid, 1, 'uint16'));
- SystemStats.CPULoad(systemstatsIdx) = double(fread(fid, 1, 'uint8'));
- SystemStats.CPUTemp(systemstatsIdx) = double(fread(fid, 1, 'int8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- systemstatsIdx = systemstatsIdx - 1;
- end
- end
- %%
- % TaskInfo read function
- function [TaskInfo] = ReadTaskInfoObject(fid, timestamp, checkCRC, TaskInfo, taskinfoIdx)
- TaskInfo.timestamp(taskinfoIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- TaskInfo.instanceID(taskinfoIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- TaskInfo.StackRemaining(:,taskinfoIdx) = double(fread(fid, 17, 'uint16'));
- TaskInfo.Running(:,taskinfoIdx) = double(fread(fid, 17, 'uint8'));
- TaskInfo.RunningTime(:,taskinfoIdx) = double(fread(fid, 17, 'uint8'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- taskinfoIdx = taskinfoIdx - 1;
- end
- end
- %%
- % VelocityActual read function
- function [VelocityActual] = ReadVelocityActualObject(fid, timestamp, checkCRC, VelocityActual, velocityactualIdx)
- VelocityActual.timestamp(velocityactualIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- VelocityActual.instanceID(velocityactualIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- VelocityActual.North(velocityactualIdx) = double(fread(fid, 1, 'float32'));
- VelocityActual.East(velocityactualIdx) = double(fread(fid, 1, 'float32'));
- VelocityActual.Down(velocityactualIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- velocityactualIdx = velocityactualIdx - 1;
- end
- end
- %%
- % VelocityDesired read function
- function [VelocityDesired] = ReadVelocityDesiredObject(fid, timestamp, checkCRC, VelocityDesired, velocitydesiredIdx)
- VelocityDesired.timestamp(velocitydesiredIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- VelocityDesired.instanceID(velocitydesiredIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- VelocityDesired.North(velocitydesiredIdx) = double(fread(fid, 1, 'float32'));
- VelocityDesired.East(velocitydesiredIdx) = double(fread(fid, 1, 'float32'));
- VelocityDesired.Down(velocitydesiredIdx) = double(fread(fid, 1, 'float32'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- velocitydesiredIdx = velocitydesiredIdx - 1;
- end
- end
- %%
- % WatchdogStatus read function
- function [WatchdogStatus] = ReadWatchdogStatusObject(fid, timestamp, checkCRC, WatchdogStatus, watchdogstatusIdx)
- WatchdogStatus.timestamp(watchdogstatusIdx)= timestamp;
- if 1
- headerSize = 8;
- else
- WatchdogStatus.instanceID(watchdogstatusIdx) = (fread(fid, 1, 'uint16'));
- headerSize = 10;
- end
- startPos = ftell(fid) - headerSize;
- WatchdogStatus.BootupFlags(watchdogstatusIdx) = double(fread(fid, 1, 'uint16'));
- WatchdogStatus.ActiveFlags(watchdogstatusIdx) = double(fread(fid, 1, 'uint16'));
- objLen = ftell(fid) - startPos;
- % read CRC
- crc_read = fread(fid, 1, '*uint8');
- if checkCRC
- fseek(fid, startPos, 'bof');
- crc_calc = compute_crc(uint8(fread(fid,objLen,'uint8')));
- fread(fid,1,'uint8');
- if (crc_calc ~= crc_read)
- disp('CRC Error')
- watchdogstatusIdx = watchdogstatusIdx - 1;
- end
- end
- % This function prunes the excess pre-allocated space
- function [structOut]=PruneStructOfArrays(structIn, lastIndex)
- fieldNames = fieldnames(structIn);
- for i=1:length(fieldNames)
- structOut.(fieldNames{i})=structIn.(fieldNames{i})(1:lastIndex);
- end
- function OPLog2csv(structIn, structName, logfile)
- %Get each field name from the structure
- fieldNames = fieldnames(structIn);
- %Create a text string with the field names
- headerOut=sprintf('%s,',fieldNames{:});
- headerOut=headerOut(1:end-1); %Trim off last `,` and `\t`
- %Assign the structure arrays to a matrix.
- matOut=zeros(max(size(structIn.(fieldNames{1}))), length(fieldNames));
- if isempty(structIn.(fieldNames{1}));
- matOut=[];
- else
- for i=1:length(fieldNames)
- matOut(:,i)=structIn.(fieldNames{i});
- end
- end
- % Create filename by replacing opl by csv
- [path, name] = fileparts(logfile);
- csvDirName=[name '_csv'];
- [dummyA, dummyB]=mkdir(fullfile(path, csvDirName)); %Dummy outputs so the program doens't throw warnings about "Directory already exists"
- csvfile=fullfile(path, csvDirName , [name '.csv']);
- %Write to csv.
- dlmwrite(csvfile, headerOut, '');
- dlmwrite(csvfile, matOut, '-append');
- function crc = compute_crc(data)
- global crc_table;
- crc = 0;
- for i = 1:length(data)
- crc = crc_table(1+bitxor(data(i),crc));
- end
Add Comment
Please, Sign In to add comment