void CDStarRepeaterRXThread::receiveModem()
{
    for (;;) {
        DSMT_TYPE type = m_modem->read();
        if (type == DSMTT_NONE)
            return;

        switch (m_rxState) {
        case DSRXS_LISTENING:
            if (type == DSMTT_HEADER) {
                CHeaderData* header = m_modem->readHeader();
                receiveHeader(header);
            } else if (type == DSMTT_DATA) {
                unsigned char data[20U];
                unsigned int length = m_modem->readData(data, 20U);
                setRadioState(DSRXS_PROCESS_SLOW_DATA);
                receiveSlowData(data, length);
            }
            break;

        case DSRXS_PROCESS_SLOW_DATA:
            if (type == DSMTT_DATA) {
                unsigned char data[20U];
                unsigned int length = m_modem->readData(data, 20U);
                receiveSlowData(data, length);
            } else if (type == DSMTT_EOT || type == DSMTT_LOST) {
                setRadioState(DSRXS_LISTENING);
            }
            break;

        case DSRXS_PROCESS_DATA:
            if (type == DSMTT_DATA) {
                unsigned char data[20U];
                unsigned int length = m_modem->readData(data, 20U);
                receiveRadioData(data, length);
            } else if (type == DSMTT_EOT || type == DSMTT_LOST) {
                unsigned char data[20U];
                ::memcpy(data, END_PATTERN_BYTES, DV_FRAME_LENGTH_BYTES);
                processRadioFrame(data, FRAME_END);
                setRadioState(DSRXS_LISTENING);
                endOfRadioData();
            }
            break;
        }
    }
}
void CDVRPTRRepeaterRXThread::receiveRadio()
{
	for (;;) {
		unsigned char data[50U];
		unsigned int length;
		DATA_QUEUE_TYPE type = m_dvrptr->readQueue(data, length);

		switch (type) {
			case DQT_NONE:
				return;
			case DQT_HEADER:
				// CUtils::dump(wxT("DQT_HEADER"), data, length);
				break;
			case DQT_DATA:
				// CUtils::dump(wxT("DQT_DATA"), data, length);
				break;
			case DQT_EOT:
				// wxLogMessage(wxT("DQT_EOT"));
				break;
			case DQT_LOST:
				// wxLogMessage(wxT("DQT_LOST"));
				break;
			default:
				wxLogMessage(wxT("type=%d"), int(type));
				CUtils::dump(wxT("DQT_???"), data, length);
				break;
		}

		switch (m_rxState) {
			case DSRXS_LISTENING:
				if (type == DQT_HEADER) {
					receiveHeader(data, length);
				} else if (type == DQT_DATA) {
					setRadioState(DSRXS_PROCESS_SLOW_DATA);
				}
				break;

			case DSRXS_PROCESS_SLOW_DATA:
				if (type == DQT_DATA) {
					receiveSlowData(data, length);
				} else if (type == DQT_EOT) {
					setRadioState(DSRXS_LISTENING);
				} else if (type == DQT_LOST) {
					setRadioState(DSRXS_LISTENING);
				}
				break;

			case DSRXS_PROCESS_DATA:
				if (type == DQT_DATA) {
					receiveRadioData(data, length);
				} else if (type == DQT_EOT) {
					processRadioFrame(data, FRAME_END);
					setRadioState(DSRXS_LISTENING);
					endOfRadioData();
				} else if (type == DQT_LOST) {
					::memcpy(data, NULL_FRAME_DATA_BYTES, DV_FRAME_LENGTH_BYTES);
					processRadioFrame(data, FRAME_END);
					setRadioState(DSRXS_LISTENING);
					endOfRadioData();
				}
				break;
		}
	}
}