diff --git a/flight/AHRS/ahrs.c b/flight/AHRS/ahrs.c index 8d0dbefa7..4adc67a43 100644 --- a/flight/AHRS/ahrs.c +++ b/flight/AHRS/ahrs.c @@ -281,7 +281,7 @@ int main() #ifdef DUMP_RAW while(1) { 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 ); ahrs_state = AHRS_PROCESSING; @@ -289,7 +289,7 @@ int main() 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, &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 *) &valid_data_buffer[0], ADC_OVERSAMPLE * ADC_CONTINUOUS_CHANNELS * sizeof(valid_data_buffer[0])); if(result == 0) diff --git a/ground/src/experimental/SerialLogger/main.cpp b/ground/src/experimental/SerialLogger/main.cpp index b54f37c89..cb5f25d4f 100644 --- a/ground/src/experimental/SerialLogger/main.cpp +++ b/ground/src/experimental/SerialLogger/main.cpp @@ -18,6 +18,9 @@ public: void run() { 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; Settings.BaudRate=BAUD57600; Settings.DataBits=DATA_8; @@ -40,9 +43,17 @@ public: while(1) { - dat = serialPort.read(100); - qDebug() << dat; + dat = serialPort.read(1000); + 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; + usleep(50000); } }; @@ -54,7 +65,20 @@ protected: int main(int argc, char *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(); return a.exec(); }