1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

AHRS: Serial output option for AHRS and corresponding serial logger.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1414 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-08-26 06:25:11 +00:00 committed by peabody124
parent 71de54d0a7
commit c07e1416b7
3 changed files with 125 additions and 0 deletions

View File

@ -60,6 +60,9 @@ void DMA1_Channel1_IRQHandler() __attribute__ ((alias ("AHRS_ADC_DMA_Handler")))
* @}
*/
// For debugging the raw sensors
//#define DUMP_RAW
/**
* @addtogroup AHRS_Definitions
* @{
@ -271,6 +274,28 @@ int main()
downsample_data();
converge_insgps();
}
#ifdef DUMP_RAW
while(1) {
int result;
uint8_t sync[4] = {7,7,7,7};
while( ahrs_state != AHRS_DATA_READY );
ahrs_state = AHRS_PROCESSING;
downsample_data();
ahrs_state = AHRS_IDLE;;
// Dump raw buffer
result = PIOS_COM_SendBuffer(PIOS_COM_AUX, &sync[0], 4); // dump block number
result += PIOS_COM_SendBuffer(PIOS_COM_AUX, (uint8_t *) &total_conversion_blocks, sizeof(total_conversion_blocks)); // dump block number
result += PIOS_COM_SendBuffer(PIOS_COM_AUX, (uint8_t *) &valid_data_buffer[0], ADC_OVERSAMPLE * ADC_CONTINUOUS_CHANNELS * sizeof(valid_data_buffer[0]));
if(result == 0)
PIOS_LED_Off(LED1);
else {
PIOS_LED_On(LED1);
}
}
#endif
/******************* Main EKF loop ****************************/
while (1) {

View File

@ -0,0 +1,40 @@
#-------------------------------------------------
#
# Project created by QtCreator 2010-08-25T23:31:09
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = SerialLogger
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += ../../libs/qextserialport/src
# event driven device enumeration on windows requires the gui module
win32:QT += gui
HEADERS = ../../libs/qextserialport/src/qextserialport.h \
../../libs/qextserialport/src/qextserialenumerator.h \
../../libs/qextserialport/src/qextserialport_global.h
SOURCES = ../../libs/qextserialport/src/qextserialport.cpp
unix:SOURCES += ../../libs/qextserialport/src/posix_qextserialport.cpp
unix:!macx:SOURCES += ../../libs/qextserialport/src/qextserialenumerator_unix.cpp
macx {
SOURCES += ../../libs/qextserialport/src/qextserialenumerator_osx.cpp
LIBS += -framework IOKit -framework CoreFoundation
}
win32 {
SOURCES += ../../libs/qextserialport/src/win_qextserialport.cpp
SOURCES += ../../libs/qextserialport/src/qextserialenumerator_win.cpp
DEFINES += WINVER=0x0501 # needed for mingw to pull in appropriate dbt business...probably a better way to do this
LIBS += -lsetupapi
}
SOURCES += main.cpp

View File

@ -0,0 +1,60 @@
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QThread>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <qextserialport.h>
#include <iostream>
class pollSerialPort : public QThread
{
public:
pollSerialPort(QString dn, QString fn) : device(dn), outFile(fn)
{
};
void run()
{
QByteArray dat;
PortSettings Settings;
Settings.BaudRate=BAUD57600;
Settings.DataBits=DATA_8;
Settings.Parity=PAR_NONE;
Settings.StopBits=STOP_1;
Settings.FlowControl=FLOW_HARDWARE;
Settings.Timeout_Millisec=500;
QextSerialPort serialPort(device, Settings);
serialPort.open(QIODevice::ReadOnly);
QFile file(outFile);
if( !file.open( QIODevice::WriteOnly ) )
{
qDebug() << "Failed to open file: " << outFile;
return;
}
QTextStream ts( &file );
while(1)
{
dat = serialPort.read(10);
qDebug() << dat;
ts << dat;
}
};
protected:
QString device;
QString outFile;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
pollSerialPort thread("/dev/tty.usbserial-000014FAB","log.dat"); //argv[0]);
thread.start();
return a.exec();
}