Ejemplo n.º 1
0
uint8_t CCWIdTX::write(const uint8_t* data, uint8_t length)
{
  ::memset(m_poBuffer, 0x00U, 1000U * sizeof(uint8_t));

  m_poLen = 8U;
  m_poPtr = 0U;
  m_n     = 0U;

  for (uint8_t i = 0U; i < length; i++) {
    for (uint8_t j = 0U; SYMBOL_LIST[j].c != 0U; j++) {
      if (SYMBOL_LIST[j].c == data[i]) {
        uint32_t MASK = 0x80000000U;
        for (uint8_t k = 0U; k < SYMBOL_LIST[j].length; k++, m_poLen++, MASK >>= 1) {
          bool b = (SYMBOL_LIST[j].pattern & MASK) == MASK;
          WRITE_BIT1(m_poBuffer, m_poLen, b);

          if (m_poLen >= 995U) {
            m_poLen = 0U;
            return 4U;
          }
        }

        break;
      }
    }
  }
Ejemplo n.º 2
0
void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* data)
{
	assert(dt != NULL);
	assert(data != NULL);

	data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;

	unsigned char output[25U];
	for (unsigned int i = 0U; i < 20U; i++)
		output[i] = dt[i] ^ WHITENING_DATA[i];

	CCRC::addCCITT16(output, 22U);
	output[22U] = 0x00U;

	unsigned char convolved[45U];

	CYSFConvolution conv;
	conv.encode(output, convolved, 180U);

	unsigned char bytes[45U];
	unsigned int j = 0U;
	for (unsigned int i = 0U; i < 180U; i++) {
		unsigned int n = INTERLEAVE_TABLE_9_20[i];

		bool s0 = READ_BIT1(convolved, j) != 0U;
		j++;

		bool s1 = READ_BIT1(convolved, j) != 0U;
		j++;

		WRITE_BIT1(bytes, n, s0);

		n++;
		WRITE_BIT1(bytes, n, s1);
	}

	unsigned char* p1 = data + 9U;
	unsigned char* p2 = bytes;
	for (unsigned int i = 0U; i < 5U; i++) {
		::memcpy(p1, p2, 9U);
		p1 += 18U; p2 += 9U;
	}
}
Ejemplo n.º 3
0
uint8_t CDMRTX::writeShortLC(const uint8_t* data, uint8_t length)
{
  if (length != 9U)
    return 4U;

  ::memset(m_newShortLC, 0x00U, 12U);
  
  for (uint8_t i = 0U; i < 68U; i++) {
    bool b = READ_BIT1(data, i);
    uint8_t n = CACH_INTERLEAVE[i];
    WRITE_BIT1(m_newShortLC, n, b);
  }

  return 0U;
}
Ejemplo n.º 4
0
uint8_t CDMRTX::writeShortLC(const uint8_t* data, uint8_t length)
{
  if (length != 9U)
    return 4U;

  ::memset(m_newShortLC, 0x00U, 12U);
  
  for (uint8_t i = 0U; i < 68U; i++) {
    bool b = READ_BIT1(data, i);
    uint8_t n = CACH_INTERLEAVE[i];
    WRITE_BIT1(m_newShortLC, n, b);
  }

  // Set the LCSS bits
  m_newShortLC[1U]  |= 0x08U;
  m_newShortLC[4U]  |= 0x88U;
  m_newShortLC[7U]  |= 0x88U;
  m_newShortLC[10U] |= 0x80U;

  return 0U;
}
Ejemplo n.º 5
0
int CWAV2AMBE::run()
{
	CWAVFileReader reader(m_input, AUDIO_BLOCK_SIZE);
	bool ret = reader.open();
	if (!ret)
		return 1;

	if (reader.getSampleRate() != AUDIO_SAMPLE_RATE) {
		::fprintf(stderr, "WAV2AMBE: input file has the wrong sample rate\n");
		reader.close();
		return 1;
	}

	if (reader.getChannels() > 1U) {
		::fprintf(stderr, "WAV2AMBE: input file has too many channels\n");
		reader.close();
		return 1;
	}

	CAMBEFileWriter writer(m_output, m_signature);
	ret = writer.open();
	if (!ret) {
		reader.close();
		return 1;
	}

	if (m_mode == MODE_P25) {
		float audioFloat[AUDIO_BLOCK_SIZE];
		while (reader.read(audioFloat, AUDIO_BLOCK_SIZE) == AUDIO_BLOCK_SIZE) {
			imbe_vocoder vocoder;

			int16_t audioInt[AUDIO_BLOCK_SIZE];
			for (unsigned int i = 0U; i < AUDIO_BLOCK_SIZE; i++)
				audioInt[i] = int16_t((audioFloat[i] * 128) + 128);

			int16_t frameInt[88U];
			vocoder.imbe_encode(frameInt, audioInt);

			unsigned char frame[11U];
			for (unsigned int i = 0U; i < 88U; i++)
				WRITE_BIT1(frame, i, frameInt[i] != 0);

			if (m_fec) {
				uint8_t data[18U];

				CIMBEFEC fec;
				fec.encode(data, frame);

				writer.write(data, 18U);
			} else {
				writer.write(frame, 11U);
			}
		}
	} else {
		CDV3000SerialController controller(m_port, m_speed, m_mode, m_fec, m_amplitude, m_reset, &reader, &writer);
		ret = controller.open();
		if (!ret) {
			writer.close();
			reader.close();
			return 1;
		}

		controller.process();

		controller.close();
	}

	writer.close();
	reader.close();

	return 0;
}