diff --git a/Controller.cpp b/Controller.cpp index b25c9e6..523afca 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -52,7 +52,7 @@ void CController::Stop() reader.Close(); dstar_device.CloseDevice(); - dmrst_device.CloseDevice(); + dmrsf_device.CloseDevice(); } bool CController::CheckTCModules() const @@ -163,20 +163,26 @@ bool CController::InitDevices() if (0==desc.compare("ThumbDV") || 0==desc.compare("DVstick-33") || 0==desc.compare("USB-3000")) dvtype = Edvtype::dv3000; + if (modules.size() > ((Edvtype::dv3000 == dvtype) ? 1 : 3)) + { + std::cerr << "Too many transcoded modules for the devices" << std::endl; + return true; + } + //initialize each device while (! deviceset.empty()) { if (dstar_device.OpenDevice(deviceset.front().first, deviceset.front().second, dvtype)) return true; deviceset.pop_front(); - if (dmrst_device.OpenDevice(deviceset.front().first, deviceset.front().second, dvtype)) + if (dmrsf_device.OpenDevice(deviceset.front().first, deviceset.front().second, dvtype)) return true; deviceset.pop_front(); } // and start them up! dstar_device.Start(); - dmrst_device.Start(); + dmrsf_device.Start(); deviceset.clear(); @@ -203,7 +209,7 @@ void CController::ReadReflectorThread() dstar_device.AddPacket(packet); break; case ECodecType::dmr: - dmrst_device.AddPacket(packet); + dmrsf_device.AddPacket(packet); break; case ECodecType::c2_1600: case ECodecType::c2_3200: @@ -297,7 +303,7 @@ void CController::Codec2toAudio(std::shared_ptr packet) } // the only thing left is to encode the two ambe, so push the packet onto both AMBE queues dstar_device.AddPacket(packet); - dmrst_device.AddPacket(packet); + dmrsf_device.AddPacket(packet); } void CController::ProcessC2Thread() @@ -342,7 +348,7 @@ void CController::RouteDstPacket(std::shared_ptr packet) { // codec_in is dstar, the audio has just completed, so now calc the M17 and DMR codec2_queue.push(packet); - dmrst_device.AddPacket(packet); + dmrsf_device.AddPacket(packet); } else if (packet->AllCodecsAreSet()) { diff --git a/Controller.h b/Controller.h index c87c7db..e2f1032 100644 --- a/Controller.h +++ b/Controller.h @@ -50,7 +50,7 @@ protected: CUnixDgramWriter writer; std::unordered_map> c2_16, c2_32; CDVDevice dstar_device{Encoding::dstar}; - CDVDevice dmrst_device{Encoding::dmrsf}; + CDVDevice dmrsf_device{Encoding::dmrsf}; CPacketQueue codec2_queue; std::mutex send_mux; diff --git a/DVSIDevice.cpp b/DVSIDevice.cpp index 82bfe2f..44b9bfd 100644 --- a/DVSIDevice.cpp +++ b/DVSIDevice.cpp @@ -223,7 +223,7 @@ bool CDVDevice::OpenDevice(const std::string &serialno, const std::string &desc, return true; } - // No timeouts! FT_Read blocks! + // No timeouts! we want blocking FT_Read // status = FT_SetTimeouts(ftHandle, 200, 200 ); // if (status != FT_OK) // { @@ -237,7 +237,7 @@ bool CDVDevice::OpenDevice(const std::string &serialno, const std::string &desc, std::cout << "Opened " << description << std::endl; - if (InitDV3003()) + if (InitDevice()) return true; const uint8_t limit = (Edvtype::dv3000 == dvtype) ? PKT_CHANNEL0 : PKT_CHANNEL2; @@ -249,7 +249,7 @@ bool CDVDevice::OpenDevice(const std::string &serialno, const std::string &desc, return false; } -bool CDVDevice::InitDV3003() +bool CDVDevice::InitDevice() { SDV_Packet responsePacket, ctrlPacket; diff --git a/DVSIDevice.h b/DVSIDevice.h index 02e25a7..e49e8e6 100644 --- a/DVSIDevice.h +++ b/DVSIDevice.h @@ -125,7 +125,7 @@ private: void FTDI_Error(const char *where, FT_STATUS status) const; void FeedDevice(); void ReadDevice(); - bool InitDV3003(); + bool InitDevice(); bool ConfigureVocoder(uint8_t pkt_ch, Encoding type); bool checkResponse(SDV_Packet &responsePacket, uint8_t response) const; bool SendAudio(const uint8_t channel, const int16_t *audio) const;