Modify the protocol and simplify the speech generation.

This commit is contained in:
Jonathan Naylor 2016-11-01 19:09:31 +00:00
parent 168cdbeec7
commit 411173efdc
3 changed files with 75 additions and 74 deletions

View File

@ -307,8 +307,8 @@ void CP25Gateway::run()
lostTimer.start();
}
}
} else if (buffer[0U] == 0x6AU || buffer[0U] == 0x73U) {
if (buffer[15U] == 0x00U && speech != NULL)
} else if (buffer[0U] == 0x80U) {
if (speech != NULL)
speech->eof();
}

View File

@ -31,12 +31,63 @@
const unsigned int SRC_ID = 10999U;
const unsigned char REC62[] = {
0x62U, 0x02U, 0x02U, 0x0CU, 0x0BU, 0x35U, 0xA3U, 0x1AU, 0x65U, 0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
0x62U, 0x02U, 0x02U, 0x0CU, 0x0BU, 0x1BU, 0x5AU, 0x1AU, 0x2BU, 0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC63[] = {
0x63U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x7AU };
const unsigned char REC64[] = {
0x64U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC65[] = {
0x65U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC66[] = {
0x66U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC67[] = {
0x67U, 0xC4U, 0x52U, 0x9BU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC68[] = {
0x68U, 0x9AU, 0xECU, 0xBAU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC69[] = {
0x69U, 0xB9U, 0xD8U, 0x16U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC6A[] = {
0x6AU, 0x00U, 0x00U, 0x06U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC6B[] = {
0x6BU, 0x02U, 0x02U, 0x0CU, 0x0BU, 0x35U, 0xA3U, 0x1AU, 0x64U, 0x9CU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
0x6BU, 0x02U, 0x02U, 0x0CU, 0x0BU, 0x1BU, 0x5AU, 0x1AU, 0x2BU, 0xACU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC6C[] = {
0x6CU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0xD6U };
const unsigned char REC6D[] = {
0x6DU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC6E[] = {
0x6EU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC6F[] = {
0x6FU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC70[] = {
0x70U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC71[] = {
0x71U, 0xACU, 0xB8U, 0xA4U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC72[] = {
0x72U, 0x9BU, 0xDCU, 0x75U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC73[] = {
0x73U, 0x00U, 0x00U, 0x06U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x02U };
const unsigned char REC80[] = {
0x80U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U };
CSpeech::CSpeech(CNetwork& network, const in_addr& address, unsigned int port) :
m_network(network),
@ -135,81 +186,55 @@ void CSpeech::clock(unsigned int ms)
m_n = 0x63U;
break;
case 0x63U:
::memset(buffer, 0x00U, 14U);
buffer[0U] = 0x63U;
buffer[13U] = 0x7AU;
::memcpy(buffer, REC63, 14U);
::memcpy(buffer + 1U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 14U, m_address, m_port);
m_n = 0x64U;
break;
case 0x64U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x64U;
buffer[16U] = 0x02U;
::memcpy(buffer, REC64, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x65U;
break;
case 0x65U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x65U;
::memcpy(buffer, REC65, 17U);
buffer[1U] = (m_id >> 16) & 0xFFU;
buffer[2U] = (m_id >> 8) & 0xFFU;
buffer[3U] = (m_id >> 0) & 0xFFU;
buffer[16U] = 0x02U;
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x66U;
break;
case 0x66U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x66U;
::memcpy(buffer, REC66, 17U);
buffer[1U] = (SRC_ID >> 16) & 0xFFU;
buffer[2U] = (SRC_ID >> 8) & 0xFFU;
buffer[3U] = (SRC_ID >> 0) & 0xFFU;
buffer[16U] = 0x02U;
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x67U;
break;
case 0x67U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x67U;
buffer[1U] = 0x28U; // XXX ???
buffer[2U] = 0xD6U; // XXX ???
buffer[3U] = 0x58U; // XXX ???
buffer[16U] = 0x02U;
::memcpy(buffer, REC67, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x68U;
break;
case 0x68U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x68U;
buffer[1U] = 0xA0U; // XXX ???
buffer[2U] = 0x81U; // XXX ???
buffer[3U] = 0x9CU; // XXX ???
buffer[16U] = 0x02U;
::memcpy(buffer, REC68, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x69U;
break;
case 0x69U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x69U;
buffer[1U] = 0x0EU; // XXX ???
buffer[2U] = 0x74U; // XXX ???
buffer[3U] = 0xBCU; // XXX ???
buffer[16U] = 0x02U;
::memcpy(buffer, REC69, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x6AU;
break;
case 0x6AU:
::memset(buffer, 0x00U, 16U);
buffer[0U] = 0x6AU;
buffer[3U] = 0x0EU; // XXX ???
buffer[15U] = (m_pos == (m_count - 1U)) ? 0x00U : 0x02U;
::memcpy(buffer, REC6A, 16U);
::memcpy(buffer + 4U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 16U, m_address, m_port);
m_n = 0x6BU;
@ -221,74 +246,49 @@ void CSpeech::clock(unsigned int ms)
m_n = 0x6CU;
break;
case 0x6CU:
::memset(buffer, 0x00U, 14U);
buffer[0U] = 0x6CU;
buffer[12U] = 0x02U;
buffer[13U] = 0xF6U;
::memcpy(buffer, REC6C, 14U);
::memcpy(buffer + 1U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 14U, m_address, m_port);
m_n = 0x6DU;
break;
case 0x6DU:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x6DU;
buffer[16U] = 0x02U;
::memcpy(buffer, REC6D, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x6EU;
break;
case 0x6EU:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x6EU;
buffer[16U] = 0x02U;
::memcpy(buffer, REC6E, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x6FU;
break;
case 0x6FU:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x6FU;
buffer[16U] = 0x02U;
::memcpy(buffer, REC6F, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x70U;
break;
case 0x70U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x70U;
buffer[1U] = 0x80U;
buffer[16U] = 0x02U;
::memcpy(buffer, REC70, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x71U;
break;
case 0x71U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x71U;
buffer[1U] = 0xACU; // XXX ???
buffer[2U] = 0xB8U; // XXX ???
buffer[3U] = 0xA4U; // XXX ???
buffer[16U] = 0x02U;
::memcpy(buffer, REC71, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x72U;
break;
case 0x72U:
::memset(buffer, 0x00U, 17U);
buffer[0U] = 0x72U;
buffer[1U] = 0x9BU; // XXX ???
buffer[2U] = 0xDCU; // XXX ???
buffer[3U] = 0x75U; // XXX ???
buffer[16U] = 0x02U;
::memcpy(buffer, REC72, 17U);
::memcpy(buffer + 5U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 17U, m_address, m_port);
m_n = 0x73U;
break;
default:
::memset(buffer, 0x00U, 16U);
buffer[0U] = 0x73U;
buffer[3U] = 0x06U; // XXX ???
buffer[15U] = (m_pos == (m_count - 1U)) ? 0x00U : 0x02U;
::memcpy(buffer, REC73, 16U);
::memcpy(buffer + 4U, m_speech + (m_pos * 11U), 11U);
m_network.writeData(buffer, 16U, m_address, m_port);
m_n = 0x62U;
@ -296,6 +296,7 @@ void CSpeech::clock(unsigned int ms)
}
if (m_pos == (m_count - 1U)) {
m_network.writeData(REC80, 17U, m_address, m_port);
m_state = SS_NONE;
m_id = 0U;
return;

View File

@ -103,7 +103,7 @@ void CP25Parrot::run()
parrot.write(buffer, len);
watchdogTimer.start();
if ((buffer[0U] == 0x6AU && buffer[15U] == 0x00U) || (buffer[0U] == 0x73U && buffer[15U] == 0x00U)) {
if (buffer[0U] == 0x80U) {
LogDebug("Received end of transmission");
turnaroundTimer.start();
watchdogTimer.stop();