begin to support 3000 devices

main
Tom Early 4 years ago
parent b73f547440
commit 1939a5af5e

@ -52,7 +52,7 @@ void CController::Stop()
reader.Close(); reader.Close();
dstar_device.CloseDevice(); dstar_device.CloseDevice();
dmr_device.CloseDevice(); dmrst_device.CloseDevice();
} }
bool CController::CheckTCModules() const bool CController::CheckTCModules() const
@ -152,18 +152,31 @@ bool CController::InitDevices()
return true; return true;
} }
const auto desc(deviceset.front().second);
if (deviceset.back().second.compare(desc))
{
std::cerr << "Both devices have to be the same type: " << desc << " != " << deviceset.back().second << std::endl;
return true;
}
Edvtype dvtype = Edvtype::dv3003;
if (0==desc.compare("ThumbDV") || 0==desc.compare("DVstick-33") || 0==desc.compare("USB-3000"))
dvtype = Edvtype::dv3000;
//initialize each device //initialize each device
while (! deviceset.empty()) while (! deviceset.empty())
{ {
dstar_device.OpenDevice(deviceset.front().first, deviceset.front().second, 921600); if (dstar_device.OpenDevice(deviceset.front().first, deviceset.front().second, dvtype))
return true;
deviceset.pop_front(); deviceset.pop_front();
dmr_device.OpenDevice(deviceset.front().first, deviceset.front().second, 921600); if (dmrst_device.OpenDevice(deviceset.front().first, deviceset.front().second, dvtype))
return true;
deviceset.pop_front(); deviceset.pop_front();
} }
// and start them up! // and start them up!
dstar_device.Start(); dstar_device.Start();
dmr_device.Start(); dmrst_device.Start();
deviceset.clear(); deviceset.clear();
@ -190,7 +203,7 @@ void CController::ReadReflectorThread()
dstar_device.AddPacket(packet); dstar_device.AddPacket(packet);
break; break;
case ECodecType::dmr: case ECodecType::dmr:
dmr_device.AddPacket(packet); dmrst_device.AddPacket(packet);
break; break;
case ECodecType::c2_1600: case ECodecType::c2_1600:
case ECodecType::c2_3200: case ECodecType::c2_3200:
@ -284,7 +297,7 @@ void CController::Codec2toAudio(std::shared_ptr<CTranscoderPacket> packet)
} }
// the only thing left is to encode the two ambe, so push the packet onto both AMBE queues // the only thing left is to encode the two ambe, so push the packet onto both AMBE queues
dstar_device.AddPacket(packet); dstar_device.AddPacket(packet);
dmr_device.AddPacket(packet); dmrst_device.AddPacket(packet);
} }
void CController::ProcessC2Thread() void CController::ProcessC2Thread()
@ -329,7 +342,7 @@ void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
{ {
// codec_in is dstar, the audio has just completed, so now calc the M17 and DMR // codec_in is dstar, the audio has just completed, so now calc the M17 and DMR
codec2_queue.push(packet); codec2_queue.push(packet);
dmr_device.AddPacket(packet); dmrst_device.AddPacket(packet);
} }
else if (packet->AllCodecsAreSet()) else if (packet->AllCodecsAreSet())
{ {

@ -29,12 +29,10 @@
#include "UnixDgramSocket.h" #include "UnixDgramSocket.h"
#include "configure.h" #include "configure.h"
enum class EAmbeType { dstar, dmr };
class CController class CController
{ {
public: public:
std::mutex dstar_mux, dmr_mux; std::mutex dstar_mux, dmrst_mux;
CController(); CController();
bool Start(); bool Start();
@ -52,7 +50,7 @@ protected:
CUnixDgramWriter writer; CUnixDgramWriter writer;
std::unordered_map<char, std::unique_ptr<CCodec2>> c2_16, c2_32; std::unordered_map<char, std::unique_ptr<CCodec2>> c2_16, c2_32;
CDV3003 dstar_device{Encoding::dstar}; CDV3003 dstar_device{Encoding::dstar};
CDV3003 dmr_device{Encoding::dmr}; CDV3003 dmrst_device{Encoding::dmrsf};
CPacketQueue codec2_queue; CPacketQueue codec2_queue;
std::mutex send_mux; std::mutex send_mux;

@ -7,7 +7,7 @@
*/ */
// tcd - a hybid transcoder using DVSI hardware and Codec2 software // tcd - a hybid transcoder using DVSI hardware and Codec2 software
// Copyright © 2021 Thomas A. Early N7TAE // Copyright © 2022 Thomas A. Early N7TAE
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@
extern CController Controller; extern CController Controller;
CDV3003::CDV3003(Encoding t) : type(t), ftHandle(nullptr), buffer_depth(0) CDV3003::CDV3003(Encoding t) : type(t), ftHandle(nullptr), buffer_depth(0), keep_running(true)
{ {
} }
@ -145,7 +145,7 @@ std::string CDV3003::GetDescription() const
return description; return description;
} }
bool CDV3003::OpenDevice(const std::string &serialno, const std::string &desc, int baudrate) bool CDV3003::OpenDevice(const std::string &serialno, const std::string &desc, Edvtype dvtype)
{ {
auto status = FT_OpenEx((PVOID)serialno.c_str(), FT_OPEN_BY_SERIAL_NUMBER, &ftHandle); auto status = FT_OpenEx((PVOID)serialno.c_str(), FT_OPEN_BY_SERIAL_NUMBER, &ftHandle);
if (FT_OK != status) if (FT_OK != status)
@ -201,7 +201,7 @@ bool CDV3003::OpenDevice(const std::string &serialno, const std::string &desc, i
} }
} }
status = FT_SetBaudRate(ftHandle, baudrate ); status = FT_SetBaudRate(ftHandle, (Edvtype::dv3000 == dvtype) ? 460800 : 921600);
if (status != FT_OK) if (status != FT_OK)
{ {
FTDI_Error("FT_SetBaudRate", status); FTDI_Error("FT_SetBaudRate", status);
@ -237,7 +237,8 @@ bool CDV3003::OpenDevice(const std::string &serialno, const std::string &desc, i
if (InitDV3003()) if (InitDV3003())
return true; return true;
for (uint8_t ch=PKT_CHANNEL0; ch<=PKT_CHANNEL2; ch++) const uint8_t limit = (Edvtype::dv3000 == dvtype) ? PKT_CHANNEL0 : PKT_CHANNEL2;
for (uint8_t ch=PKT_CHANNEL0; ch<=limit; ch++)
{ {
if (ConfigureVocoder(ch, type)) if (ConfigureVocoder(ch, type))
return true; return true;
@ -383,7 +384,6 @@ bool CDV3003::InitDV3003()
void CDV3003::Start() void CDV3003::Start()
{ {
keep_running = true;
feedFuture = std::async(std::launch::async, &CDV3003::FeedDevice, this); feedFuture = std::async(std::launch::async, &CDV3003::FeedDevice, this);
readFuture = std::async(std::launch::async, &CDV3003::ReadDevice, this); readFuture = std::async(std::launch::async, &CDV3003::ReadDevice, this);
} }
@ -609,9 +609,9 @@ void CDV3003::ReadDevice()
} }
else else
{ {
Controller.dmr_mux.lock(); Controller.dmrst_mux.lock();
Controller.RouteDmrPacket(packet); Controller.RouteDmrPacket(packet);
Controller.dmr_mux.unlock(); Controller.dmrst_mux.unlock();
} }
} }
} }

@ -1,7 +1,7 @@
#pragma once #pragma once
// tcd - a hybid transcoder using DVSI hardware and Codec2 software // tcd - a hybid transcoder using DVSI hardware and Codec2 software
// Copyright © 2021 Thomas A. Early N7TAE // Copyright © 2022 Thomas A. Early N7TAE
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -98,13 +98,14 @@ struct dv3003_packet {
using SDV3003_Packet = struct dv3003_packet; using SDV3003_Packet = struct dv3003_packet;
enum class Encoding { dstar, dmr }; enum class Encoding { dstar, dmrsf };
enum class Edvtype { dv3000, dv3003 };
class CDV3003 { class CDV3003 {
public: public:
CDV3003(Encoding t); CDV3003(Encoding t);
~CDV3003(); ~CDV3003();
bool OpenDevice(const std::string &serialno, const std::string &desc, int baudrate); bool OpenDevice(const std::string &serialno, const std::string &desc, Edvtype dvtype);
void Start(); void Start();
void CloseDevice(); void CloseDevice();
std::string GetDescription() const; std::string GetDescription() const;

Loading…
Cancel
Save

Powered by TurnKey Linux.