Created
September 14, 2015 21:21
-
-
Save blandry/4f64657b72398c1ac813 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- | |
// | |
// Test for AP_GPS_AUTO | |
// | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <AP_Common/AP_Common.h> | |
#include <AP_Progmem/AP_Progmem.h> | |
#include <AP_Param/AP_Param.h> | |
#include <AP_HAL/AP_HAL.h> | |
#include <AP_HAL_AVR/AP_HAL_AVR.h> | |
#include <AP_HAL_SITL/AP_HAL_SITL.h> | |
#include <AP_HAL_PX4/AP_HAL_PX4.h> | |
#include <AP_HAL_Linux/AP_HAL_Linux.h> | |
#include <AP_HAL_Empty/AP_HAL_Empty.h> | |
#include <AP_GPS/AP_GPS.h> | |
#include <DataFlash/DataFlash.h> | |
#include <AP_InertialSensor/AP_InertialSensor.h> | |
#include <AP_ADC/AP_ADC.h> | |
#include <GCS_MAVLink/GCS_MAVLink.h> | |
#include <AP_Baro/AP_Baro.h> | |
#include <Filter/Filter.h> | |
#include <AP_AHRS/AP_AHRS.h> | |
#include <AP_Compass/AP_Compass.h> | |
#include <AP_Declination/AP_Declination.h> | |
#include <AP_Airspeed/AP_Airspeed.h> | |
#include <AP_Vehicle/AP_Vehicle.h> | |
#include <AP_ADC_AnalogSource/AP_ADC_AnalogSource.h> | |
#include <AP_Mission/AP_Mission.h> | |
#include <StorageManager/StorageManager.h> | |
#include <AP_Terrain/AP_Terrain.h> | |
#include <AP_Math/AP_Math.h> | |
#include <AP_Notify/AP_Notify.h> | |
#include <AP_Notify/AP_BoardLED.h> | |
#include <AP_NavEKF/AP_NavEKF.h> | |
#include <AP_Rally/AP_Rally.h> | |
#include <AP_Scheduler/AP_Scheduler.h> | |
#include <AP_BattMonitor/AP_BattMonitor.h> | |
#include <AP_SerialManager/AP_SerialManager.h> | |
const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; | |
// create board led object | |
AP_BoardLED board_led; | |
AP_SerialManager serial_manager; | |
int fd; | |
void setup() | |
{ | |
hal.scheduler->delay(5000); | |
// initialise the leds | |
board_led.init(); | |
serial_manager.init(); | |
/* Allocate large enough buffers on uartA to support mavlink */ | |
hal.uartC->begin(500000, 128, 256); | |
char fname[] = "/fs/microsd/gimbal_2kHz_log.bin"; | |
fd = 0; | |
hal.uartC->printf("Trying to open the log file...\n"); | |
while(fd <= 0){ | |
fd = ::open(fname, O_RDWR|O_CREAT|O_TRUNC, 00777); | |
} | |
hal.uartC->printf("The file was opened...\n"); | |
char headergyro[] = { 0xA3,0x95,0x80,0x81,0x13,'G','Y','R',0x00,'I','f','f','f',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'T','i','m','e','U','S',',','G','y','r','X',',','G','y','r','Y',',','G','y','r','Z',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; | |
char headeracc[] = { 0xA3,0x95,0x80,0x82,0x13,'A','C','C',0x00,'I','f','f','f',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'T','i','m','e','U','S',',','A','c','c','X',',','A','c','c','Y',',','A','c','c','Z',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; | |
::write(fd,headergyro,sizeof(headergyro)); | |
::write(fd,headeracc,sizeof(headeracc)); | |
} | |
void loop() | |
{ | |
int a = hal.uartC->available(); | |
if (a > 0) { | |
int r = hal.uartC->read(); | |
while (r > 0) { | |
::write(fd,&r,sizeof(char)); | |
r = hal.uartC->read(); | |
} | |
} | |
::fsync(fd); | |
hal.scheduler->delay(10); | |
} | |
AP_HAL_MAIN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment