no warnings

pull/1/head
Tom Early 6 years ago
parent 1c9ee1b8c1
commit cd4df55cc5

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "main.h" #include "main.h"
@ -42,11 +42,6 @@ CCallsign::CCallsign(const char *sz)
::memcpy(m_Callsign, sz, MIN(strlen(sz), sizeof(m_Callsign))); ::memcpy(m_Callsign, sz, MIN(strlen(sz), sizeof(m_Callsign)));
} }
CCallsign::CCallsign(const CCallsign &callsign)
{
::memcpy(m_Callsign, callsign.m_Callsign, sizeof(m_Callsign));
}
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// status // status
@ -54,7 +49,7 @@ bool CCallsign::IsValid(void) const
{ {
bool valid = true; bool valid = true;
int i; int i;
// callsign // callsign
// first 3 chars are letter or number but cannot be all number // first 3 chars are letter or number but cannot be all number
int iNum = 0; int iNum = 0;
@ -72,7 +67,7 @@ bool CCallsign::IsValid(void) const
{ {
valid &= IsLetter(m_Callsign[i]) || IsNumber(m_Callsign[i]) || IsSpace(m_Callsign[i]); valid &= IsLetter(m_Callsign[i]) || IsNumber(m_Callsign[i]) || IsSpace(m_Callsign[i]);
} }
// done // done
return valid; return valid;
} }
@ -93,7 +88,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len)
// set callsign // set callsign
::memset(m_Callsign, ' ', sizeof(m_Callsign)); ::memset(m_Callsign, ' ', sizeof(m_Callsign));
::memcpy(m_Callsign, buffer, MIN(len, sizeof(m_Callsign))); ::memcpy(m_Callsign, buffer, MIN(len, sizeof(m_Callsign)));
for ( int i = 0; i < sizeof(m_Callsign); i++ ) for ( unsigned i = 0; i < sizeof(m_Callsign); i++ )
{ {
if ( m_Callsign[i] == 0 ) if ( m_Callsign[i] == 0 )
{ {
@ -108,7 +103,7 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len)
void CCallsign::PatchCallsign(int off, const uint8 *patch, int len) void CCallsign::PatchCallsign(int off, const uint8 *patch, int len)
{ {
if ( off < sizeof(m_Callsign) ) if ( off < int(sizeof(m_Callsign)) )
{ {
::memcpy(m_Callsign, patch, MIN(len, sizeof(m_Callsign) - off)); ::memcpy(m_Callsign, patch, MIN(len, sizeof(m_Callsign) - off));
} }
@ -125,7 +120,7 @@ void CCallsign::GetCallsign(uint8 *buffer) const
void CCallsign::GetCallsignString(char *sz) const void CCallsign::GetCallsignString(char *sz) const
{ {
int i; unsigned i;
for ( i = 0; (i < sizeof(m_Callsign)) && (m_Callsign[i] != ' '); i++ ) for ( i = 0; (i < sizeof(m_Callsign)) && (m_Callsign[i] != ' '); i++ )
{ {
sz[i] = m_Callsign[i]; sz[i] = m_Callsign[i];
@ -145,8 +140,8 @@ bool CCallsign::HasSameCallsignWithWildcard(const CCallsign &callsign) const
{ {
bool same = true; bool same = true;
bool done = false; bool done = false;
for ( int i = 0; (i < sizeof(m_Callsign)) && same && !done; i++ ) for ( unsigned i = 0; (i < sizeof(m_Callsign)) && same && !done; i++ )
{ {
if ( !(done = ((m_Callsign[i] == '*') || (callsign[i] == '*'))) ) if ( !(done = ((m_Callsign[i] == '*') || (callsign[i] == '*'))) )
{ {
@ -168,13 +163,13 @@ bool CCallsign::operator ==(const CCallsign &callsign) const
CCallsign::operator const char *() const CCallsign::operator const char *() const
{ {
char *sz = (char *)(const char *)m_sz; char *sz = (char *)(const char *)m_sz;
// empty // empty
::memset(sz, 0, sizeof(m_sz)); ::memset(sz, 0, sizeof(m_sz));
// callsign // callsign
sz[CALLSIGN_LEN] = 0; sz[CALLSIGN_LEN] = 0;
::memcpy(sz, m_Callsign, sizeof(m_Callsign)); ::memcpy(sz, m_Callsign, sizeof(m_Callsign));
// done // done
return m_sz; return m_sz;
} }

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef ccallsign_h #ifndef ccallsign_h
@ -40,39 +40,35 @@ public:
// contructors // contructors
CCallsign(); CCallsign();
CCallsign(const char *); CCallsign(const char *);
CCallsign(const CCallsign &);
// destructor
virtual ~CCallsign() {};
// status // status
bool IsValid(void) const; bool IsValid(void) const;
// set // set
void SetCallsign(const char *); void SetCallsign(const char *);
void SetCallsign(const uint8 *, int); void SetCallsign(const uint8 *, int);
// modify // modify
void PatchCallsign(int, const uint8 *, int); void PatchCallsign(int, const uint8 *, int);
// get // get
void GetCallsign(uint8 *) const; void GetCallsign(uint8 *) const;
void GetCallsignString(char *) const; void GetCallsignString(char *) const;
// compare // compare
bool HasSameCallsign(const CCallsign &) const; bool HasSameCallsign(const CCallsign &) const;
bool HasSameCallsignWithWildcard(const CCallsign &) const; bool HasSameCallsignWithWildcard(const CCallsign &) const;
// operators // operators
bool operator ==(const CCallsign &) const; bool operator ==(const CCallsign &) const;
operator const char *() const; operator const char *() const;
protected: protected:
// helper // helper
bool IsNumber(char) const; bool IsNumber(char) const;
bool IsLetter(char) const; bool IsLetter(char) const;
bool IsSpace(char) const; bool IsSpace(char) const;
protected: protected:
// data // data
char m_Callsign[CALLSIGN_LEN]; char m_Callsign[CALLSIGN_LEN];

@ -76,9 +76,9 @@ bool CController::Init(void)
m_bStopThread = false; m_bStopThread = false;
// create our socket // create our socket
CIp ip(strchr(straddress, ':') ? AF_INET6 : AF_INET, TRANSCODER_PORT, straddress); CIp ip(strchr(m_addr, ':') ? AF_INET6 : AF_INET, TRANSCODER_PORT, m_addr);
if (! ip.IsSet()) { if (! ip.IsSet()) {
std::cerr << "IP initialization failed for " << straddress << std::endl; std::cerr << "IP initialization failed for " << m_addr << std::endl;
return false; return false;
} }
if (! m_Socket.Open(ip)) if (! m_Socket.Open(ip))
@ -128,7 +128,7 @@ void CController::Task(void)
CStream *Stream; CStream *Stream;
// anything coming in from codec client ? // anything coming in from codec client ?
if ( m_Socket.Receive(Buffer, Ip, 20) != -1 ) if ( m_Socket.Receive(Buffer, Ip, 20) )
{ {
// crack packet // crack packet
if ( IsValidOpenstreamPacket(Buffer, &Callsign, &CodecIn, &CodecOut) ) if ( IsValidOpenstreamPacket(Buffer, &Callsign, &CodecIn, &CodecOut) )

@ -50,10 +50,10 @@ public:
void Unlock(void) { m_Mutex.unlock(); } void Unlock(void) { m_Mutex.unlock(); }
// get // get
const CIp &GetListenIp(void) const { return straddress; } const char *GetListenIp(void) const { return m_addr; }
// set // set
void SetListenIp(const char *str) { straddress = str; } void SetListenIp(const char *str) { memset(m_addr, 0, INET6_ADDRSTRLEN); strncpy(m_addr, str, INET6_ADDRSTRLEN-1); }
// streams management // streams management
CStream *OpenStream(const CCallsign &, const CIp &, uint8, uint8); CStream *OpenStream(const CCallsign &, const CIp &, uint8, uint8);
@ -81,8 +81,8 @@ protected:
protected: protected:
// control socket // control socket
const char *straddress; char m_addr[INET6_ADDRSTRLEN];
CUdpSocket m_Socket; CUdpSocket m_Socket;
// streams // streams
uint16 m_uiLastStreamId; uint16 m_uiLastStreamId;

@ -48,4 +48,3 @@ private:
}; };
#endif //cfirfilter_h #endif //cfirfilter_h

@ -31,8 +31,9 @@
class CSampleBlockProcessor class CSampleBlockProcessor
{ {
public: public:
virtual ~CSampleBlockProcessor() {}
//processing //processing
virtual void ProcessSampleBlock(uint8* voice, int length) = 0; virtual void ProcessSampleBlock(uint8* voice, int length) = 0;
}; };
#endif /* csampleprocessor_h */ #endif /* csampleprocessor_h */

@ -57,10 +57,11 @@ CSignalProcessor::CSignalProcessor(float gaindB)
CSignalProcessor::~CSignalProcessor() CSignalProcessor::~CSignalProcessor()
{ {
for(int i = 0; i < m_sampleProcessors.size(); i++) for(auto it=m_sampleProcessors.begin(); it!=m_sampleProcessors.end(); it++)
{ {
delete m_sampleProcessors[i]; delete *it;
} }
m_sampleProcessors.clear();
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -70,11 +71,10 @@ void CSignalProcessor::Process(uint8* voice, int length)
{ {
/*float sample; /*float sample;
int j;*/ int j;*/
auto processorsSize = m_sampleProcessors.size();
for(int j = 0; j < processorsSize; j++) for(auto it=m_sampleProcessors.begin(); it!=m_sampleProcessors.end(); it++)
{ {
m_sampleProcessors[j]->ProcessSampleBlock(voice, length); (*it)->ProcessSampleBlock(voice, length);
} }
/*for(int i = 0; i < length; i += 2) /*for(int i = 0; i < length; i += 2)
@ -91,4 +91,4 @@ void CSignalProcessor::Process(uint8* voice, int length)
voice[i] = HIBYTE((short)sample); voice[i] = HIBYTE((short)sample);
voice[i+1] = LOBYTE((short)sample); voice[i+1] = LOBYTE((short)sample);
}*/ }*/
} }

@ -42,7 +42,7 @@ public:
void Process(uint8* voice, int length); void Process(uint8* voice, int length);
private: private:
std::vector<CSampleBlockProcessor *> m_sampleProcessors; std::list<CSampleBlockProcessor *> m_sampleProcessors;
}; };
#endif /* csignalprocessor_h */ #endif /* csignalprocessor_h */

@ -49,17 +49,17 @@ CUsb3000Interface::CUsb3000Interface(uint32 uiVid, uint32 uiPid, const char *szD
bool CUsb3000Interface::Init(uint8 uiOddCodec) bool CUsb3000Interface::Init(uint8 uiOddCodec)
{ {
bool ok = true; bool ok = true;
// init the odd channel // init the odd channel
m_uiChCodec = uiOddCodec; m_uiChCodec = uiOddCodec;
// base class // base class
ok &= CUsb3xxxInterface::Init(); ok &= CUsb3xxxInterface::Init();
// do not create our channels now // do not create our channels now
// this is delegated to caller (CVocodecs) as our channel // this is delegated to caller (CVocodecs) as our channel
// may be hybrids between 2 interfaces in case of odd n' of channel device) // may be hybrids between 2 interfaces in case of odd n' of channel device)
// done // done
return ok; return ok;
} }
@ -79,7 +79,7 @@ CVocodecChannel *CUsb3000Interface::GetChannelWithChannelIn(int iCh)
{ {
CVocodecChannel *Channel = NULL; CVocodecChannel *Channel = NULL;
bool done = false; bool done = false;
for ( int i = 0; (i < m_Channels.size()) && !done; i++ ) for ( unsigned i = 0; (i < m_Channels.size()) && !done; i++ )
{ {
if ( iCh == 0 ) if ( iCh == 0 )
{ {
@ -97,7 +97,7 @@ CVocodecChannel *CUsb3000Interface::GetChannelWithChannelOut(int iCh)
{ {
CVocodecChannel *Channel = NULL; CVocodecChannel *Channel = NULL;
bool done = false; bool done = false;
for ( int i = 0; (i < m_Channels.size()) && !done; i++ ) for ( unsigned i = 0; (i < m_Channels.size()) && !done; i++ )
{ {
if ( (m_Channels[i]->GetChannelOut() == iCh) && (m_Channels[i]->IsInterfaceOut(this)) ) if ( (m_Channels[i]->GetChannelOut() == iCh) && (m_Channels[i]->IsInterfaceOut(this)) )
{ {
@ -116,7 +116,7 @@ bool CUsb3000Interface::IsValidChannelPacket(const CBuffer &buffer, int *ch, CAm
{ {
bool valid = false; bool valid = false;
uint8 tag[] = { PKT_HEADER,0x00,0x0B,PKT_CHANNEL }; uint8 tag[] = { PKT_HEADER,0x00,0x0B,PKT_CHANNEL };
if ( (buffer.size() == 15) && (buffer.Compare(tag, sizeof(tag)) == 0)) if ( (buffer.size() == 15) && (buffer.Compare(tag, sizeof(tag)) == 0))
{ {
*ch = 0; *ch = 0;
@ -131,7 +131,7 @@ bool CUsb3000Interface::IsValidChannelPacket(const CBuffer &buffer, int *ch, CAm
bool CUsb3000Interface::IsValidSpeechPacket(const CBuffer &buffer, int *ch, CVoicePacket *packet) bool CUsb3000Interface::IsValidSpeechPacket(const CBuffer &buffer, int *ch, CVoicePacket *packet)
{ {
bool valid = false; bool valid = false;
if ( (buffer.size() > 6) && if ( (buffer.size() > 6) &&
(buffer.data()[0] == PKT_HEADER) && (buffer.data()[3] == PKT_SPEECH) && (buffer.data()[0] == PKT_HEADER) && (buffer.data()[3] == PKT_SPEECH) &&
(buffer.data()[4] == PKT_SPEECHD) ) (buffer.data()[4] == PKT_SPEECHD) )
@ -181,44 +181,44 @@ bool CUsb3000Interface::OpenDevice(void)
{ {
FT_STATUS ftStatus; FT_STATUS ftStatus;
int baudrate = 460800; int baudrate = 460800;
//sets serial VID/PID for a Standard Device NOTE: This is for legacy purposes only. This can be ommitted. //sets serial VID/PID for a Standard Device NOTE: This is for legacy purposes only. This can be ommitted.
ftStatus = FT_SetVIDPID(m_uiVid, m_uiPid); ftStatus = FT_SetVIDPID(m_uiVid, m_uiPid);
if (ftStatus != FT_OK) {FTDI_Error((char *)"FT_SetVIDPID", ftStatus ); return false; } if (ftStatus != FT_OK) {FTDI_Error((char *)"FT_SetVIDPID", ftStatus ); return false; }
ftStatus = FT_OpenEx((PVOID)m_szDeviceSerial, FT_OPEN_BY_SERIAL_NUMBER, &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; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_OpenEx", ftStatus ); return false; }
CTimePoint::TaskSleepFor(50); CTimePoint::TaskSleepFor(50);
FT_Purge(m_FtdiHandle, FT_PURGE_RX | FT_PURGE_TX ); FT_Purge(m_FtdiHandle, FT_PURGE_RX | FT_PURGE_TX );
CTimePoint::TaskSleepFor(50); CTimePoint::TaskSleepFor(50);
ftStatus = FT_SetDataCharacteristics(m_FtdiHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE); ftStatus = FT_SetDataCharacteristics(m_FtdiHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE);
if ( ftStatus != FT_OK ) { FTDI_Error((char *)"FT_SetDataCharacteristics", ftStatus ); return false; } if ( ftStatus != FT_OK ) { FTDI_Error((char *)"FT_SetDataCharacteristics", ftStatus ); return false; }
ftStatus = FT_SetFlowControl(m_FtdiHandle, FT_FLOW_RTS_CTS, 0x11, 0x13); ftStatus = FT_SetFlowControl(m_FtdiHandle, FT_FLOW_RTS_CTS, 0x11, 0x13);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetFlowControl", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetFlowControl", ftStatus ); return false; }
ftStatus = FT_SetRts (m_FtdiHandle); ftStatus = FT_SetRts (m_FtdiHandle);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetRts", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetRts", ftStatus ); return false; }
//for usb-3012 pull DTR high to take AMBE3003 out of reset. //for usb-3012 pull DTR high to take AMBE3003 out of reset.
//for other devices noting is connected to DTR so it is a dont care //for other devices noting is connected to DTR so it is a dont care
ftStatus = FT_ClrDtr(m_FtdiHandle); ftStatus = FT_ClrDtr(m_FtdiHandle);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_ClrDtr", ftStatus); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_ClrDtr", ftStatus); return false; }
ftStatus = FT_SetBaudRate(m_FtdiHandle, baudrate ); ftStatus = FT_SetBaudRate(m_FtdiHandle, baudrate );
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetBaudRate", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetBaudRate", ftStatus ); return false; }
ftStatus = FT_SetLatencyTimer(m_FtdiHandle, 4); ftStatus = FT_SetLatencyTimer(m_FtdiHandle, 4);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetLatencyTimer", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetLatencyTimer", ftStatus ); return false; }
ftStatus = FT_SetUSBParameters(m_FtdiHandle, USB3XXX_MAXPACKETSIZE, 0); ftStatus = FT_SetUSBParameters(m_FtdiHandle, USB3XXX_MAXPACKETSIZE, 0);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetUSBParameters", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetUSBParameters", ftStatus ); return false; }
ftStatus = FT_SetTimeouts(m_FtdiHandle, 200, 200 ); ftStatus = FT_SetTimeouts(m_FtdiHandle, 200, 200 );
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetTimeouts", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetTimeouts", ftStatus ); return false; }
// done // done
return true; return true;
} }
@ -242,20 +242,20 @@ bool CUsb3000Interface::ResetDevice(void)
PKT_PARITYBYTE, PKT_PARITYBYTE,
3 ^ PKT_RESET ^ PKT_PARITYBYTE 3 ^ PKT_RESET ^ PKT_PARITYBYTE
}; };
//the chip might be in a state where it is waiting to receive bytes from a prior incomplete packet. //the chip might be in a state where it is waiting to receive bytes from a prior incomplete packet.
//first send 350 zeros in case, the chip's receive state is still waiting for characters //first send 350 zeros in case, the chip's receive state is still waiting for characters
//if we send more than needed, the exta characters will just get discarded since they do not match the header byte //if we send more than needed, the exta characters will just get discarded since they do not match the header byte
//after that we send PKT_RESET to reset the device //after that we send PKT_RESET to reset the device
//As long as the AMBE3000 is able to receive via uart, this method will succeed in resetting it. //As long as the AMBE3000 is able to receive via uart, this method will succeed in resetting it.
for ( int i = 0; i < 35 ; i++ ) for ( int i = 0; i < 35 ; i++ )
{ {
FTDI_write_packet(m_FtdiHandle, zeropacket, sizeof(zeropacket)); FTDI_write_packet(m_FtdiHandle, zeropacket, sizeof(zeropacket));
} }
// write soft-reset packet // write soft-reset packet
if ( FTDI_write_packet(m_FtdiHandle, txpacket, sizeof(txpacket)) ) if ( FTDI_write_packet(m_FtdiHandle, txpacket, sizeof(txpacket)) )
{ {
@ -267,7 +267,7 @@ bool CUsb3000Interface::ResetDevice(void)
std::cout << "USB-3000 soft reset failed" << std::endl; std::cout << "USB-3000 soft reset failed" << std::endl;
} }
} }
// done // done
return ok; return ok;
} }
@ -277,7 +277,7 @@ bool CUsb3000Interface::ConfigureDevice(void)
bool ok = true; bool ok = true;
uint8 pkt_ratep_ambeplus[] = { 0x01,0x30,0x07,0x63,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x48 }; uint8 pkt_ratep_ambeplus[] = { 0x01,0x30,0x07,0x63,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x48 };
uint8 pkt_ratep_ambe2plus[] = { 0x04,0x31,0x07,0x54,0x24,0x00,0x00,0x00,0x00,0x00,0x6F,0x48 }; uint8 pkt_ratep_ambe2plus[] = { 0x04,0x31,0x07,0x54,0x24,0x00,0x00,0x00,0x00,0x00,0x6F,0x48 };
// configure the channel for desired codec // configure the channel for desired codec
switch ( m_uiChCodec ) switch ( m_uiChCodec )
{ {
@ -291,7 +291,7 @@ bool CUsb3000Interface::ConfigureDevice(void)
default: default:
break; break;
} }
// done // done
return ok; return ok;
} }

@ -42,25 +42,23 @@ CUsb3003HRInterface::CUsb3003HRInterface(uint32 uiVid, uint32 uiPid, const char
bool CUsb3003HRInterface::ResetDevice(void) bool CUsb3003HRInterface::ResetDevice(void)
{ {
bool ok = false; bool ok = false;
FT_STATUS ftStatus;
int len; int len;
char rxpacket[100]; char rxpacket[100];
//if the device is a USB-3003, it supports reset via UART break signal //if the device is a USB-3003, it supports reset via UART break signal
//printf("reset via uart break...\n"); //printf("reset via uart break...\n");
ftStatus = FT_SetBreakOn( m_FtdiHandle ); FT_SetBreakOn( m_FtdiHandle );
CTimePoint::TaskSleepFor(10); CTimePoint::TaskSleepFor(10);
ftStatus = FT_SetBreakOff( m_FtdiHandle ); FT_SetBreakOff( m_FtdiHandle );
//CTimePoint::TaskSleepFor(10); //CTimePoint::TaskSleepFor(10);
len = FTDI_read_packet( m_FtdiHandle, rxpacket, sizeof(rxpacket) ); len = FTDI_read_packet( m_FtdiHandle, rxpacket, sizeof(rxpacket) );
ok = ((len == 7) && (rxpacket[4] == PKT_READY)); ok = ((len == 7) && (rxpacket[4] == PKT_READY));
if ( !ok ) if ( !ok )
{ {
std::cout << "USB-3003 hard reset failed" << std::endl; std::cout << "USB-3003 hard reset failed" << std::endl;
} }
// done // done
return ok; return ok;
} }

@ -53,17 +53,17 @@ CUsb3003Interface::CUsb3003Interface(uint32 uiVid, uint32 uiPid, const char *szD
bool CUsb3003Interface::Init(uint8 uiOddCodec) bool CUsb3003Interface::Init(uint8 uiOddCodec)
{ {
bool ok = true; bool ok = true;
// init the odd channel // init the odd channel
m_uiChCodecs[2] = uiOddCodec; m_uiChCodecs[2] = uiOddCodec;
// base class // base class
ok &= CUsb3xxxInterface::Init(); ok &= CUsb3xxxInterface::Init();
// do not create our channels now // do not create our channels now
// this is delegated to caller (CVocodecs) as our channel // this is delegated to caller (CVocodecs) as our channel
// may be hybrids between 2 interfaces in case of odd n' of channel device) // may be hybrids between 2 interfaces in case of odd n' of channel device)
// done // done
return ok; return ok;
} }
@ -88,7 +88,7 @@ CVocodecChannel *CUsb3003Interface::GetChannelWithChannelIn(int iCh)
{ {
CVocodecChannel *Channel = NULL; CVocodecChannel *Channel = NULL;
bool done = false; bool done = false;
for ( int i = 0; (i < m_Channels.size()) && !done; i++ ) for ( unsigned i = 0; (i < m_Channels.size()) && !done; i++ )
{ {
if ( iCh == 2 ) if ( iCh == 2 )
{ {
@ -114,7 +114,7 @@ CVocodecChannel *CUsb3003Interface::GetChannelWithChannelOut(int iCh)
{ {
CVocodecChannel *Channel = NULL; CVocodecChannel *Channel = NULL;
bool done = false; bool done = false;
for ( int i = 0; (i < m_Channels.size()) && !done; i++ ) for ( unsigned i = 0; (i < m_Channels.size()) && !done; i++ )
{ {
if ( (m_Channels[i]->GetChannelOut() == iCh) && (m_Channels[i]->IsInterfaceOut(this)) ) if ( (m_Channels[i]->GetChannelOut() == iCh) && (m_Channels[i]->IsInterfaceOut(this)) )
{ {
@ -132,7 +132,7 @@ bool CUsb3003Interface::IsValidChannelPacket(const CBuffer &buffer, int *ch, CAm
{ {
bool valid = false; bool valid = false;
uint8 tag[] = { PKT_HEADER,0x00,0x0C,PKT_CHANNEL }; uint8 tag[] = { PKT_HEADER,0x00,0x0C,PKT_CHANNEL };
if ( (buffer.size() == 16) && (buffer.Compare(tag, sizeof(tag)) == 0)) if ( (buffer.size() == 16) && (buffer.Compare(tag, sizeof(tag)) == 0))
{ {
*ch = buffer.data()[4] - PKT_CHANNEL0; *ch = buffer.data()[4] - PKT_CHANNEL0;
@ -152,7 +152,7 @@ bool CUsb3003Interface::IsValidChannelPacket(const CBuffer &buffer, int *ch, CAm
bool CUsb3003Interface::IsValidSpeechPacket(const CBuffer &buffer, int *ch, CVoicePacket *packet) bool CUsb3003Interface::IsValidSpeechPacket(const CBuffer &buffer, int *ch, CVoicePacket *packet)
{ {
bool valid = false; bool valid = false;
if ( (buffer.size() > 6) && if ( (buffer.size() > 6) &&
(buffer.data()[0] == PKT_HEADER) && (buffer.data()[3] == PKT_SPEECH) && (buffer.data()[0] == PKT_HEADER) && (buffer.data()[3] == PKT_SPEECH) &&
(buffer.data()[5] == PKT_SPEECHD) ) (buffer.data()[5] == PKT_SPEECHD) )
@ -204,44 +204,44 @@ bool CUsb3003Interface::OpenDevice(void)
{ {
FT_STATUS ftStatus; FT_STATUS ftStatus;
int baudrate = 921600; int baudrate = 921600;
//sets serial VID/PID for a Standard Device NOTE: This is for legacy purposes only. This can be ommitted. //sets serial VID/PID for a Standard Device NOTE: This is for legacy purposes only. This can be ommitted.
ftStatus = FT_SetVIDPID(m_uiVid, m_uiPid); ftStatus = FT_SetVIDPID(m_uiVid, m_uiPid);
if (ftStatus != FT_OK) {FTDI_Error((char *)"FT_SetVIDPID", ftStatus ); return false; } if (ftStatus != FT_OK) {FTDI_Error((char *)"FT_SetVIDPID", ftStatus ); return false; }
ftStatus = FT_OpenEx((PVOID)m_szDeviceSerial, FT_OPEN_BY_SERIAL_NUMBER, &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; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_OpenEx", ftStatus ); return false; }
CTimePoint::TaskSleepFor(50); CTimePoint::TaskSleepFor(50);
FT_Purge(m_FtdiHandle, FT_PURGE_RX | FT_PURGE_TX ); FT_Purge(m_FtdiHandle, FT_PURGE_RX | FT_PURGE_TX );
CTimePoint::TaskSleepFor(50); CTimePoint::TaskSleepFor(50);
ftStatus = FT_SetDataCharacteristics(m_FtdiHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE); ftStatus = FT_SetDataCharacteristics(m_FtdiHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE);
if ( ftStatus != FT_OK ) { FTDI_Error((char *)"FT_SetDataCharacteristics", ftStatus ); return false; } if ( ftStatus != FT_OK ) { FTDI_Error((char *)"FT_SetDataCharacteristics", ftStatus ); return false; }
ftStatus = FT_SetFlowControl(m_FtdiHandle, FT_FLOW_RTS_CTS, 0x11, 0x13); ftStatus = FT_SetFlowControl(m_FtdiHandle, FT_FLOW_RTS_CTS, 0x11, 0x13);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetFlowControl", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetFlowControl", ftStatus ); return false; }
ftStatus = FT_SetRts (m_FtdiHandle); ftStatus = FT_SetRts (m_FtdiHandle);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetRts", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetRts", ftStatus ); return false; }
//for usb-3012 pull DTR high to take AMBE3003 out of reset. //for usb-3012 pull DTR high to take AMBE3003 out of reset.
//for other devices noting is connected to DTR so it is a dont care //for other devices noting is connected to DTR so it is a dont care
ftStatus = FT_ClrDtr(m_FtdiHandle); ftStatus = FT_ClrDtr(m_FtdiHandle);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_ClrDtr", ftStatus); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_ClrDtr", ftStatus); return false; }
ftStatus = FT_SetBaudRate(m_FtdiHandle, baudrate ); ftStatus = FT_SetBaudRate(m_FtdiHandle, baudrate );
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetBaudRate", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetBaudRate", ftStatus ); return false; }
ftStatus = FT_SetLatencyTimer(m_FtdiHandle, 4); ftStatus = FT_SetLatencyTimer(m_FtdiHandle, 4);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetLatencyTimer", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetLatencyTimer", ftStatus ); return false; }
ftStatus = FT_SetUSBParameters(m_FtdiHandle, USB3XXX_MAXPACKETSIZE, 0); ftStatus = FT_SetUSBParameters(m_FtdiHandle, USB3XXX_MAXPACKETSIZE, 0);
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetUSBParameters", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetUSBParameters", ftStatus ); return false; }
ftStatus = FT_SetTimeouts(m_FtdiHandle, 200, 200 ); ftStatus = FT_SetTimeouts(m_FtdiHandle, 200, 200 );
if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetTimeouts", ftStatus ); return false; } if (ftStatus != FT_OK) { FTDI_Error((char *)"FT_SetTimeouts", ftStatus ); return false; }
// done // done
return true; return true;
} }
@ -265,20 +265,20 @@ bool CUsb3003Interface::ResetDevice(void)
PKT_PARITYBYTE, PKT_PARITYBYTE,
3 ^ PKT_RESET ^ PKT_PARITYBYTE 3 ^ PKT_RESET ^ PKT_PARITYBYTE
}; };
//the chip might be in a state where it is waiting to receive bytes from a prior incomplete packet. //the chip might be in a state where it is waiting to receive bytes from a prior incomplete packet.
//first send 350 zeros in case, the chip's receive state is still waiting for characters //first send 350 zeros in case, the chip's receive state is still waiting for characters
//if we send more than needed, the exta characters will just get discarded since they do not match the header byte //if we send more than needed, the exta characters will just get discarded since they do not match the header byte
//after that we send PKT_RESET to reset the device //after that we send PKT_RESET to reset the device
//As long as the AMBE3000 is able to receive via uart, this method will succeed in resetting it. //As long as the AMBE3000 is able to receive via uart, this method will succeed in resetting it.
for ( int i = 0; i < 35 ; i++ ) for ( int i = 0; i < 35 ; i++ )
{ {
FTDI_write_packet(m_FtdiHandle, zeropacket, sizeof(zeropacket)); FTDI_write_packet(m_FtdiHandle, zeropacket, sizeof(zeropacket));
} }
// write soft-reset packet // write soft-reset packet
if ( FTDI_write_packet(m_FtdiHandle, txpacket, sizeof(txpacket)) ) if ( FTDI_write_packet(m_FtdiHandle, txpacket, sizeof(txpacket)) )
{ {
@ -290,7 +290,7 @@ bool CUsb3003Interface::ResetDevice(void)
std::cout << "USB-3003 soft reset failed" << std::endl; std::cout << "USB-3003 soft reset failed" << std::endl;
} }
} }
// done // done
return ok; return ok;
} }
@ -300,7 +300,7 @@ bool CUsb3003Interface::ConfigureDevice(void)
bool ok = true; bool ok = true;
uint8 pkt_ratep_ambeplus[] = { 0x01,0x30,0x07,0x63,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x48 }; uint8 pkt_ratep_ambeplus[] = { 0x01,0x30,0x07,0x63,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x48 };
uint8 pkt_ratep_ambe2plus[] = { 0x04,0x31,0x07,0x54,0x24,0x00,0x00,0x00,0x00,0x00,0x6F,0x48 }; uint8 pkt_ratep_ambe2plus[] = { 0x04,0x31,0x07,0x54,0x24,0x00,0x00,0x00,0x00,0x00,0x6F,0x48 };
// configure each channels for desired codec // configure each channels for desired codec
for ( int i = 0; i < USB3003_NB_CH; i++ ) for ( int i = 0; i < USB3003_NB_CH; i++ )
{ {
@ -321,4 +321,3 @@ bool CUsb3003Interface::ConfigureDevice(void)
// done // done
return ok; return ok;
} }

@ -53,14 +53,14 @@ CUsb3xxxInterface::CUsb3xxxInterface(uint32 uiVid, uint32 uiPid, const char *szD
CUsb3xxxInterface::~CUsb3xxxInterface() CUsb3xxxInterface::~CUsb3xxxInterface()
{ {
// delete m_SpeechQueues // delete m_SpeechQueues
for ( int i = 0; i < m_SpeechQueues.size(); i++ ) for ( unsigned i = 0; i < m_SpeechQueues.size(); i++ )
{ {
delete m_SpeechQueues[i]; delete m_SpeechQueues[i];
} }
m_SpeechQueues.clear(); m_SpeechQueues.clear();
// delete m_ChannelQueues // delete m_ChannelQueues
for ( int i = 0; i < m_ChannelQueues.size(); i++ ) for ( unsigned i = 0; i < m_ChannelQueues.size(); i++ )
{ {
delete m_ChannelQueues[i]; delete m_ChannelQueues[i];
} }
@ -73,7 +73,7 @@ CUsb3xxxInterface::~CUsb3xxxInterface()
bool CUsb3xxxInterface::Init(void) bool CUsb3xxxInterface::Init(void)
{ {
bool ok = true; bool ok = true;
// open USB device // open USB device
std::cout << "Opening " << m_szDeviceName << ":" << m_szDeviceSerial << " device" << std::endl; std::cout << "Opening " << m_szDeviceName << ":" << m_szDeviceSerial << " device" << std::endl;
if ( ok &= OpenDevice() ) if ( ok &= OpenDevice() )
@ -94,20 +94,20 @@ bool CUsb3xxxInterface::Init(void)
} }
} }
std::cout << std::endl; std::cout << std::endl;
// create our queues // create our queues
for ( int i = 0; i < GetNbChannels(); i++ ) for ( int i = 0; i < GetNbChannels(); i++ )
{ {
m_SpeechQueues.push_back(new CPacketQueue); m_SpeechQueues.push_back(new CPacketQueue);
m_ChannelQueues.push_back(new CPacketQueue); m_ChannelQueues.push_back(new CPacketQueue);
} }
// base class // base class
if ( ok ) if ( ok )
{ {
ok &= CVocodecInterface::Init(); ok &= CVocodecInterface::Init();
} }
// done // done
return ok; return ok;
} }
@ -125,12 +125,12 @@ void CUsb3xxxInterface::Task(void)
CAmbePacket AmbePacket; CAmbePacket AmbePacket;
CVoicePacket VoicePacket; CVoicePacket VoicePacket;
bool done; bool done;
// TODO : // TODO :
// preserve packets PIDs, so the transcoded CAmbePacket returned // preserve packets PIDs, so the transcoded CAmbePacket returned
// to CStream client is garantied to have the same PID // to CStream client is garantied to have the same PID
// than the corresponding incoming packet // than the corresponding incoming packet
// process the device incoming packet // process the device incoming packet
// get all packets from device and push them // get all packets from device and push them
// to the relevant clients queues // to the relevant clients queues
@ -142,7 +142,7 @@ void CUsb3xxxInterface::Task(void)
// as we get a speech packet, it means that the device // as we get a speech packet, it means that the device
// channel fifo input decreased by 1 // channel fifo input decreased by 1
m_iChannelFifolLevel = MAX(0, m_iChannelFifolLevel-1); m_iChannelFifolLevel = MAX(0, m_iChannelFifolLevel-1);
// push back to relevant channel voice queue // push back to relevant channel voice queue
// our incoming channel packet has now been through the decoder // our incoming channel packet has now been through the decoder
// find the coupled channel encoder and push to it's queue // find the coupled channel encoder and push to it's queue
@ -177,18 +177,18 @@ void CUsb3xxxInterface::Task(void)
} }
} }
} }
// process the streams (channels) incoming queue // process the streams (channels) incoming queue
// make sure that packets from different channels // make sure that packets from different channels
// are interlaced so to keep the device fifo busy // are interlaced so to keep the device fifo busy
do do
{ {
done = true; done = true;
for ( int i = 0; i < m_Channels.size(); i++) for ( unsigned i = 0; i < m_Channels.size(); i++)
{ {
// get channel // get channel
Channel = m_Channels[i]; Channel = m_Channels[i];
// any packet in voice queue ? // any packet in voice queue ?
if ( Channel->IsInterfaceOut(this) ) if ( Channel->IsInterfaceOut(this) )
{ {
@ -209,7 +209,7 @@ void CUsb3xxxInterface::Task(void)
} }
Channel->ReleaseVoiceQueue(); Channel->ReleaseVoiceQueue();
} }
// any packet in ambe queue for us ? // any packet in ambe queue for us ?
if ( Channel->IsInterfaceIn(this) ) if ( Channel->IsInterfaceIn(this) )
{ {
@ -232,7 +232,7 @@ void CUsb3xxxInterface::Task(void)
} }
} }
} while (!done); } while (!done);
// process device incoming queues (aka to device) // process device incoming queues (aka to device)
// interlace speech and channels packets // interlace speech and channels packets
// and post to final device queue // and post to final device queue
@ -264,9 +264,9 @@ void CUsb3xxxInterface::Task(void)
// done = false; // done = false;
} }
} }
} while (!done); } while (!done);
// process device queue to feed hardware // process device queue to feed hardware
// make sure that device fifo is fed all the time // make sure that device fifo is fed all the time
int fifoSize = GetDeviceFifoSize(); int fifoSize = GetDeviceFifoSize();
@ -276,7 +276,7 @@ void CUsb3xxxInterface::Task(void)
// if device fifo level is zero (device idle) // if device fifo level is zero (device idle)
// wait that at least 3 packets are in incoming // wait that at least 3 packets are in incoming
// queue before restarting // queue before restarting
if ( ((m_iSpeechFifolLevel+m_iChannelFifolLevel) > 0) || (m_DeviceQueue.size() >= (fifoSize+1)) ) if ( ((m_iSpeechFifolLevel+m_iChannelFifolLevel) > 0) || (m_DeviceQueue.size() >= unsigned(fifoSize+1)) )
{ {
// any packet to send ? // any packet to send ?
if ( m_DeviceQueue.size() > 0 ) if ( m_DeviceQueue.size() > 0 )
@ -321,7 +321,7 @@ void CUsb3xxxInterface::Task(void)
} }
} }
} while (!done); } while (!done);
// and wait a bit // and wait a bit
CTimePoint::TaskSleepFor(2); CTimePoint::TaskSleepFor(2);
} }
@ -411,13 +411,13 @@ bool CUsb3xxxInterface::ConfigureChannel(uint8 pkt_ch, const uint8 *pkt_ratep, i
PKT_GAIN, 0x00,0x00, PKT_GAIN, 0x00,0x00,
PKT_INIT, 0x03 PKT_INIT, 0x03
}; };
// update packet content // update packet content
txpacket[4] = pkt_ch; txpacket[4] = pkt_ch;
:: memcpy(&(txpacket[14]), pkt_ratep, 12); :: memcpy(&(txpacket[14]), pkt_ratep, 12);
txpacket[33] = (uint8)(signed char)in_gain; txpacket[33] = (uint8)(signed char)in_gain;
txpacket[34] = (uint8)(signed char)out_gain; txpacket[34] = (uint8)(signed char)out_gain;
// write packet // write packet
if ( FTDI_write_packet(m_FtdiHandle, txpacket, sizeof(txpacket)) ) if ( FTDI_write_packet(m_FtdiHandle, txpacket, sizeof(txpacket)) )
{ {
@ -426,7 +426,7 @@ bool CUsb3xxxInterface::ConfigureChannel(uint8 pkt_ch, const uint8 *pkt_ratep, i
ok = ((len == 18) && (rxpacket[20] == PKT_INIT) &&(rxpacket[21] == 0x00) ); ok = ((len == 18) && (rxpacket[20] == PKT_INIT) &&(rxpacket[21] == 0x00) );
} }
return ok; return ok;
} }
@ -437,7 +437,7 @@ bool CUsb3xxxInterface::ReadBuffer(CBuffer *buffer)
{ {
bool ok = false; bool ok = false;
int n; int n;
// any byte in tx queue ? // any byte in tx queue ?
if ( FT_GetQueueStatus(m_FtdiHandle, (LPDWORD)&n) == FT_OK ) if ( FT_GetQueueStatus(m_FtdiHandle, (LPDWORD)&n) == FT_OK )
{ {
@ -462,7 +462,7 @@ bool CUsb3xxxInterface::WriteBuffer(const CBuffer &buffer)
int CUsb3xxxInterface::FTDI_read_packet(FT_HANDLE ftHandle, char *pkt, int maxlen) int CUsb3xxxInterface::FTDI_read_packet(FT_HANDLE ftHandle, char *pkt, int maxlen)
{ {
int plen; int plen;
// first read 4 bytes header // first read 4 bytes header
if ( FTDI_read_bytes(ftHandle, pkt, 4) ) if ( FTDI_read_bytes(ftHandle, pkt, 4) )
{ {
@ -491,14 +491,14 @@ bool CUsb3xxxInterface::FTDI_read_bytes(FT_HANDLE ftHandle, char *buffer, int le
// this relies on FT_SetTimouts() mechanism // this relies on FT_SetTimouts() mechanism
int n; int n;
bool ok = false; bool ok = false;
ok = (FT_Read(ftHandle, (LPVOID)buffer, len, (LPDWORD)&n) == FT_OK) && (n == len); ok = (FT_Read(ftHandle, (LPVOID)buffer, len, (LPDWORD)&n) == FT_OK) && (n == len);
if ( !ok ) if ( !ok )
{ {
//FT_Purge(ftHandle, FT_PURGE_RX); //FT_Purge(ftHandle, FT_PURGE_RX);
std::cout << "FTDI_read_bytes(" << len << ") failed : " << n << std::endl; std::cout << "FTDI_read_bytes(" << len << ") failed : " << n << std::endl;
} }
return ok; return ok;
} }
@ -507,7 +507,7 @@ bool CUsb3xxxInterface::FTDI_write_packet(FT_HANDLE ft_handle, const char *pkt,
FT_STATUS ftStatus; FT_STATUS ftStatus;
bool ok = true; bool ok = true;
int nwritten; int nwritten;
if ( len > 0 ) if ( len > 0 )
{ {
ftStatus = FT_Write(m_FtdiHandle, (LPVOID *)pkt, (DWORD)len, (LPDWORD)&nwritten); ftStatus = FT_Write(m_FtdiHandle, (LPVOID *)pkt, (DWORD)len, (LPDWORD)&nwritten);

@ -49,27 +49,27 @@ CVocodecs::~CVocodecs()
// delete channels // delete channels
m_MutexChannels.lock(); m_MutexChannels.lock();
{ {
for ( int i = 0; i < m_Channels.size(); i++ ) for ( unsigned i = 0; i < m_Channels.size(); i++ )
{ {
delete m_Channels[i]; delete m_Channels[i];
} }
m_Channels.clear(); m_Channels.clear();
} }
m_MutexChannels.unlock(); m_MutexChannels.unlock();
// delete interfaces // delete interfaces
m_MutexInterfaces.lock(); m_MutexInterfaces.lock();
{ {
for ( int i = 0; i < m_Interfaces.size(); i++ ) for ( unsigned i = 0; i < m_Interfaces.size(); i++ )
{ {
delete m_Interfaces[i]; delete m_Interfaces[i];
} }
m_Interfaces.clear(); m_Interfaces.clear();
} }
m_MutexInterfaces.unlock(); m_MutexInterfaces.unlock();
// delete ftdi device descriptors // delete ftdi device descriptors
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ ) for ( unsigned i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{ {
delete m_FtdiDeviceDescrs[i]; delete m_FtdiDeviceDescrs[i];
} }
@ -82,14 +82,14 @@ bool CVocodecs::Init(void)
{ {
bool ok = true; bool ok = true;
int iNbCh = 0; int iNbCh = 0;
// discover and add vocodecs interfaces // discover and add vocodecs interfaces
DiscoverFtdiDevices(); DiscoverFtdiDevices();
// and create interfaces for the discovered devices // and create interfaces for the discovered devices
// first handle all even number of channels devices // first handle all even number of channels devices
std::vector<CVocodecChannel *> Multi3003DevicesChs; std::vector<CVocodecChannel *> Multi3003DevicesChs;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ ) for ( unsigned i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{ {
CFtdiDeviceDescr *descr = m_FtdiDeviceDescrs[i]; CFtdiDeviceDescr *descr = m_FtdiDeviceDescrs[i];
if ( !descr->IsUsed() && IsEven(descr->GetNbChannels()) ) if ( !descr->IsUsed() && IsEven(descr->GetNbChannels()) )
@ -104,7 +104,7 @@ bool CVocodecs::Init(void)
// they must be handeled in pair, or in pair with another // they must be handeled in pair, or in pair with another
// even number of channels device. // even number of channels device.
std::vector<CVocodecChannel *> PairsOf3000DevicesChs; std::vector<CVocodecChannel *> PairsOf3000DevicesChs;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ ) for ( unsigned i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{ {
CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i]; CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i];
CFtdiDeviceDescr *descr2 = NULL; CFtdiDeviceDescr *descr2 = NULL;
@ -112,7 +112,7 @@ bool CVocodecs::Init(void)
{ {
// any other single channel device to pair with ? // any other single channel device to pair with ?
bool found = false; bool found = false;
int j = i+1; unsigned j = i+1;
while ( !found && (j < m_FtdiDeviceDescrs.size()) ) while ( !found && (j < m_FtdiDeviceDescrs.size()) )
{ {
descr2 = m_FtdiDeviceDescrs[j]; descr2 = m_FtdiDeviceDescrs[j];
@ -133,7 +133,7 @@ bool CVocodecs::Init(void)
// now we should have only remaining the 3 channels device(s) // now we should have only remaining the 3 channels device(s)
// and possibly an unique single channel device // and possibly an unique single channel device
std::vector<CVocodecChannel *> Single3003DeviceChannels; std::vector<CVocodecChannel *> Single3003DeviceChannels;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ ) for ( unsigned i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{ {
CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i]; CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i];
CFtdiDeviceDescr *descr2 = NULL; CFtdiDeviceDescr *descr2 = NULL;
@ -141,7 +141,7 @@ bool CVocodecs::Init(void)
{ {
// any other 3 channel device to pair with ? // any other 3 channel device to pair with ?
bool found = false; bool found = false;
int j = i+1; unsigned j = i+1;
while ( !found && (j < m_FtdiDeviceDescrs.size()) ) while ( !found && (j < m_FtdiDeviceDescrs.size()) )
{ {
descr2 = m_FtdiDeviceDescrs[j]; descr2 = m_FtdiDeviceDescrs[j];
@ -162,7 +162,7 @@ bool CVocodecs::Init(void)
// at this point we should have only remaining an unique 3 channels // at this point we should have only remaining an unique 3 channels
// and or a unique single channel // and or a unique single channel
std::vector<CVocodecChannel *> Combined3003And3000DeviceChannels; std::vector<CVocodecChannel *> Combined3003And3000DeviceChannels;
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ ) for ( unsigned i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{ {
CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i]; CFtdiDeviceDescr *descr1 = m_FtdiDeviceDescrs[i];
CFtdiDeviceDescr *descr2 = NULL; CFtdiDeviceDescr *descr2 = NULL;
@ -171,7 +171,7 @@ bool CVocodecs::Init(void)
{ {
// any single channel device to pair with ? // any single channel device to pair with ?
bool found = false; bool found = false;
int j = 0; unsigned j = 0;
while ( !found && (j < m_FtdiDeviceDescrs.size()) ) while ( !found && (j < m_FtdiDeviceDescrs.size()) )
{ {
descr2 = m_FtdiDeviceDescrs[j]; descr2 = m_FtdiDeviceDescrs[j];
@ -202,7 +202,7 @@ bool CVocodecs::Init(void)
// for proper load sharing // for proper load sharing
// pairs of 3000 devices first // pairs of 3000 devices first
{ {
for ( int i = 0; i < PairsOf3000DevicesChs.size(); i++ ) for ( unsigned i = 0; i < PairsOf3000DevicesChs.size(); i++ )
{ {
m_Channels.push_back(PairsOf3000DevicesChs.at(i)); m_Channels.push_back(PairsOf3000DevicesChs.at(i));
} }
@ -210,7 +210,7 @@ bool CVocodecs::Init(void)
} }
// next the left-over single 3003 device // next the left-over single 3003 device
{ {
for ( int i = 0; i < Single3003DeviceChannels.size(); i++ ) for ( unsigned i = 0; i < Single3003DeviceChannels.size(); i++ )
{ {
m_Channels.push_back(Single3003DeviceChannels.at(i)); m_Channels.push_back(Single3003DeviceChannels.at(i));
} }
@ -219,10 +219,10 @@ bool CVocodecs::Init(void)
// finally interlace multi-3003 and pairs of 3003 devices which always // finally interlace multi-3003 and pairs of 3003 devices which always
// results to 6 channels per pair of 3003 // results to 6 channels per pair of 3003
{ {
int n = (int)Multi3003DevicesChs.size() / 6; unsigned n = (int)Multi3003DevicesChs.size() / 6;
for ( int i = 0; (i < 6) && (n != 0); i++ ) for ( unsigned i = 0; (i < 6) && (n != 0); i++ )
{ {
for ( int j = 0; j < n; j++ ) for ( unsigned j = 0; j < n; j++ )
{ {
m_Channels.push_back(Multi3003DevicesChs.at((j*6) + i)); m_Channels.push_back(Multi3003DevicesChs.at((j*6) + i));
} }
@ -231,14 +231,14 @@ bool CVocodecs::Init(void)
} }
// and finaly the hybrid combination of 3003 / 3000 // and finaly the hybrid combination of 3003 / 3000
{ {
for ( int i = 0; i < Combined3003And3000DeviceChannels.size(); i++ ) for ( unsigned i = 0; i < Combined3003And3000DeviceChannels.size(); i++ )
{ {
m_Channels.push_back(Combined3003And3000DeviceChannels.at(i)); m_Channels.push_back(Combined3003And3000DeviceChannels.at(i));
} }
Combined3003And3000DeviceChannels.clear(); Combined3003And3000DeviceChannels.clear();
} }
// done // done
if ( ok ) if ( ok )
{ {
@ -260,13 +260,13 @@ bool CVocodecs::DiscoverFtdiDevices(void)
bool ok = false; bool ok = false;
int iNbDevices = 0; int iNbDevices = 0;
FT_DEVICE_LIST_INFO_NODE *list; FT_DEVICE_LIST_INFO_NODE *list;
// clear vector // clear vector
for ( int i = 0; i < m_FtdiDeviceDescrs.size(); i++ ) for ( unsigned i = 0; i < m_FtdiDeviceDescrs.size(); i++ )
{ {
delete m_FtdiDeviceDescrs[i]; delete m_FtdiDeviceDescrs[i];
} }
// and discover // and discover
if ( FT_CreateDeviceInfoList((LPDWORD)&iNbDevices) == FT_OK ) if ( FT_CreateDeviceInfoList((LPDWORD)&iNbDevices) == FT_OK )
{ {
@ -276,7 +276,7 @@ bool CVocodecs::DiscoverFtdiDevices(void)
{ {
// allocate the list // allocate the list
list = new FT_DEVICE_LIST_INFO_NODE[iNbDevices]; list = new FT_DEVICE_LIST_INFO_NODE[iNbDevices];
// fill // fill
if ( FT_GetDeviceInfoList(list, (LPDWORD)&iNbDevices) == FT_OK ) if ( FT_GetDeviceInfoList(list, (LPDWORD)&iNbDevices) == FT_OK )
{ {
@ -299,7 +299,7 @@ bool CVocodecs::DiscoverFtdiDevices(void)
delete list; delete list;
} }
} }
// done // done
return ok; return ok;
} }
@ -311,10 +311,10 @@ CVocodecChannel *CVocodecs::OpenChannel(uint8 uiCodecIn, uint8 uiCodecOut)
{ {
CVocodecChannel *Channel = NULL; CVocodecChannel *Channel = NULL;
bool done = false; bool done = false;
// loop on all interface until suitable & available channel found // loop on all interface until suitable & available channel found
m_MutexChannels.lock(); m_MutexChannels.lock();
for ( int i = 0; (i < m_Channels.size()) && !done; i++ ) for ( unsigned i = 0; (i < m_Channels.size()) && !done; i++ )
{ {
if ( !m_Channels[i]->IsOpen() && if ( !m_Channels[i]->IsOpen() &&
(m_Channels[i]->GetCodecIn() == uiCodecIn) && (m_Channels[i]->GetCodecIn() == uiCodecIn) &&
@ -328,7 +328,7 @@ CVocodecChannel *CVocodecs::OpenChannel(uint8 uiCodecIn, uint8 uiCodecOut)
} }
} }
m_MutexChannels.unlock(); m_MutexChannels.unlock();
// done // done
return Channel; return Channel;
} }

@ -93,8 +93,8 @@ typedef unsigned int uint;
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// macros // macros
#define MIN(a,b) ((a) < (b))?(a):(b) #define MIN(a,b) (int(a) < int(b))?(a):(b)
#define MAX(a,b) ((a) > (b))?(a):(b) #define MAX(a,b) (int(a) > int(b))?(a):(b)
#define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8)))
#define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16)))
#define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF)) #define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF))

@ -36,9 +36,9 @@ DATADIR=/var/lib/xlxd
CC=g++ CC=g++
ifdef DEBUG ifdef DEBUG
CFLAGS=-ggdb3 -c -std=c++11 -MMD -MD -c CFLAGS=-ggdb3 -W -c -std=c++11 -MMD -MD -c
else else
CFLAGS=-c -std=c++11 -MMD -MD -c CFLAGS=-c -W -std=c++11 -MMD -MD -c
endif endif
ifdef NOXLX ifdef NOXLX
CFLAGS += -DNO_XLX CFLAGS += -DNO_XLX

@ -43,7 +43,7 @@ CBmPeer::CBmPeer(const CCallsign &callsign, const CIp &ip, const char *modules,
std::cout << "Adding BM peer" << std::endl; std::cout << "Adding BM peer" << std::endl;
// and construct all xlx clients // and construct all xlx clients
for ( int i = 0; i < ::strlen(modules); i++ ) for ( unsigned i = 0; i < ::strlen(modules); i++ )
{ {
// create // create
CBmClient *client = new CBmClient(callsign, ip, modules[i]); CBmClient *client = new CBmClient(callsign, ip, modules[i]);

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "main.h" #include "main.h"
@ -48,7 +48,7 @@ CCallsign::CCallsign(const char *sz, uint32 dmrid)
::memset(m_Suffix, ' ', sizeof(m_Suffix)); ::memset(m_Suffix, ' ', sizeof(m_Suffix));
m_Module = ' '; m_Module = ' ';
m_uiDmrid = dmrid; m_uiDmrid = dmrid;
// and populate // and populate
if ( ::strlen(sz) > 0 ) if ( ::strlen(sz) > 0 )
{ {
@ -82,14 +82,6 @@ CCallsign::CCallsign(const char *sz, uint32 dmrid)
} }
} }
CCallsign::CCallsign(const CCallsign &callsign)
{
::memcpy(m_Callsign, callsign.m_Callsign, sizeof(m_Callsign));
::memcpy(m_Suffix, callsign.m_Suffix, sizeof(m_Suffix));
m_Module = callsign.m_Module;
m_uiDmrid = callsign.m_uiDmrid;
}
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// status // status
@ -97,7 +89,7 @@ bool CCallsign::IsValid(void) const
{ {
bool valid = true; bool valid = true;
int i; int i;
// callsign // callsign
// first 3 chars are letter or number but cannot be all number // first 3 chars are letter or number but cannot be all number
int iNum = 0; int iNum = 0;
@ -115,21 +107,21 @@ bool CCallsign::IsValid(void) const
{ {
valid &= IsLetter(m_Callsign[i]) || IsNumber(m_Callsign[i]) || IsSpace(m_Callsign[i]); valid &= IsLetter(m_Callsign[i]) || IsNumber(m_Callsign[i]) || IsSpace(m_Callsign[i]);
} }
// prefix // prefix
// all chars are number, uppercase or space // all chars are number, uppercase or space
for ( i = 0; i < CALLSUFFIX_LEN; i++ ) for ( i = 0; i < CALLSUFFIX_LEN; i++ )
{ {
valid &= IsLetter(m_Suffix[i]) || IsNumber(m_Suffix[i]) || IsSpace(m_Suffix[i]); valid &= IsLetter(m_Suffix[i]) || IsNumber(m_Suffix[i]) || IsSpace(m_Suffix[i]);
} }
// module // module
// is an letter or space // is an letter or space
valid &= IsLetter(m_Module) || IsSpace(m_Module); valid &= IsLetter(m_Module) || IsSpace(m_Module);
// dmrid is not tested, as it can be NULL // dmrid is not tested, as it can be NULL
// if station does is not dmr registered // if station does is not dmr registered
// done // done
return valid; return valid;
} }
@ -174,14 +166,14 @@ void CCallsign::SetCallsign(const uint8 *buffer, int len, bool UpdateDmrid)
::memset(m_Callsign, ' ', sizeof(m_Callsign)); ::memset(m_Callsign, ' ', sizeof(m_Callsign));
m_Module = ' '; m_Module = ' ';
::memcpy(m_Callsign, buffer, MIN(len, sizeof(m_Callsign)-1)); ::memcpy(m_Callsign, buffer, MIN(len, sizeof(m_Callsign)-1));
for ( int i = 0; i < sizeof(m_Callsign); i++ ) for ( unsigned i = 0; i < sizeof(m_Callsign); i++ )
{ {
if ( m_Callsign[i] == 0 ) if ( m_Callsign[i] == 0 )
{ {
m_Callsign[i] = ' '; m_Callsign[i] = ' ';
} }
} }
if ( (len >= sizeof(m_Callsign)) && ((char)buffer[sizeof(m_Callsign)-1] != 0) ) if ( (len >= (int)sizeof(m_Callsign)) && ((char)buffer[sizeof(m_Callsign)-1] != 0) )
{ {
m_Module = (char)buffer[sizeof(m_Callsign)-1]; m_Module = (char)buffer[sizeof(m_Callsign)-1];
} }
@ -244,7 +236,7 @@ void CCallsign::SetSuffix(const uint8 *buffer, int len)
void CCallsign::PatchCallsign(int off, const uint8 *patch, int len) void CCallsign::PatchCallsign(int off, const uint8 *patch, int len)
{ {
if ( off < sizeof(m_Callsign) ) if ( off < CALLSIGN_LEN )
{ {
::memcpy(m_Callsign, patch, MIN(len, sizeof(m_Callsign) - off)); ::memcpy(m_Callsign, patch, MIN(len, sizeof(m_Callsign) - off));
} }
@ -265,7 +257,7 @@ void CCallsign::GetCallsign(uint8 *buffer) const
void CCallsign::GetCallsignString(char *sz) const void CCallsign::GetCallsignString(char *sz) const
{ {
int i; unsigned i;
for ( i = 0; (i < sizeof(m_Callsign)) && (m_Callsign[i] != ' '); i++ ) for ( i = 0; (i < sizeof(m_Callsign)) && (m_Callsign[i] != ' '); i++ )
{ {
sz[i] = m_Callsign[i]; sz[i] = m_Callsign[i];
@ -290,8 +282,8 @@ bool CCallsign::HasSameCallsignWithWildcard(const CCallsign &callsign) const
{ {
bool same = true; bool same = true;
bool done = false; bool done = false;
for ( int i = 0; (i < sizeof(m_Callsign)) && same && !done; i++ ) for ( unsigned i = 0; (i < sizeof(m_Callsign)) && same && !done; i++ )
{ {
if ( !(done = ((m_Callsign[i] == '*') || (callsign[i] == '*'))) ) if ( !(done = ((m_Callsign[i] == '*') || (callsign[i] == '*'))) )
{ {
@ -326,9 +318,9 @@ bool CCallsign::operator ==(const CCallsign &callsign) const
CCallsign::operator const char *() const CCallsign::operator const char *() const
{ {
char *sz = (char *)(const char *)m_sz; char *sz = (char *)(const char *)m_sz;
// empty // empty
::memset(sz, 0, sizeof(m_sz)); ::memset(sz, 0, sizeof(m_sz));
// callsign // callsign
sz[CALLSIGN_LEN] = 0; sz[CALLSIGN_LEN] = 0;
::memcpy(sz, m_Callsign, sizeof(m_Callsign)); ::memcpy(sz, m_Callsign, sizeof(m_Callsign));
@ -342,8 +334,8 @@ CCallsign::operator const char *() const
{ {
::strcat(sz, " / "); ::strcat(sz, " / ");
::strncat(sz, m_Suffix, sizeof(m_Suffix)); ::strncat(sz, m_Suffix, sizeof(m_Suffix));
} }
// done // done
return m_sz; return m_sz;
} }

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef ccallsign_h #ifndef ccallsign_h
@ -41,16 +41,12 @@ public:
// contructors // contructors
CCallsign(); CCallsign();
CCallsign(const char *, uint32 = 0); CCallsign(const char *, uint32 = 0);
CCallsign(const CCallsign &);
// destructor
virtual ~CCallsign() {};
// status // status
bool IsValid(void) const; bool IsValid(void) const;
bool HasSuffix(void) const; bool HasSuffix(void) const;
bool HasModule(void) const { return m_Module != ' '; } bool HasModule(void) const { return m_Module != ' '; }
// set // set
void SetCallsign(const char *, bool = true); void SetCallsign(const char *, bool = true);
void SetCallsign(const uint8 *, int, bool = true); void SetCallsign(const uint8 *, int, bool = true);
@ -59,33 +55,33 @@ public:
void SetModule(char); void SetModule(char);
void SetSuffix(const char *); void SetSuffix(const char *);
void SetSuffix(const uint8 *, int); void SetSuffix(const uint8 *, int);
// modify // modify
void PatchCallsign(int, const uint8 *, int); void PatchCallsign(int, const uint8 *, int);
// get // get
void GetCallsign(uint8 *) const; void GetCallsign(uint8 *) const;
void GetCallsignString(char *) const; void GetCallsignString(char *) const;
uint32 GetDmrid(void) const { return m_uiDmrid; } uint32 GetDmrid(void) const { return m_uiDmrid; }
void GetSuffix(uint8 *) const; void GetSuffix(uint8 *) const;
char GetModule(void) const { return m_Module; } char GetModule(void) const { return m_Module; }
// compare // compare
bool HasSameCallsign(const CCallsign &) const; bool HasSameCallsign(const CCallsign &) const;
bool HasSameCallsignWithWildcard(const CCallsign &) const; bool HasSameCallsignWithWildcard(const CCallsign &) const;
bool HasLowerCallsign(const CCallsign &) const; bool HasLowerCallsign(const CCallsign &) const;
bool HasSameModule(const CCallsign &) const; bool HasSameModule(const CCallsign &) const;
// operators // operators
bool operator ==(const CCallsign &) const; bool operator ==(const CCallsign &) const;
operator const char *() const; operator const char *() const;
protected: protected:
// helper // helper
bool IsNumber(char) const; bool IsNumber(char) const;
bool IsLetter(char) const; bool IsLetter(char) const;
bool IsSpace(char) const; bool IsSpace(char) const;
protected: protected:
// data // data
char m_Callsign[CALLSIGN_LEN]; char m_Callsign[CALLSIGN_LEN];

@ -125,14 +125,14 @@ bool CCallsignListItem::HasModuleListed(char module) const
bool CCallsignListItem::CheckListedModules(char *Modules) const bool CCallsignListItem::CheckListedModules(char *Modules) const
{ {
bool listed = false; bool listed = false;
if ( Modules != NULL ) if ( Modules != NULL )
{ {
// build a list of common modules // build a list of common modules
char list[NB_MODULES_MAX+1]; char list[NB_MODULES_MAX+1];
list[0] = 0; list[0] = 0;
// //
for ( int i = 0; i < ::strlen(Modules); i++ ) for ( unsigned i = 0; i < ::strlen(Modules); i++ )
{ {
if ( HasModuleListed(Modules[i]) ) if ( HasModuleListed(Modules[i]) )
{ {
@ -144,4 +144,3 @@ bool CCallsignListItem::CheckListedModules(char *Modules) const
} }
return listed; return listed;
} }

@ -44,7 +44,7 @@ CDextraPeer::CDextraPeer(const CCallsign &callsign, const CIp &ip, const char *m
std::cout << "Adding DExtra peer" << std::endl; std::cout << "Adding DExtra peer" << std::endl;
// and construct the DExtra clients // and construct the DExtra clients
for ( int i = 0; i < ::strlen(modules); i++ ) for ( unsigned i = 0; i < ::strlen(modules); i++ )
{ {
// create // create
CDextraClient *client = new CDextraClient(callsign, ip, modules[i], version.GetMajor()); CDextraClient *client = new CDextraClient(callsign, ip, modules[i], version.GetMajor());

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -86,17 +86,6 @@ CDvFramePacket::CDvFramePacket
::memcpy(m_uiDvSync, dmrsync, sizeof(m_uiDvSync)); ::memcpy(m_uiDvSync, dmrsync, sizeof(m_uiDvSync));
} }
// copy constructor
CDvFramePacket::CDvFramePacket(const CDvFramePacket &DvFrame)
: CPacket(DvFrame)
{
::memcpy(m_uiAmbe, DvFrame.m_uiAmbe, sizeof(m_uiAmbe));
::memcpy(m_uiDvData, DvFrame.m_uiDvData, sizeof(m_uiDvData));
::memcpy(m_uiAmbePlus, DvFrame.m_uiAmbePlus, sizeof(m_uiAmbePlus));
::memcpy(m_uiDvSync, DvFrame.m_uiDvSync, sizeof(m_uiDvSync));
}
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// virtual duplication // virtual duplication

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef cdvframepacket_h #ifndef cdvframepacket_h
@ -57,25 +57,21 @@ public:
CDvFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8); CDvFramePacket(const uint8 *, const uint8 *, uint16, uint8, uint8);
CDvFramePacket(const uint8 *, uint16, uint8, uint8, uint8); CDvFramePacket(const uint8 *, uint16, uint8, uint8, uint8);
CDvFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *); CDvFramePacket(uint16, uint8, const uint8 *, const uint8 *, uint8, uint8, const uint8 *, const uint8 *);
CDvFramePacket(const CDvFramePacket &);
// destructor
virtual ~CDvFramePacket() {};
// virtual duplication // virtual duplication
CPacket *Duplicate(void) const; CPacket *Duplicate(void) const;
// identity // identity
bool IsDvFrame(void) const { return true; } bool IsDvFrame(void) const { return true; }
bool HaveTranscodableAmbe(void) const { return true; } bool HaveTranscodableAmbe(void) const { return true; }
// get // get
const uint8 *GetAmbe(uint8) const; const uint8 *GetAmbe(uint8) const;
const uint8 *GetAmbe(void) const { return m_uiAmbe; } const uint8 *GetAmbe(void) const { return m_uiAmbe; }
const uint8 *GetAmbePlus(void) const { return m_uiAmbePlus; } const uint8 *GetAmbePlus(void) const { return m_uiAmbePlus; }
const uint8 *GetDvData(void) const { return m_uiDvData; } const uint8 *GetDvData(void) const { return m_uiDvData; }
const uint8 *GetDvSync(void) const { return m_uiDvSync; } const uint8 *GetDvSync(void) const { return m_uiDvSync; }
// set // set
void SetDvData(uint8 *); void SetDvData(uint8 *);
void SetAmbe(uint8, uint8 *); void SetAmbe(uint8, uint8 *);
@ -87,7 +83,7 @@ protected:
// get // get
uint8 *GetAmbeData(void) { return m_uiAmbe; } uint8 *GetAmbeData(void) { return m_uiAmbe; }
uint8 *GetAmbePlusData(void) { return m_uiAmbePlus; } uint8 *GetAmbePlusData(void) { return m_uiAmbePlus; }
protected: protected:
// data (dstar) // data (dstar)
uint8 m_uiAmbe[AMBE_SIZE]; uint8 m_uiAmbe[AMBE_SIZE];

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "main.h" #include "main.h"
@ -85,23 +85,6 @@ CDvHeaderPacket::CDvHeaderPacket(const CCallsign &my, const CCallsign &ur, const
m_csMY = my; m_csMY = my;
} }
// copy constructor
CDvHeaderPacket::CDvHeaderPacket(const CDvHeaderPacket &Header)
: CPacket(Header)
{
m_uiFlag1 = Header.m_uiFlag1;
m_uiFlag2 = Header.m_uiFlag2;
m_uiFlag3 = Header.m_uiFlag3;
m_csUR = Header.m_csUR;
m_csRPT1 = Header.m_csRPT1;
m_csRPT2 = Header.m_csRPT2;
m_csMY = Header.m_csMY;
m_uiCrc = Header.m_uiCrc;
}
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// virtual duplication // virtual duplication
@ -134,11 +117,11 @@ void CDvHeaderPacket::ConvertToDstarStruct(struct dstar_header *buffer) const
bool CDvHeaderPacket::IsValid(void) const bool CDvHeaderPacket::IsValid(void) const
{ {
bool valid = CPacket::IsValid(); bool valid = CPacket::IsValid();
valid &= m_csRPT1.IsValid(); valid &= m_csRPT1.IsValid();
valid &= m_csRPT2.IsValid(); valid &= m_csRPT2.IsValid();
valid &= m_csMY.IsValid(); valid &= m_csMY.IsValid();
return valid; return valid;
} }
@ -168,7 +151,7 @@ CDvHeaderPacket::operator const char *() const
(const char *)m_csRPT1, (const char *)m_csRPT1,
(const char *)m_csRPT2, (const char *)m_csRPT2,
(const char *)m_csMY); (const char *)m_csMY);
return m_sz; return m_sz;
} }
#endif #endif

@ -19,7 +19,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Foobar. If not, see <http://www.gnu.org/licenses/>. // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef cdvheaderpacket_h #ifndef cdvheaderpacket_h
@ -64,10 +64,6 @@ public:
CDvHeaderPacket(const struct dstar_header *, uint16, uint8); CDvHeaderPacket(const struct dstar_header *, uint16, uint8);
CDvHeaderPacket(uint32, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8, uint8); CDvHeaderPacket(uint32, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8, uint8);
CDvHeaderPacket(const CCallsign &, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8); CDvHeaderPacket(const CCallsign &, const CCallsign &, const CCallsign &, const CCallsign &, uint16, uint8);
CDvHeaderPacket(const CDvHeaderPacket &);
// destructor
virtual ~CDvHeaderPacket(){};
// virtual duplication // virtual duplication
CPacket *Duplicate(void) const; CPacket *Duplicate(void) const;
@ -80,23 +76,23 @@ public:
// get valid // get valid
bool IsValid(void) const; bool IsValid(void) const;
// get callsigns // get callsigns
const CCallsign &GetUrCallsign(void) const { return m_csUR; } const CCallsign &GetUrCallsign(void) const { return m_csUR; }
const CCallsign &GetRpt1Callsign(void) const { return m_csRPT1; } const CCallsign &GetRpt1Callsign(void) const { return m_csRPT1; }
const CCallsign &GetRpt2Callsign(void) const { return m_csRPT2; } const CCallsign &GetRpt2Callsign(void) const { return m_csRPT2; }
const CCallsign &GetMyCallsign(void) const { return m_csMY; } const CCallsign &GetMyCallsign(void) const { return m_csMY; }
// get modules // get modules
char GetUrModule(void) const { return m_csUR.GetModule(); } char GetUrModule(void) const { return m_csUR.GetModule(); }
char GetRpt1Module(void) const { return m_csRPT1.GetModule(); } char GetRpt1Module(void) const { return m_csRPT1.GetModule(); }
char GetRpt2Module(void) const { return m_csRPT2.GetModule(); } char GetRpt2Module(void) const { return m_csRPT2.GetModule(); }
char GetMyModule(void) const { return m_csMY.GetModule(); } char GetMyModule(void) const { return m_csMY.GetModule(); }
// set callsigns // set callsigns
void SetRpt2Callsign(const CCallsign &cs) { m_csRPT2 = cs; } void SetRpt2Callsign(const CCallsign &cs) { m_csRPT2 = cs; }
void SetRpt2Module(char c) { m_csRPT2.SetModule(c); } void SetRpt2Module(char c) { m_csRPT2.SetModule(c); }
// operators // operators
bool operator ==(const CDvHeaderPacket &) const; bool operator ==(const CDvHeaderPacket &) const;
#ifdef IMPLEMENT_CDVHEADERPACKET_CONST_CHAR_OPERATOR #ifdef IMPLEMENT_CDVHEADERPACKET_CONST_CHAR_OPERATOR

@ -74,8 +74,10 @@ void CIp::Initialize(const int family, const uint16_t port, const char *address)
else else
{ {
if (1 > inet_pton(AF_INET, address, &(addr4->sin_addr))) if (1 > inet_pton(AF_INET, address, &(addr4->sin_addr)))
{
std::cerr << "Address Initialization Error: '" << address << "' is not a valdid IPV4 address!" << std::endl; std::cerr << "Address Initialization Error: '" << address << "' is not a valdid IPV4 address!" << std::endl;
is_set = false; is_set = false;
}
} }
} }
} }
@ -92,8 +94,10 @@ void CIp::Initialize(const int family, const uint16_t port, const char *address)
else else
{ {
if (1 > inet_pton(AF_INET6, address, &(addr6->sin6_addr))) if (1 > inet_pton(AF_INET6, address, &(addr6->sin6_addr)))
{
std::cerr << "Address Initialization Error: '" << address << "' is not a valid IPV6 address!" << std::endl; std::cerr << "Address Initialization Error: '" << address << "' is not a valid IPV6 address!" << std::endl;
is_set = false; is_set = false;
}
} }
} }
} }

@ -34,12 +34,6 @@ CNotification::CNotification()
m_iId = NOTIFICATION_NONE; m_iId = NOTIFICATION_NONE;
} }
CNotification::CNotification(const CNotification &Notification)
{
m_iId = Notification.m_iId;
m_Callsign = Notification.m_Callsign;
}
CNotification::CNotification(int iId) CNotification::CNotification(int iId)
{ {
m_iId = iId; m_iId = iId;

@ -46,22 +46,18 @@ class CNotification
public: public:
// constructor // constructor
CNotification(); CNotification();
CNotification(const CNotification &);
CNotification(int); CNotification(int);
CNotification(int, const CCallsign &); CNotification(int, const CCallsign &);
// destructor
~CNotification() {};
// get // get
int GetId(void) const { return m_iId; } int GetId(void) const { return m_iId; }
const CCallsign &GetCallsign(void) const { return m_Callsign; } const CCallsign &GetCallsign(void) const { return m_Callsign; }
protected: protected:
// data // data
int m_iId; int m_iId;
CCallsign m_Callsign; CCallsign m_Callsign;
}; };
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////

@ -577,7 +577,7 @@ CPacketStream *CReflector::GetStream(char module)
bool CReflector::IsStreamOpen(const CDvHeaderPacket *DvHeader) bool CReflector::IsStreamOpen(const CDvHeaderPacket *DvHeader)
{ {
bool open = false; bool open = false;
for ( int i = 0; (i < m_Streams.size()) && !open; i++ ) for ( unsigned i = 0; (i < m_Streams.size()) && !open; i++ )
{ {
open = ( (m_Streams[i].GetStreamId() == DvHeader->GetStreamId()) && open = ( (m_Streams[i].GetStreamId() == DvHeader->GetStreamId()) &&
(m_Streams[i].IsOpen())); (m_Streams[i].IsOpen()));
@ -588,7 +588,7 @@ bool CReflector::IsStreamOpen(const CDvHeaderPacket *DvHeader)
char CReflector::GetStreamModule(CPacketStream *stream) char CReflector::GetStreamModule(CPacketStream *stream)
{ {
char module = ' '; char module = ' ';
for ( int i = 0; (i < m_Streams.size()) && (module == ' '); i++ ) for ( unsigned i = 0; (i < m_Streams.size()) && (module == ' '); i++ )
{ {
if ( &(m_Streams[i]) == stream ) if ( &(m_Streams[i]) == stream )
{ {

@ -42,13 +42,6 @@ CVersion::CVersion(int iMajor, int iMinor, int iRevision)
m_iRevision = iRevision; m_iRevision = iRevision;
} }
CVersion::CVersion(const CVersion &Version)
{
m_iMajor = Version.m_iMajor;
m_iMinor = Version.m_iMinor;
m_iRevision = Version.m_iRevision;
}
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// comparaison // comparaison
@ -84,4 +77,3 @@ bool CVersion::operator ==(const CVersion &Version) const
(Version.m_iMinor == m_iMinor) && (Version.m_iMinor == m_iMinor) &&
(Version.m_iRevision == m_iRevision )) ; (Version.m_iRevision == m_iRevision )) ;
} }

@ -36,11 +36,7 @@ public:
// constructor // constructor
CVersion(); CVersion();
CVersion(int, int, int); CVersion(int, int, int);
CVersion(const CVersion &);
// destructor
virtual ~CVersion() {}
// get // get
int GetMajor(void) const { return m_iMajor; } int GetMajor(void) const { return m_iMajor; }
int GetMinor(void) const { return m_iMinor; } int GetMinor(void) const { return m_iMinor; }
@ -48,7 +44,7 @@ public:
// comparaison // comparaison
bool IsEqualOrHigherTo(const CVersion &) const; bool IsEqualOrHigherTo(const CVersion &) const;
// operator // operator
bool operator ==(const CVersion &) const; bool operator ==(const CVersion &) const;

@ -43,12 +43,3 @@ CWiresxCmd::CWiresxCmd(const CIp &Ip, const CCallsign &Callsign, int iCmd, int i
m_iArg = iArg; m_iArg = iArg;
m_Time.Now(); m_Time.Now();
} }
CWiresxCmd::CWiresxCmd(const CWiresxCmd &Cmd)
{
m_Ip = Cmd.m_Ip;
m_Callsign = Cmd.m_Callsign;
m_iCmd = Cmd.m_iCmd;
m_iArg = Cmd.m_iArg;
m_Time = Cmd.m_Time;
}

@ -50,18 +50,14 @@ public:
// constructor // constructor
CWiresxCmd(); CWiresxCmd();
CWiresxCmd(const CIp &, const CCallsign &, int, int); CWiresxCmd(const CIp &, const CCallsign &, int, int);
CWiresxCmd(const CWiresxCmd &);
// destructor
virtual ~CWiresxCmd() {}
// get // get
const CCallsign &GetCallsign(void) const { return m_Callsign; } const CCallsign &GetCallsign(void) const { return m_Callsign; }
const CIp &GetIp(void) const { return m_Ip; } const CIp &GetIp(void) const { return m_Ip; }
int GetCmd(void) const { return m_iCmd; } int GetCmd(void) const { return m_iCmd; }
int GetArg(void) const { return m_iArg; } int GetArg(void) const { return m_iArg; }
const CTimePoint &GetTime(void) const { return m_Time; } const CTimePoint &GetTime(void) const { return m_Time; }
protected: protected:
// data // data
CIp m_Ip; CIp m_Ip;

@ -46,7 +46,7 @@ CXlxPeer::CXlxPeer(const CCallsign &callsign, const CIp &ip, const char *modules
//std::cout << "Adding XLX peer with protocol revision " << protrev << std::endl; //std::cout << "Adding XLX peer with protocol revision " << protrev << std::endl;
// and construct all xlx clients // and construct all xlx clients
for ( int i = 0; i < ::strlen(modules); i++ ) for ( unsigned i = 0; i < ::strlen(modules); i++ )
{ {
// create // create
CXlxClient *client = new CXlxClient(callsign, ip, modules[i], protrev); CXlxClient *client = new CXlxClient(callsign, ip, modules[i], protrev);

@ -491,7 +491,7 @@ bool CXlxProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsi
::strcpy(modules, (const char *)&(Buffer.data()[12])); ::strcpy(modules, (const char *)&(Buffer.data()[12]));
valid = callsign->IsValid(); valid = callsign->IsValid();
*version = CVersion(Buffer.data()[9], Buffer.data()[10], Buffer.data()[11]); *version = CVersion(Buffer.data()[9], Buffer.data()[10], Buffer.data()[11]);
for ( int i = 0; i < ::strlen(modules); i++ ) for ( unsigned i = 0; i < ::strlen(modules); i++ )
{ {
valid &= IsLetter(modules[i]); valid &= IsLetter(modules[i]);
} }
@ -519,7 +519,7 @@ bool CXlxProtocol::IsValidAckPacket(const CBuffer &Buffer, CCallsign *callsign,
::strcpy(modules, (const char *)&(Buffer.data()[12])); ::strcpy(modules, (const char *)&(Buffer.data()[12]));
valid = callsign->IsValid(); valid = callsign->IsValid();
*version = CVersion(Buffer.data()[9], Buffer.data()[10], Buffer.data()[11]); *version = CVersion(Buffer.data()[9], Buffer.data()[10], Buffer.data()[11]);
for ( int i = 0; i < ::strlen(modules); i++ ) for ( unsigned i = 0; i < ::strlen(modules); i++ )
{ {
valid &= IsLetter(modules[i]); valid &= IsLetter(modules[i]);
} }

@ -324,7 +324,7 @@ void CYsfProtocol::HandleQueue(void)
{ {
// update local stream cache or send triplet when needed // update local stream cache or send triplet when needed
uint8 sid = packet->GetYsfPacketSubId(); uint8 sid = packet->GetYsfPacketSubId();
if ( (sid >= 0) && (sid <= 4) ) if (sid <= 4)
{ {
//std::cout << (int)sid; //std::cout << (int)sid;
m_StreamsCache[iModId].m_dvFrames[sid] = CDvFramePacket((const CDvFramePacket &)*packet); m_StreamsCache[iModId].m_dvFrames[sid] = CDvFramePacket((const CDvFramePacket &)*packet);

@ -194,8 +194,8 @@ typedef unsigned int uint;
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// macros // macros
#define MIN(a,b) ((a) < (b))?(a):(b) #define MIN(a,b) (int(a) < int(b))?(a):(b)
#define MAX(a,b) ((a) > (b))?(a):(b) #define MAX(a,b) (int(a) > int(b))?(a):(b)
#define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8))) #define MAKEWORD(low, high) ((uint16)(((uint8)(low)) | (((uint16)((uint8)(high))) << 8)))
#define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16))) #define MAKEDWORD(low, high) ((uint32)(((uint16)(low)) | (((uint32)((uint16)(high))) << 16)))
#define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF)) #define LOBYTE(w) ((uint8)(uint16)(w & 0x00FF))

Loading…
Cancel
Save

Powered by TurnKey Linux.