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

Ground/SerialLogging: Improved the serial dump from AHRS to have a big random frame header and to detect it on the logging program.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1556 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-09-07 16:33:10 +00:00 committed by peabody124
parent 755c47d666
commit 9895b403c7
2 changed files with 29 additions and 5 deletions

View File

@ -281,7 +281,7 @@ int main()
#ifdef DUMP_RAW #ifdef DUMP_RAW
while(1) { while(1) {
int result; int result;
uint8_t sync[4] = {7,7,7,7}; uint8_t framing[16] = {7,9,3,15,193,130,150,10,7,9,3,15,193,130,150,10};
while( ahrs_state != AHRS_DATA_READY ); while( ahrs_state != AHRS_DATA_READY );
ahrs_state = AHRS_PROCESSING; ahrs_state = AHRS_PROCESSING;
@ -289,7 +289,7 @@ int main()
ahrs_state = AHRS_IDLE;; ahrs_state = AHRS_IDLE;;
// Dump raw buffer // Dump raw buffer
result = PIOS_COM_SendBuffer(PIOS_COM_AUX, &sync[0], 4); // dump block number result = PIOS_COM_SendBuffer(PIOS_COM_AUX, &framing[0], 16); // framing header
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 *) &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])); 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) if(result == 0)

View File

@ -18,6 +18,9 @@ public:
void run() void run()
{ {
QByteArray dat; QByteArray dat;
const char framingRaw[16] = {7,9,3,15,193,130,150,10,7,9,3,15,193,130,150,10};
QByteArray framing(framingRaw,16);
PortSettings Settings; PortSettings Settings;
Settings.BaudRate=BAUD57600; Settings.BaudRate=BAUD57600;
Settings.DataBits=DATA_8; Settings.DataBits=DATA_8;
@ -40,9 +43,17 @@ public:
while(1) while(1)
{ {
dat = serialPort.read(100); dat = serialPort.read(1000);
qDebug() << dat; if(dat.contains(framing))
{
int start = dat.indexOf(framing);
int count = *((int *) (dat.data() + start+16));
qDebug() << "Found frame start at " << start << " count " << count;
}
else
qDebug() << "No frame start";
ts << dat; ts << dat;
usleep(50000);
} }
}; };
@ -54,7 +65,20 @@ protected:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
pollSerialPort thread("/dev/tty.usbserial-000014FAB","log.dat"); //argv[0]); QString device;
QString log;
if(argc < 2)
device = "/dev/tty.usbserial-000014FAB";
else
device = QString(argv[1]);
if(argc < 3)
log = "log.dat";
else
log = QString(argv[2]);
pollSerialPort thread(device, log);
thread.start(); thread.start();
return a.exec(); return a.exec();
} }