void CGMSKClientThread::processFrame(const unsigned char* buffer, bool sync) { if (m_recorder != NULL) m_recorder->writeFrame(buffer, DV_FRAME_LENGTH_BYTES); // Only process the slow data if this isn't a data sync frame if (!sync) processSlowData(buffer + VOICE_FRAME_LENGTH_BYTES); else m_slowDataDecoder.sync(); m_decodeData.addData(buffer, VOICE_FRAME_LENGTH_BYTES); }
void DSDDstar::processData() { int bit = m_dsdDecoder->m_dsdSymbol.getDibit(); // get dibit from symbol if (m_symbolIndex == 0) { memset(slowdata, 0, 4); memset(nullBytes, 0, 4); slowdataIx = 0; } else if (m_symbolIndex%8 == 0) { slowdataIx++; } slowdata[slowdataIx] += bit<<(m_symbolIndex%8); // this is LSB first! if (m_symbolIndex == 24-1) // last bit in data frame { // std::cerr << "DSDDstar::processData: " << m_voiceFrameCount << std::endl; if ((m_voiceFrameCount > 0) && (memcmp(slowdata, nullBytes, 4) != 0)) { slowdata[0] ^= 0x70; slowdata[1] ^= 0x4f; slowdata[2] ^= 0x93; // std::cerr << "DSDDstar::processData:" // << " " << std::hex << (int) (slowdata[0]) // << " " << std::hex << (int) (slowdata[1]) // << " " << std::hex << (int) (slowdata[2]) // << " (" << m_voiceFrameCount << ")" << std::endl; processSlowData(m_voiceFrameCount == 1); //printf("unscrambled- %s",slowdata); } m_symbolIndex = 0; m_frameType = DStarVoiceFrame; } else { m_symbolIndex++; } }
void CDExtraClientThread::processFrame(const unsigned char* buffer, bool sync, bool end) { m_watchdog.reset(); if (m_recorder != NULL) m_recorder->writeFrame(buffer, DV_FRAME_LENGTH_BYTES); // Only process the slow data if this isn't a data sync frame if (!sync) processSlowData(buffer + VOICE_FRAME_LENGTH_BYTES); else m_slowDataDecoder.sync(); m_decodeData.addData(buffer, VOICE_FRAME_LENGTH_BYTES); if (end) { m_dongle->setMode(DVDMODE_IDLE); resetReceiver(); } }
void CDVToolReaderThread::processFile() { m_stopped = false; DVTFR_TYPE type; unsigned char header[RADIO_HEADER_LENGTH_BYTES]; unsigned int n = m_reader->read(header, RADIO_HEADER_LENGTH_BYTES, type); if (n == 0U || type != DVTFR_HEADER) { // Release the input file m_reader->close(); delete m_reader; m_reader = NULL; return; } processHeader(header); // Clear any state that may be hanging around m_slowDataDecoder.reset(); m_dataBuffer.clear(); m_dongle->setMode(DVDMODE_DECODE); for (;;) { DVTFR_TYPE type; unsigned char frame[RADIO_HEADER_LENGTH_BYTES]; unsigned int n = m_reader->read(frame, RADIO_HEADER_LENGTH_BYTES, type); // End of file? if (n == 0U || type != DVTFR_DETAIL) break; if (n != DV_FRAME_LENGTH_BYTES) { wxLogError(wxT("Invalid frame size of %u in the file"), n); ::wxGetApp().error(_("Invalid frame size in the file.")); break; } // Don't pass data re-sync to the slow data processor if (::memcmp(frame + VOICE_FRAME_LENGTH_BYTES, DATA_SYNC_BYTES, DATA_FRAME_LENGTH_BYTES) != 0) processSlowData(frame + VOICE_FRAME_LENGTH_BYTES); else m_slowDataDecoder.sync(); m_dataBuffer.addData(frame, VOICE_FRAME_LENGTH_BYTES); Sleep(FRAME_TIME_MS); } Sleep(FRAME_TIME_MS * 30U); m_dongle->setMode(DVDMODE_IDLE); // Clear the GUI ::wxGetApp().showHeader(NULL); // Release the input file m_reader->close(); delete m_reader; m_reader = NULL; wxLogMessage(wxT("Finished processing the file")); m_stopped = true; }
void CSoundCardRepeaterTXRXThread::radioStateMachine(bool bit) { switch (m_rxState) { case DSRXS_LISTENING: { unsigned int errs1 = m_frameMatcher.add(bit); unsigned int errs2 = m_dataMatcher.add(bit); // The frame sync has been seen, an exact match only if (errs1 == 0U) { // wxLogMessage(wxT("Found frame sync")); setRadioState(DSRXS_PROCESS_HEADER); } // The data sync has been seen, an exact match only if (errs2 == 0U) { // wxLogMessage(wxT("Found data sync")); setRadioState(DSRXS_PROCESS_SLOW_DATA); } } break; case DSRXS_PROCESS_HEADER: m_bitBuffer.add(bit); if (m_bitBuffer.getLength() == FEC_SECTION_LENGTH_BITS) { CHeaderData* header = processFECHeader(); if (header != NULL) { bool res = processRadioHeader(header); if (res) { // A valid header and is a DV packet m_radioSeqNo = 20U; m_radioSyncsLost = 0U; setRadioState(DSRXS_PROCESS_DATA); } else { // This is a DD packet or some other problem // wxLogMessage(wxT("Invalid header")); setRadioState(DSRXS_LISTENING); } } else { // The checksum failed setRadioState(DSRXS_LISTENING); } } break; case DSRXS_PROCESS_DATA: { m_bitBuffer.add(bit); unsigned int errs1 = m_endMatcher.add(bit); unsigned int errs2 = m_dataMatcher.add(bit); // The end pattern has been seen, a fuzzy match is used, four bit errors or less if (errs1 <= MAX_END_PATTERN_BIT_ERRS) { // wxLogMessage(wxT("Found end pattern, errs: %u"), errs1); processRadioFrame(FRAME_END); setRadioState(DSRXS_LISTENING); endOfRadioData(); break; } if (m_bitBuffer.getLength() == DV_FRAME_LENGTH_BITS) { // The squelch is closed so replace the data with silence if (m_squelchCount >= MAX_SQUELCH_COUNT) { m_bitBuffer.clear(); // Add AMBE silence and slow data for (unsigned int i = 0U; i < DV_FRAME_LENGTH_BITS; i++) m_bitBuffer.add(NULL_FRAME_DATA_BITS[i]); } // The data sync has been seen, a fuzzy match is used, two bit errors or less if (errs2 <= MAX_DATA_SYNC_BIT_ERRS) { // wxLogMessage(wxT("Found data sync at frame %u, errs: %u"), m_radioSeqNo, errs2); m_radioSeqNo = 0U; m_radioSyncsLost = 0U; processRadioFrame(FRAME_SYNC); } else if (m_radioSeqNo == 20U) { // wxLogMessage(wxT("Regenerating data sync")); m_radioSeqNo = 0U; m_radioSyncsLost++; if (m_radioSyncsLost == MAX_LOST_SYNCS) { // wxLogMessage(wxT("Lost sync")); processRadioFrame(FRAME_END); setRadioState(DSRXS_LISTENING); endOfRadioData(); } else { processRadioFrame(FRAME_SYNC); } } else { m_radioSeqNo++; processRadioFrame(FRAME_NORMAL); } m_squelchCount = 0U; m_bitBuffer.clear(); } } break; case DSRXS_PROCESS_SLOW_DATA: { m_bitBuffer.add(bit); unsigned int errs1 = m_endMatcher.add(bit); unsigned int errs2 = m_dataMatcher.add(bit); // The end pattern has been seen, a fuzzy match is used, four bit errors or less if (errs1 <= MAX_END_PATTERN_BIT_ERRS) { // wxLogMessage(wxT("Found end pattern, errs: %u"), errs1); setRadioState(DSRXS_LISTENING); break; } if (m_bitBuffer.getLength() == DV_FRAME_LENGTH_BITS) { // The squelch is closed so abort the slow data search if (m_squelchCount >= MAX_SQUELCH_COUNT) { setRadioState(DSRXS_LISTENING); break; } // The data sync has been seen, a fuzzy match is used, two bit errors or less if (errs2 <= MAX_DATA_SYNC_BIT_ERRS) { // wxLogMessage(wxT("Found data sync at frame %u, errs: %u"), m_radioSeqNo, errs2); m_radioSeqNo = 0U; m_radioSyncsLost = 0U; processSlowData(true); } else if (m_radioSeqNo == 20U) { // wxLogMessage(wxT("Assuming data sync")); m_radioSeqNo = 0U; m_radioSyncsLost++; if (m_radioSyncsLost == MAX_LOST_SYNCS) { // wxLogMessage(wxT("Lost sync")); setRadioState(DSRXS_LISTENING); } else { processSlowData(true); } } else { m_radioSeqNo++; CHeaderData* header = processSlowData(false); if (header != NULL) { bool res = processRadioHeader(header); if (res) { // A valid header and is a DV packet, go to normal data relaying setRadioState(DSRXS_PROCESS_DATA); } else { // This is a DD packet or some other problem // wxLogMessage(wxT("Invalid header")); } } } m_squelchCount = 0U; m_bitBuffer.clear(); } } break; } }