当前位置: 首页>>代码示例>>C++>>正文


C++ CAMBEData::isSync方法代码示例

本文整理汇总了C++中CAMBEData::isSync方法的典型用法代码示例。如果您正苦于以下问题:C++ CAMBEData::isSync方法的具体用法?C++ CAMBEData::isSync怎么用?C++ CAMBEData::isSync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAMBEData的用法示例。


在下文中一共展示了CAMBEData::isSync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeData

void CDRATSServer::writeData(const CAMBEData& data)
{
	// Sync data isn't sent on
	if (data.isSync()) {
		m_writeState = SS_FIRST;
		return;
	}

	if (data.isEnd()) {
		if (m_writeLength > 0U && m_socket != NULL) {
			// CUtils::dump(wxT("From RF"), m_writeBuffer, m_writeLength);
			m_socket->write(m_writeBuffer, m_writeLength);
		}

		m_writeLength = 0U;
		return;
	}

	unsigned char buffer[DV_FRAME_MAX_LENGTH_BYTES];
	unsigned int length = data.getData(buffer, DV_FRAME_MAX_LENGTH_BYTES);

	if (length != DV_FRAME_LENGTH_BYTES)
		return;

	unsigned char byte1 = buffer[VOICE_FRAME_LENGTH_BYTES + 0U] ^ SCRAMBLER_BYTE1;
	unsigned char byte2 = buffer[VOICE_FRAME_LENGTH_BYTES + 1U] ^ SCRAMBLER_BYTE2;
	unsigned char byte3 = buffer[VOICE_FRAME_LENGTH_BYTES + 2U] ^ SCRAMBLER_BYTE3;

	switch (m_writeState) {
		case SS_FIRST:
			m_writeText[0U] = byte1;
			m_writeText[1U] = byte2;
			m_writeText[2U] = byte3;
			m_writeState = SS_SECOND;
			return;

		case SS_SECOND:
			m_writeText[3U] = byte1;
			m_writeText[4U] = byte2;
			m_writeText[5U] = byte3;
			m_writeState = SS_FIRST;
			break;
	}

	if ((m_writeText[0U] & SLOW_DATA_TYPE_MASK) != SLOW_DATA_TYPE_GPS)
		return;

	length = m_writeText[0U] & 0x07;	// Maximum value of 5
	if (length > 5U)
		length = 5U;

	for (unsigned int i = 0U; i < length; i++) {
		m_writeBuffer[m_writeLength++] = m_writeText[i + 1U];

		// Check for [EOB] in the buffer to signal the end of the D-RATS data.
		// To allow strstr() to run correctly
		m_writeBuffer[m_writeLength] = 0x00U;

		if (::strstr((char*)m_writeBuffer, "[EOB]") != NULL) {
			if (m_socket != NULL) {
				// CUtils::dump(wxT("From RF"), m_writeBuffer, m_writeLength);
				m_socket->write(m_writeBuffer, m_writeLength);
			}

			m_writeLength = 0U;
		}
	}
}
开发者ID:EA3HKB,项目名称:OpenDV,代码行数:68,代码来源:DRATSServer.cpp

示例2: writeData

void CAPRSWriter::writeData(const wxString& callsign, const CAMBEData& data)
{
	if (data.isEnd())
		return;

	CAPRSEntry* entry = m_array[callsign];
	if (entry == NULL) {
		wxLogError(wxT("Cannot find the callsign \"%s\" in the APRS array"), callsign.c_str());
		return;
	}

	CAPRSCollector* collector = entry->getCollector();

	if (data.isSync()) {
		collector->sync();
		return;
	}

	unsigned char buffer[400U];
	data.getData(buffer, DV_FRAME_MAX_LENGTH_BYTES);

	bool complete = collector->writeData(buffer + VOICE_FRAME_LENGTH_BYTES);
	if (!complete)
		return;

	if (!m_enabled) {
		collector->reset();
		return;
	}

	if (!m_thread->isConnected()) {
		collector->reset();
		return;
	}

	// Check the transmission timer
	bool ok = entry->isOK();
	if (!ok) {
		collector->reset();
		return;
	}

	unsigned int length = collector->getData(buffer, 400U);
	wxString text((char*)buffer, wxConvLocal, length);

	int n = text.Find(wxT(':'));
	if (n == wxNOT_FOUND) {
		collector->reset();
		return;
	}

	wxString header = text.Left(n);
	wxString body   = text.Mid(n + 1U);

	// If we already have a q-construct, don't send it on
	n = header.Find(wxT('q'));
	if (n != wxNOT_FOUND)
		return;

	// Remove the trailing \r
	n = body.Find(wxT('\r'));
	if (n != wxNOT_FOUND)
		body = body.Left(n);

	wxString output;
	output.Printf(wxT("%s,qAR,%s-%s:%s"), header.c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(), body.c_str());

	char ascii[500U];
	::memset(ascii, 0x00, 500U);
	for (unsigned int i = 0U; i < output.Len(); i++)
		ascii[i] = output.GetChar(i);

	m_thread->write(ascii);

	collector->reset();
}
开发者ID:BackupTheBerlios,项目名称:opendv-svn,代码行数:76,代码来源:APRSWriter.cpp

示例3: writeData

void CTextCollector::writeData(const CAMBEData& data)
{
	if (data.isSync()) {
		sync();
		return;
	}

	unsigned char buffer[DV_FRAME_MAX_LENGTH_BYTES];
	data.getData(buffer, DV_FRAME_MAX_LENGTH_BYTES);

	switch (m_slowData) {
		case SS_FIRST:
			m_buffer[0U] = buffer[VOICE_FRAME_LENGTH_BYTES + 0U] ^ SCRAMBLER_BYTE1;
			m_buffer[1U] = buffer[VOICE_FRAME_LENGTH_BYTES + 1U] ^ SCRAMBLER_BYTE2;
			m_buffer[2U] = buffer[VOICE_FRAME_LENGTH_BYTES + 2U] ^ SCRAMBLER_BYTE3;
			m_slowData = SS_SECOND;
			return;

		case SS_SECOND:
			m_buffer[3U] = buffer[VOICE_FRAME_LENGTH_BYTES + 0U] ^ SCRAMBLER_BYTE1;
			m_buffer[4U] = buffer[VOICE_FRAME_LENGTH_BYTES + 1U] ^ SCRAMBLER_BYTE2;
			m_buffer[5U] = buffer[VOICE_FRAME_LENGTH_BYTES + 2U] ^ SCRAMBLER_BYTE3;
			m_slowData = SS_FIRST;
			break;
	}

	switch (m_buffer[0U]) {
		case SLOW_DATA_TYPE_TEXT | 0U:
			m_data[0U] = m_buffer[1U] & 0x7FU;
			m_data[1U] = m_buffer[2U] & 0x7FU;
			m_data[2U] = m_buffer[3U] & 0x7FU;
			m_data[3U] = m_buffer[4U] & 0x7FU;
			m_data[4U] = m_buffer[5U] & 0x7FU;
			m_has0 = true;
			break;
		case SLOW_DATA_TYPE_TEXT | 1U:
			m_data[5U] = m_buffer[1U] & 0x7FU;
			m_data[6U] = m_buffer[2U] & 0x7FU;
			m_data[7U] = m_buffer[3U] & 0x7FU;
			m_data[8U] = m_buffer[4U] & 0x7FU;
			m_data[9U] = m_buffer[5U] & 0x7FU;
			m_has1 = true;
			break;
		case SLOW_DATA_TYPE_TEXT | 2U:
			m_data[10U] = m_buffer[1U] & 0x7FU;
			m_data[11U] = m_buffer[2U] & 0x7FU;
			m_data[12U] = m_buffer[3U] & 0x7FU;
			m_data[13U] = m_buffer[4U] & 0x7FU;
			m_data[14U] = m_buffer[5U] & 0x7FU;
			m_has2 = true;
			break;
		case SLOW_DATA_TYPE_TEXT | 3U:
			m_data[15U] = m_buffer[1U] & 0x7FU;
			m_data[16U] = m_buffer[2U] & 0x7FU;
			m_data[17U] = m_buffer[3U] & 0x7FU;
			m_data[18U] = m_buffer[4U] & 0x7FU;
			m_data[19U] = m_buffer[5U] & 0x7FU;
			m_has3 = true;
			break;
		default:
			break;
	}
}
开发者ID:KH6VM,项目名称:OpenSystemFusion,代码行数:63,代码来源:TextCollector.cpp


注:本文中的CAMBEData::isSync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。