amber 1.3.2

fixed problem while running multiple 3006 or 3012 devices
adjusted load sharing when running multiple devices
This commit is contained in:
LX3JL 2018-06-25 18:41:24 +02:00
parent 1399eeb696
commit 71cddc2f5a
6 changed files with 106 additions and 39 deletions

View File

@ -132,6 +132,33 @@ int CFtdiDeviceDescr::CreateInterfacePair(CFtdiDeviceDescr *descr1, CFtdiDeviceD
////////////////////////////////////////////////////////////////////////////////////////
// get
const char * CFtdiDeviceDescr::GetChannelDescription(int ch) const
{
static char descr[FTDI_MAX_STRINGLENGTH];
char tag[3] = "_X";
::strcpy(descr, GetDescription());
if ( ::strlen(descr) >= 2 )
{
descr[::strlen(descr)-2] = 0x00;
tag[1] = (char)ch + 'A';
::strcat(descr, tag);
}
return descr;
}
const char * CFtdiDeviceDescr::GetChannelSerialNumber(int ch) const
{
static char serial[FTDI_MAX_STRINGLENGTH];
::strcpy(serial, GetSerialNumber());
if ( ::strlen(serial) >= 1 )
{
serial[::strlen(serial)-1] = (char)ch + 'A';
}
return serial;
}
int CFtdiDeviceDescr::GetNbChannels(void) const
{
int iNbChs = 0;
@ -180,13 +207,13 @@ int CFtdiDeviceDescr::CreateUsb3012(CFtdiDeviceDescr *descr, std::vector<CVocode
// create the interfaces for the four 3003 chips
CUsb3003HRInterface *Usb3003A =
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), "USB-3012_A", descr->GetSerialNumber());
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), descr->GetChannelDescription(0), descr->GetChannelSerialNumber(0));
CUsb3003HRInterface *Usb3003B =
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), "USB-3012_B", descr->GetSerialNumber());
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), descr->GetChannelDescription(1), descr->GetChannelSerialNumber(1));
CUsb3003HRInterface *Usb3003C =
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), "USB-3012_C", descr->GetSerialNumber());
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), descr->GetChannelDescription(2), descr->GetChannelSerialNumber(2));
CUsb3003HRInterface *Usb3003D =
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), "USB-3012_D", descr->GetSerialNumber());
new CUsb3003HRInterface(descr->GetVid(), descr->GetPid(), descr->GetChannelDescription(3), descr->GetChannelSerialNumber(3));
// init the interfaces
if ( Usb3003A->Init(CODEC_AMBEPLUS) && Usb3003B->Init(CODEC_AMBE2PLUS) &&
@ -212,31 +239,31 @@ int CFtdiDeviceDescr::CreateUsb3012(CFtdiDeviceDescr *descr, std::vector<CVocode
channels->push_back(Channel);
Usb3003B->AddChannel(Channel);
// ch5
Channel = new CVocodecChannel(Usb3003C, 0, Usb3003C, 1, CODECGAIN_AMBEPLUS);
channels->push_back(Channel);
Usb3003C->AddChannel(Channel);
// ch6
Channel = new CVocodecChannel(Usb3003C, 1, Usb3003C, 0, CODECGAIN_AMBE2PLUS);
channels->push_back(Channel);
Usb3003C->AddChannel(Channel);
// ch7
Channel = new CVocodecChannel(Usb3003D, 0, Usb3003D, 1, CODECGAIN_AMBEPLUS);
channels->push_back(Channel);
Usb3003D->AddChannel(Channel);
// ch8
Channel = new CVocodecChannel(Usb3003D, 1, Usb3003D, 0, CODECGAIN_AMBE2PLUS);
channels->push_back(Channel);
Usb3003D->AddChannel(Channel);
// ch9
Channel = new CVocodecChannel(Usb3003A, 2, Usb3003B, 2, CODECGAIN_AMBEPLUS);
channels->push_back(Channel);
Usb3003A->AddChannel(Channel);
Usb3003B->AddChannel(Channel);
// ch10
// ch6
Channel = new CVocodecChannel(Usb3003B, 2, Usb3003A, 2, CODECGAIN_AMBE2PLUS);
channels->push_back(Channel);
Usb3003A->AddChannel(Channel);
Usb3003B->AddChannel(Channel);
// ch7
Channel = new CVocodecChannel(Usb3003C, 0, Usb3003C, 1, CODECGAIN_AMBEPLUS);
channels->push_back(Channel);
Usb3003C->AddChannel(Channel);
// ch8
Channel = new CVocodecChannel(Usb3003C, 1, Usb3003C, 0, CODECGAIN_AMBE2PLUS);
channels->push_back(Channel);
Usb3003C->AddChannel(Channel);
// ch9
Channel = new CVocodecChannel(Usb3003D, 0, Usb3003D, 1, CODECGAIN_AMBEPLUS);
channels->push_back(Channel);
Usb3003D->AddChannel(Channel);
// ch10
Channel = new CVocodecChannel(Usb3003D, 1, Usb3003D, 0, CODECGAIN_AMBE2PLUS);
channels->push_back(Channel);
Usb3003D->AddChannel(Channel);
// ch11
Channel = new CVocodecChannel(Usb3003C, 2, Usb3003D, 2, CODECGAIN_AMBEPLUS);
channels->push_back(Channel);
@ -273,13 +300,13 @@ int CFtdiDeviceDescr::CreateUsb3012(CFtdiDeviceDescr *descr, std::vector<CVocode
//
int CFtdiDeviceDescr::CreateUsb3006(CFtdiDeviceDescr *descr, std::vector<CVocodecChannel *>*channels)
{
int nStreams = 0;
int nStreams = 0;
// create the interfaces for the four 3003 chips
// create the interfaces for the two 3003 chips
CUsb3003Interface *Usb3003A =
new CUsb3003Interface(descr->GetVid(), descr->GetPid(), "USB-3006_A", descr->GetSerialNumber());
new CUsb3003Interface(descr->GetVid(), descr->GetPid(), descr->GetChannelDescription(0), descr->GetChannelSerialNumber(0));
CUsb3003Interface *Usb3003B =
new CUsb3003Interface(descr->GetVid(), descr->GetPid(), "USB-3006_B", descr->GetSerialNumber());
new CUsb3003Interface(descr->GetVid(), descr->GetPid(), descr->GetChannelDescription(1), descr->GetChannelSerialNumber(1));
// init the interfaces
if ( Usb3003A->Init(CODEC_AMBEPLUS) && Usb3003B->Init(CODEC_AMBE2PLUS) )

View File

@ -58,12 +58,15 @@ public:
static int CreateInterfacePair(CFtdiDeviceDescr *, CFtdiDeviceDescr *, std::vector<CVocodecChannel *>*);
// get
bool IsUsed(void) const { return m_bUsed; }
bool IsUsed(void) const { return m_bUsed; }
int GetNbChannels(void) const;
uint32 GetVid(void) const { return m_uiVid; }
uint32 GetPid(void) const { return m_uiPid; }
const char *GetDescription(void) const { return m_szDescription; }
const char *GetSerialNumber(void) const { return m_szSerial; }
uint32 GetVid(void) const { return m_uiVid; }
uint32 GetPid(void) const { return m_uiPid; }
const char *GetDescription(void) const { return m_szDescription; }
const char *GetSerialNumber(void) const { return m_szSerial; }
const char * GetChannelDescription(int) const;
const char * GetChannelSerialNumber(int) const;
// set
void SetUsed(bool used) { m_bUsed = used; }

View File

@ -209,9 +209,9 @@ bool CUsb3003Interface::OpenDevice(void)
ftStatus = FT_SetVIDPID(m_uiVid, m_uiPid);
if (ftStatus != FT_OK) {FTDI_Error((char *)"FT_SetVIDPID", ftStatus ); return false; }
ftStatus = FT_OpenEx((PVOID)m_szDeviceName, FT_OPEN_BY_DESCRIPTION, &m_FtdiHandle);
ftStatus = FT_OpenEx((PVOID)m_szDeviceSerial, FT_OPEN_BY_SERIAL_NUMBER, &m_FtdiHandle);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_OpenEx", ftStatus ); return false; }
CTimePoint::TaskSleepFor(50);
FT_Purge(m_FtdiHandle, FT_PURGE_RX | FT_PURGE_TX );
CTimePoint::TaskSleepFor(50);

View File

@ -88,13 +88,14 @@ bool CVocodecs::Init(void)
// and create interfaces for the discovered devices
// first handle all even number of channels devices
std::vector<CVocodecChannel *> Multi3003DevicesChs;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{
CFtdiDeviceDescr *descr = m_FtdiDeviceDescrs[i];
if ( !descr->IsUsed() && IsEven(descr->GetNbChannels()) )
{
// create the object
iNbCh += CFtdiDeviceDescr::CreateInterface(descr, &m_Channels);
iNbCh += CFtdiDeviceDescr::CreateInterface(descr, &Multi3003DevicesChs);
// and flag as used
descr->SetUsed(true);
}
@ -102,6 +103,7 @@ bool CVocodecs::Init(void)
// next handle all single channel devices.
// they must be handeled in pair, or in pair with another
// even number of channels device.
std::vector<CVocodecChannel *> PairsOf3000DevicesChs;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{
CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i];
@ -120,15 +122,16 @@ bool CVocodecs::Init(void)
if ( found )
{
// yes, create and pairboth interfaces
iNbCh += CFtdiDeviceDescr::CreateInterfacePair(descr1, descr2, &m_Channels);
iNbCh += CFtdiDeviceDescr::CreateInterfacePair(descr1, descr2, &PairsOf3000DevicesChs);
// and flag as used
descr1->SetUsed(true);
descr2->SetUsed(true);
}
}
}
// now we should have only remaining the 3 chennels device(s)
// now we should have only remaining the 3 channels device(s)
// and possibly an unique single channel device
std::vector<CVocodecChannel *> Single3003DeviceChannels;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{
CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i];
@ -148,7 +151,7 @@ bool CVocodecs::Init(void)
if ( found )
{
// yes, create and pairboth interfaces
iNbCh += CFtdiDeviceDescr::CreateInterfacePair(descr1, descr2, &m_Channels);
iNbCh += CFtdiDeviceDescr::CreateInterfacePair(descr1, descr2, &Multi3003DevicesChs);
// and flag as used
descr1->SetUsed(true);
descr2->SetUsed(true);
@ -156,13 +159,47 @@ bool CVocodecs::Init(void)
else
{
// no, just create a standalone 3003 interface
iNbCh += CFtdiDeviceDescr::CreateInterface(descr1, &m_Channels);
iNbCh += CFtdiDeviceDescr::CreateInterface(descr1, &Single3003DeviceChannels);
// and flag as used
descr1->SetUsed(true);
}
}
}
// now agregate channels by order of priority
// for proper load sharing
// pairs of 300 devices first
{
for ( int i = 0; i < PairsOf3000DevicesChs.size(); i++ )
{
m_Channels.push_back(PairsOf3000DevicesChs.at(i));
}
PairsOf3000DevicesChs.clear();
}
// next the left-over single 3003 device
{
for ( int i = 0; i < Single3003DeviceChannels.size(); i++ )
{
m_Channels.push_back(Single3003DeviceChannels.at(i));
}
Single3003DeviceChannels.clear();
}
// and finally interlace multi-3003 and pairs of 3003 devices which always
// results to 6 channels per pair of 3003
{
int n = (int)Multi3003DevicesChs.size() / 6;
for ( int i = 0; i < 6; i++ )
{
for ( int j = 0; j < n; j++ )
{
m_Channels.push_back(Multi3003DevicesChs.at((j*6) + i));
}
}
Multi3003DevicesChs.clear();
}
// done
if ( ok )
{
std::cout << "Codec interfaces initialized successfully : " << iNbCh << " channels available" << std::endl;

View File

@ -49,7 +49,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_REVISION 1
#define VERSION_REVISION 2
// global ------------------------------------------------------

View File

@ -22,7 +22,7 @@
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
VERSION: 1.3.1
VERSION: 1.3.2
Hardware compatibility.
======================