first commit

main
root 2 years ago
commit 1dbe3feb40

Binary file not shown.

@ -0,0 +1,74 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVToolReader", "DVToolReader\DVToolReader.vcproj", "{415003E0-04C2-4757-B47B-D1465C3FE461}"
ProjectSection(ProjectDependencies) = postProject
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B} = {EF9E87F7-40A0-4916-AB29-00F9A4526A7B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Common\Common.vcproj", "{EF9E87F7-40A0-4916-AB29-00F9A4526A7B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVToolWriter", "DVToolWriter\DVToolWriter.vcproj", "{034377C2-0DA9-4D11-B882-D8B8F120B663}"
ProjectSection(ProjectDependencies) = postProject
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B} = {EF9E87F7-40A0-4916-AB29-00F9A4526A7B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wav2ambe", "wav2ambe\wav2ambe.vcproj", "{18684994-D6B0-40EF-A9BE-C148EF2BD5EC}"
ProjectSection(ProjectDependencies) = postProject
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B} = {EF9E87F7-40A0-4916-AB29-00F9A4526A7B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wav2dvtool", "wav2dvtool\wav2dvtool.vcproj", "{34B0F1FA-82D0-4A8A-BCE3-8EE54A5C44A1}"
ProjectSection(ProjectDependencies) = postProject
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B} = {EF9E87F7-40A0-4916-AB29-00F9A4526A7B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ambe2wav", "ambe2wav\ambe2wav.vcproj", "{8C55A75D-7BE1-4DCE-82D9-DEB44D8A369B}"
ProjectSection(ProjectDependencies) = postProject
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B} = {EF9E87F7-40A0-4916-AB29-00F9A4526A7B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dvtool2wav", "dvtool2wav\dvtool2wav.vcproj", "{1633EFC4-CEB7-455A-8587-10FE7ABB33AB}"
ProjectSection(ProjectDependencies) = postProject
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B} = {EF9E87F7-40A0-4916-AB29-00F9A4526A7B}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{415003E0-04C2-4757-B47B-D1465C3FE461}.Debug|Win32.ActiveCfg = Debug|Win32
{415003E0-04C2-4757-B47B-D1465C3FE461}.Debug|Win32.Build.0 = Debug|Win32
{415003E0-04C2-4757-B47B-D1465C3FE461}.Release|Win32.ActiveCfg = Release|Win32
{415003E0-04C2-4757-B47B-D1465C3FE461}.Release|Win32.Build.0 = Release|Win32
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B}.Debug|Win32.ActiveCfg = Debug|Win32
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B}.Debug|Win32.Build.0 = Debug|Win32
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B}.Release|Win32.ActiveCfg = Release|Win32
{EF9E87F7-40A0-4916-AB29-00F9A4526A7B}.Release|Win32.Build.0 = Release|Win32
{034377C2-0DA9-4D11-B882-D8B8F120B663}.Debug|Win32.ActiveCfg = Debug|Win32
{034377C2-0DA9-4D11-B882-D8B8F120B663}.Debug|Win32.Build.0 = Debug|Win32
{034377C2-0DA9-4D11-B882-D8B8F120B663}.Release|Win32.ActiveCfg = Release|Win32
{034377C2-0DA9-4D11-B882-D8B8F120B663}.Release|Win32.Build.0 = Release|Win32
{18684994-D6B0-40EF-A9BE-C148EF2BD5EC}.Debug|Win32.ActiveCfg = Debug|Win32
{18684994-D6B0-40EF-A9BE-C148EF2BD5EC}.Debug|Win32.Build.0 = Debug|Win32
{18684994-D6B0-40EF-A9BE-C148EF2BD5EC}.Release|Win32.ActiveCfg = Release|Win32
{18684994-D6B0-40EF-A9BE-C148EF2BD5EC}.Release|Win32.Build.0 = Release|Win32
{34B0F1FA-82D0-4A8A-BCE3-8EE54A5C44A1}.Debug|Win32.ActiveCfg = Debug|Win32
{34B0F1FA-82D0-4A8A-BCE3-8EE54A5C44A1}.Debug|Win32.Build.0 = Debug|Win32
{34B0F1FA-82D0-4A8A-BCE3-8EE54A5C44A1}.Release|Win32.ActiveCfg = Release|Win32
{34B0F1FA-82D0-4A8A-BCE3-8EE54A5C44A1}.Release|Win32.Build.0 = Release|Win32
{8C55A75D-7BE1-4DCE-82D9-DEB44D8A369B}.Debug|Win32.ActiveCfg = Debug|Win32
{8C55A75D-7BE1-4DCE-82D9-DEB44D8A369B}.Debug|Win32.Build.0 = Debug|Win32
{8C55A75D-7BE1-4DCE-82D9-DEB44D8A369B}.Release|Win32.ActiveCfg = Release|Win32
{8C55A75D-7BE1-4DCE-82D9-DEB44D8A369B}.Release|Win32.Build.0 = Release|Win32
{1633EFC4-CEB7-455A-8587-10FE7ABB33AB}.Debug|Win32.ActiveCfg = Debug|Win32
{1633EFC4-CEB7-455A-8587-10FE7ABB33AB}.Debug|Win32.Build.0 = Debug|Win32
{1633EFC4-CEB7-455A-8587-10FE7ABB33AB}.Release|Win32.ActiveCfg = Release|Win32
{1633EFC4-CEB7-455A-8587-10FE7ABB33AB}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,62 @@
AMBE Tools - 20140519
=====================
Windows
-------
To use the AMBE Tools software (D-Star only at present) you will first need to
build the latest version of wxWidgets (http://www.wxwidgets.org), the version I
used was 2.8.12, I also installed it in the default location which is
C:\wxWidgets-2.8.12.
You will also need a copy of PortAudio (http://www.portaudio.com), I used the
latest stable version which is currently 20071207 and it appears to be fine. I
put that into the "Visual Studio 2008\Projects" folder alongside the source code
for Digital Voice itself.
For compiling I use Visual C++ 2008 Express Edition downloaded from Microsoft
for free. I recommend that you use the same.
To build wxWidgets, you simply need to open Visual Studio 2008 using the File ->
Open -> Projects/Solutions and load the wx_dll.dsw file to be found in
wxWidgets-2.8.12\build\msw directory and then go into Batch Build and select the
DLL Unicode Debug and DLL Uncode Release entries for every one, this take a
little time! Then build them.
The path names for things like wxWidgets and PortAudio are embedded within the
Solution and Project preferences, and will need changing if anything other than
these default locations are used. The first pass through the compiler will no
doubt tell you all that you need to know if there are problems.
Once you have built the executables, you will need to copy the
portaudio_x86.dll, wxbase28u_vc_custom.dll, wxmsw28u_adv_vc_custom.dll, and
wxmsw28u_core_vc_custom.dll files to the same directory as your newly built
executables in order for it to run. If you are running in debug mode then the
required wxWidgets files have the names xxx28ud_xxxx instead. These can be found
in the wxWidgets-2.8.12\lib\vc_dll directory.
It is also probable that you'll need to install a copy of the latest Visual C++
run-time libraries from Microsoft, if you are not running the Digital Voice
software on the same machine as the development/compilation was done on. To do
this you need to copy and run the Vcredist_x86.exe file which is found at
<http://www.microsoft.com/en-gb/download/details.aspx?id=5582>
Linux
-----
You need to ensure that wxGTK and PortAudio are already installed on your
machine, under Ubuntu these are available from the standard repositories, the
versions provided are adequate. Alternatively install them from scratch, wxGTK
can be found at http://www.wxwidgets.org and PortAudio can be found at
http://www.portaudio.com. If you do a "make install" on both then they'll be
installed in the right places and nothing more needs to be done.
To actually build the software, type "make" in the same directory as this file
and all should build without errors, there may be a warning or two though. Once
compiled, do "make install".
Depending on your Linux distribution, you mat find that both PortAudio and
wxWidgets are available in a suitable repository, however the names probably
are different in each one. wxGTK is probably named something like
wxGTK-devel-xxxx for example, and make sure that you get a version in the 2.8
series.

@ -0,0 +1,10 @@
AMBE Tools - 20140519
=====================
20140519
--------
Split from the Digital Voice package.
Add support for the DV3000 on the Raspberry Pi.
Added the DV Tool Writer program.
Added the ambe2wav, dvtool2wav, wav2ambe and wav2dvtool command-line programs.

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

@ -0,0 +1,173 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "AMBE3000Thread.h"
#include "DStarDefines.h"
const unsigned int MAX_PACKETS = 10U;
CAMBE3000Thread::CAMBE3000Thread(CDV3000Controller* dongle) :
CDongleThread(),
m_dongle(dongle),
m_wantMode(A3_IDLE),
m_mode(A3_IDLE),
m_packets(0U)
{
wxASSERT(dongle != NULL);
}
CAMBE3000Thread::~CAMBE3000Thread()
{
}
bool CAMBE3000Thread::open()
{
m_mode = m_wantMode = A3_IDLE;
m_packets = 0U;
return m_dongle->open();
}
void* CAMBE3000Thread::Entry()
{
while (!m_killed) {
if (m_mode != m_wantMode) {
if (m_mode == A3_DECODE && m_packets == 0U && m_decodeData.isEmpty()) {
if (m_bleep)
sendBleep();
reset();
m_mode = m_wantMode;
} else if (m_mode == A3_ENCODE && m_packets == 0U && m_encodeAudio.isEmpty()) {
reset();
m_mode = m_wantMode;
} else if (m_mode == A3_IDLE) {
m_mode = m_wantMode;
}
}
switch (m_mode) {
case A3_DECODE:
processDecodeIn();
processDecodeOut();
break;
case A3_ENCODE:
processEncodeIn();
processEncodeOut();
break;
default:
break;
}
Sleep(5UL);
}
m_dongle->close();
delete m_dongle;
return NULL;
}
void CAMBE3000Thread::setDecode()
{
if (m_mode != A3_DECODE && m_decodeCallback == NULL)
return;
m_wantMode = A3_DECODE;
}
void CAMBE3000Thread::setEncode()
{
if (m_mode != A3_ENCODE && m_encodeCallback == NULL)
return;
m_wantMode = A3_ENCODE;
}
void CAMBE3000Thread::setIdle()
{
m_wantMode = A3_IDLE;
}
void CAMBE3000Thread::processDecodeIn()
{
if (m_packets >= MAX_PACKETS)
return;
unsigned char ambe[VOICE_FRAME_LENGTH_BYTES];
unsigned int len = m_decodeData.getData(ambe, VOICE_FRAME_LENGTH_BYTES);
if (len == 0U)
return;
// Convert the AMBE data to real audio, even if it's nonsense
m_dongle->decodeIn(ambe, VOICE_FRAME_LENGTH_BYTES);
m_packets++;
}
void CAMBE3000Thread::processDecodeOut()
{
wxFloat32 audioIn[DSTAR_AUDIO_BLOCK_SIZE];
bool res = m_dongle->decodeOut(audioIn, DSTAR_AUDIO_BLOCK_SIZE);
if (res) {
wxFloat32 audioOut[DSTAR_RADIO_BLOCK_SIZE];
upSample(audioIn, audioOut);
m_decodeCallback->decodeCallback(audioOut, DSTAR_RADIO_BLOCK_SIZE);
if (m_packets > 0U)
m_packets--;
}
}
void CAMBE3000Thread::processEncodeIn()
{
if (m_packets >= MAX_PACKETS)
return;
wxFloat32 audioIn[DSTAR_RADIO_BLOCK_SIZE];
::memset(audioIn, 0x00, DSTAR_RADIO_BLOCK_SIZE * sizeof(wxFloat32));
unsigned int len = m_encodeAudio.getData(audioIn, DSTAR_RADIO_BLOCK_SIZE);
if (len == 0U)
return;
wxFloat32 audioOut[DSTAR_AUDIO_BLOCK_SIZE];
downSample(audioIn, audioOut);
// Convert the audio into AMBE data
m_dongle->encodeIn(audioOut, DSTAR_AUDIO_BLOCK_SIZE);
m_packets++;
}
void CAMBE3000Thread::processEncodeOut()
{
unsigned char ambe[VOICE_FRAME_LENGTH_BYTES];
bool res = m_dongle->encodeOut(ambe, VOICE_FRAME_LENGTH_BYTES);
if (res) {
m_encodeCallback->encodeCallback(ambe, VOICE_FRAME_LENGTH_BYTES);
if (m_packets > 0U)
m_packets--;
}
}

@ -0,0 +1,58 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef AMBE3000Thread_H
#define AMBE3000Thread_H
#include "DV3000Controller.h"
#include "DongleThread.h"
#include <wx/wx.h>
class CAMBE3000Thread : public CDongleThread {
public:
CAMBE3000Thread(CDV3000Controller* dongle);
virtual ~CAMBE3000Thread();
virtual bool open();
virtual void setEncode();
virtual void setDecode();
virtual void setIdle();
virtual void* Entry();
private:
enum AMBE3000MODE {
A3_DECODE,
A3_ENCODE,
A3_IDLE
};
CDV3000Controller* m_dongle;
AMBE3000MODE m_wantMode;
AMBE3000MODE m_mode;
unsigned int m_packets;
void processDecodeOut();
void processDecodeIn();
void processEncodeOut();
void processEncodeIn();
};
#endif

Binary file not shown.

@ -0,0 +1,85 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "AMBEFileReader.h"
#include "DStarDefines.h"
#include <wx/wx.h>
static const char AMBE_SIGNATURE[] = "AMBE";
static const unsigned int AMBE_SIGNATURE_LENGTH = 4U;
CAMBEFileReader::CAMBEFileReader() :
m_fileName(),
m_file()
{
}
CAMBEFileReader::~CAMBEFileReader()
{
}
wxString CAMBEFileReader::getFileName()
{
return m_fileName;
}
bool CAMBEFileReader::open(const wxString& fileName)
{
m_fileName = fileName;
bool res = m_file.Open(fileName, wxT("rb"));
if (!res)
return false;
unsigned char buffer[AMBE_SIGNATURE_LENGTH];
size_t n = m_file.Read(buffer, AMBE_SIGNATURE_LENGTH);
if (n != AMBE_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
if (::memcmp(buffer, AMBE_SIGNATURE, AMBE_SIGNATURE_LENGTH) != 0) {
m_file.Close();
return false;
}
return true;
}
unsigned int CAMBEFileReader::read(unsigned char* buffer, unsigned int length, DVTFR_TYPE& type)
{
wxASSERT(buffer != 0);
wxASSERT(length > 0U);
if (length > VOICE_FRAME_LENGTH_BYTES)
length = VOICE_FRAME_LENGTH_BYTES;
size_t n = m_file.Read(buffer, length);
if (n != length)
return 0U;
type = DVTFR_DETAIL;
return length;
}
void CAMBEFileReader::close()
{
m_file.Close();
}

@ -0,0 +1,43 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef AMBEFileReader_H
#define AMBEFileReader_H
#include "FileReader.h"
#include <wx/wx.h>
#include <wx/ffile.h>
class CAMBEFileReader : public IFileReader {
public:
CAMBEFileReader();
virtual ~CAMBEFileReader();
virtual wxString getFileName();
virtual bool open(const wxString& fileName);
virtual unsigned int read(unsigned char* buffer, unsigned int length, DVTFR_TYPE& type);
virtual void close();
private:
wxString m_fileName;
wxFFile m_file;
};
#endif

Binary file not shown.

@ -0,0 +1,93 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "AMBEFileWriter.h"
#include "DStarDefines.h"
#include <wx/wx.h>
static const char AMBE_SIGNATURE[] = "AMBE";
static unsigned int AMBE_SIGNATURE_LENGTH = 4U;
CAMBEFileWriter::CAMBEFileWriter(const wxString& filename) :
m_filename(filename),
m_file()
{
}
CAMBEFileWriter::~CAMBEFileWriter()
{
}
wxString CAMBEFileWriter::getFilename()
{
return m_filename;
}
bool CAMBEFileWriter::open()
{
if (m_file.IsOpened())
close();
bool res = m_file.Open(m_filename, wxT("wb"));
if (!res)
return false;
size_t n = m_file.Write(AMBE_SIGNATURE, AMBE_SIGNATURE_LENGTH);
if (n != AMBE_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
return true;
}
bool CAMBEFileWriter::writeHeader(const CHeaderData& header)
{
return true;
}
bool CAMBEFileWriter::writeHeader(const unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != 0);
wxASSERT(length > 0U);
return true;
}
bool CAMBEFileWriter::writeFrame(const unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != 0);
wxASSERT(length > 0U);
if (length > VOICE_FRAME_LENGTH_BYTES)
length = VOICE_FRAME_LENGTH_BYTES;
size_t n = m_file.Write(buffer, length);
if (n != length) {
m_file.Close();
return false;
}
return true;
}
void CAMBEFileWriter::close()
{
m_file.Close();
}

@ -0,0 +1,45 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef AMBEFileWriter_H
#define AMBEFileWriter_H
#include "FileWriter.h"
#include <wx/wx.h>
#include <wx/ffile.h>
class CAMBEFileWriter : public IFileWriter {
public:
CAMBEFileWriter(const wxString& filename);
virtual ~CAMBEFileWriter();
virtual wxString getFilename();
virtual bool open();
virtual bool writeHeader(const CHeaderData& header);
virtual bool writeHeader(const unsigned char* buffer, unsigned int length);
virtual bool writeFrame(const unsigned char* buffer, unsigned int length);
virtual void close();
private:
wxString m_filename;
wxFFile m_file;
};
#endif

Binary file not shown.

@ -0,0 +1,29 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "AddressTextCtrl.h"
CAddressTextCtrl::CAddressTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos, const wxSize& size, long style) :
CRestrictedTextCtrl(parent, id, value, pos, size, style, ADDRESS_CHARS)
{
}
CAddressTextCtrl::~CAddressTextCtrl()
{
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef AddressTextCtrl_H
#define AddressTextCtrl_H
#include <wx/wx.h>
#include "RestrictedTextCtrl.h"
const wxString ADDRESS_CHARS = wxT("0123456789.");
class CAddressTextCtrl : public CRestrictedTextCtrl {
public:
CAddressTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0L);
virtual ~CAddressTextCtrl();
private:
};
#endif

@ -0,0 +1,26 @@
/*
* Copyright (C) 2009 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef AudioCallback_H
#define AudioCallback_H
#include <wx/wx.h>
class IAudioCallback {
public:
virtual void callback(const wxFloat32* input, wxFloat32* output, unsigned int nSamples, int id) = 0;
private:
};
#endif

@ -0,0 +1,51 @@
/*
* Copyright (C) 2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "BleepSet.h"
const unsigned int BORDER_SIZE = 5U;
const unsigned int CONTROL_WIDTH = 200U;
CBleepSet::CBleepSet(wxWindow* parent, int id, const wxString& title, bool bleep) :
wxPanel(parent, id),
m_title(title),
m_bleep(NULL)
{
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
m_bleep = new wxCheckBox(this, -1, _("End Bleep"));
m_bleep->SetValue(bleep);
sizer->Add(m_bleep, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
SetAutoLayout(true);
sizer->Fit(this);
sizer->SetSizeHints(this);
SetSizer(sizer);
}
CBleepSet::~CBleepSet()
{
}
bool CBleepSet::getBleep() const
{
return m_bleep->GetValue();
}

@ -0,0 +1,36 @@
/*
* Copyright (C) 2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef BleepSet_H
#define BleepSet_H
#include <wx/wx.h>
class CBleepSet : public wxPanel {
public:
CBleepSet(wxWindow* parent, int id, const wxString& title, bool bleep);
virtual ~CBleepSet();
virtual bool getBleep() const;
private:
wxString m_title;
wxCheckBox* m_bleep;
};
#endif

Binary file not shown.

@ -0,0 +1,73 @@
/*
* Copyright (C) 2009,2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Bleeper.h"
#include <cmath>
CBleeper::CBleeper(unsigned int sampleRate, unsigned int hz, unsigned int ms, float amplitude) :
m_audio(NULL),
m_length(0U),
m_total(0U),
m_position(0U)
{
wxASSERT(sampleRate > 0U);
wxASSERT(hz > 0U);
wxASSERT(ms > 0U);
wxASSERT(amplitude > 0.0F);
m_length = sampleRate / hz;
m_total = (sampleRate * ms) / 1000U;
m_audio = new wxFloat32[m_length];
for (unsigned int i = 0U; i < m_length; i++) {
if (i < m_length / 2U)
m_audio[i] = amplitude;
else
m_audio[i] = -amplitude;
}
}
CBleeper::~CBleeper()
{
delete[] m_audio;
}
unsigned int CBleeper::getAudio(wxFloat32* audio, unsigned int length)
{
wxASSERT(audio != NULL);
wxASSERT(length > 0U);
unsigned int n = 0U;
while (n < length && m_position < m_total) {
unsigned int pos = m_position % m_length;
audio[n] = m_audio[pos];
m_position++;
n++;
}
return n;
}
void CBleeper::reset()
{
m_position = 0U;
}

@ -0,0 +1,40 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef Bleeper_H
#define Bleeper_H
#include <wx/wx.h>
class CBleeper {
public:
CBleeper(unsigned int sampleRate, unsigned int hz, unsigned int ms, float amplitude);
~CBleeper();
unsigned int getAudio(wxFloat32* audio, unsigned int length);
void reset();
private:
wxFloat32* m_audio;
unsigned int m_length;
unsigned int m_total;
unsigned int m_position;
};
#endif

Binary file not shown.

@ -0,0 +1,92 @@
/*
* Copyright (C) 2009,2011,2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "CCITTChecksumReverse.h"
#include "Utils.h"
static const unsigned short ccittTab[] = {
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,
0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,
0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,
0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,
0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,
0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,
0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,
0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,
0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,
0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,
0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,
0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,
0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,
0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,
0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78};
CCCITTChecksumReverse::CCCITTChecksumReverse() :
m_crc16(0xFFFFU)
{
}
CCCITTChecksumReverse::~CCCITTChecksumReverse()
{
}
void CCCITTChecksumReverse::update(const unsigned char* data, unsigned int length)
{
wxASSERT(data != NULL);
for (unsigned int i = 0U; i < length; i++)
m_crc16 = wxUint16(m_crc8[1U]) ^ ccittTab[m_crc8[0U] ^ data[i]];
}
void CCCITTChecksumReverse::result(unsigned char* data)
{
wxASSERT(data != NULL);
m_crc16 = ~m_crc16;
data[0U] = m_crc8[0U];
data[1U] = m_crc8[1U];
}
bool CCCITTChecksumReverse::check(const unsigned char* data)
{
wxASSERT(data != NULL);
unsigned char sum[2U];
result(sum);
return sum[0U] == data[0U] && sum[1U] == data[1U];
}
void CCCITTChecksumReverse::reset()
{
m_crc16 = 0xFFFFU;
}

@ -0,0 +1,39 @@
/*
* Copyright (C) 2009,2011,2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef CCITTChecksumReverse_H
#define CCITTChecksumReverse_H
#include <wx/wx.h>
class CCCITTChecksumReverse {
public:
CCCITTChecksumReverse();
~CCCITTChecksumReverse();
void update(const unsigned char* data, unsigned int length);
void result(unsigned char* data);
bool check(const unsigned char* data);
void reset();
private:
union {
wxUint16 m_crc16;
wxUint8 m_crc8[2U];
};
};
#endif

@ -0,0 +1,86 @@
/*
* Copyright (C) 2010,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "DStarDefines.h"
#include "CallsignSet.h"
#if defined(__WINDOWS__)
const unsigned int LONG_CALLSIGN_WIDTH = 80U;
const unsigned int SHORT_CALLSIGN_WIDTH = 50U;
#else
const unsigned int LONG_CALLSIGN_WIDTH = 100U;
const unsigned int SHORT_CALLSIGN_WIDTH = 60U;
#endif
const unsigned int BORDER_SIZE = 5U;
CCallsignSet::CCallsignSet(wxWindow* parent, int id, const wxString& title, const wxString& callsign1, const wxString& callsign2) :
wxPanel(parent, id),
m_title(title),
m_callsign1(NULL),
m_callsign2(NULL)
{
wxFlexGridSizer* sizer = new wxFlexGridSizer(4);
wxStaticText* callsignLabel = new wxStaticText(this, -1, _("Callsign"));
sizer->Add(callsignLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
m_callsign1 = new CCallsignTextCtrl(this, -1, callsign1, wxDefaultPosition, wxSize(LONG_CALLSIGN_WIDTH, -1));
m_callsign1->SetMaxLength(LONG_CALLSIGN_LENGTH);
sizer->Add(m_callsign1, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
wxStaticText* slashLabel = new wxStaticText(this, -1, wxT("/"));
sizer->Add(slashLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
m_callsign2 = new CCallsignTextCtrl(this, -1, callsign2, wxDefaultPosition, wxSize(SHORT_CALLSIGN_WIDTH, -1));
m_callsign2->SetMaxLength(SHORT_CALLSIGN_LENGTH);
sizer->Add(m_callsign2, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
SetAutoLayout(true);
sizer->Fit(this);
sizer->SetSizeHints(this);
SetSizer(sizer);
}
CCallsignSet::~CCallsignSet()
{
}
bool CCallsignSet::Validate()
{
bool res = !getCallsign1().IsEmpty();
if (!res) {
wxMessageDialog dialog(this, _("The Callsign may not be empty"), m_title + _(" Error"), wxICON_ERROR);
dialog.ShowModal();
}
return res;
}
wxString CCallsignSet::getCallsign1() const
{
return m_callsign1->GetValue().MakeUpper();
}
wxString CCallsignSet::getCallsign2() const
{
return m_callsign2->GetValue().MakeUpper();
}

@ -0,0 +1,42 @@
/*
* Copyright (C) 2010,2011,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef CallsignSet_H
#define CallsignSet_H
#include "CallsignTextCtrl.h"
#include <wx/wx.h>
class CCallsignSet : public wxPanel {
public:
CCallsignSet(wxWindow* parent, int id, const wxString& title, const wxString& callsign1, const wxString& callsign2);
virtual ~CCallsignSet();
virtual bool Validate();
virtual wxString getCallsign1() const;
virtual wxString getCallsign2() const;
private:
wxString m_title;
CCallsignTextCtrl* m_callsign1;
CCallsignTextCtrl* m_callsign2;
};
#endif

Binary file not shown.

@ -0,0 +1,29 @@
/*
* Copyright (C) 2002,2003 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "CallsignTextCtrl.h"
CCallsignTextCtrl::CCallsignTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos, const wxSize& size, long style) :
CRestrictedTextCtrl(parent, id, value, pos, size, style, CALLSIGN_CHARS)
{
}
CCallsignTextCtrl::~CCallsignTextCtrl()
{
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2002,2003 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef CallsignTextCtrl_H
#define CallsignTextCtrl_H
#include <wx/wx.h>
#include "RestrictedTextCtrl.h"
const wxString CALLSIGN_CHARS = wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/ ");
class CCallsignTextCtrl : public CRestrictedTextCtrl {
public:
CCallsignTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0L);
virtual ~CCallsignTextCtrl();
private:
};
#endif

Binary file not shown.

@ -0,0 +1,491 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="Common"
ProjectGUID="{EF9E87F7-40A0-4916-AB29-00F9A4526A7B}"
RootNamespace="Common"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)..\portaudio\include&quot;;&quot;$(SolutionDir)..\WinUSB&quot;;&quot;$(SolutionDir)..\HID&quot;;&quot;C:\wxWidgets-2.8.12\include\msvc&quot;;&quot;C:\wxWidgets-2.8.12\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WINVER=0x0400;__WXMSW__;WXUSINGDLL;wxUSE_GUI=1;__WXDEBUG__;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;$(SolutionDir)..\portaudio\include&quot;;&quot;$(SolutionDir)..\WinUSB&quot;;&quot;$(SolutionDir)..\HID&quot;;&quot;C:\wxWidgets-2.8.12\include\msvc&quot;;&quot;C:\wxWidgets-2.8.12\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;WINVER=0x0400;__WXMSW__;WXUSINGDLL;wxUSE_GUI=1;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_LIB"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AddressTextCtrl.cpp"
>
</File>
<File
RelativePath=".\AMBE3000Thread.cpp"
>
</File>
<File
RelativePath=".\AMBEFileReader.cpp"
>
</File>
<File
RelativePath=".\AMBEFileWriter.cpp"
>
</File>
<File
RelativePath=".\Bleeper.cpp"
>
</File>
<File
RelativePath=".\BleepSet.cpp"
>
</File>
<File
RelativePath=".\CallsignSet.cpp"
>
</File>
<File
RelativePath=".\CallsignTextCtrl.cpp"
>
</File>
<File
RelativePath=".\CCITTChecksumReverse.cpp"
>
</File>
<File
RelativePath=".\DongleSet.cpp"
>
</File>
<File
RelativePath=".\DongleThread.cpp"
>
</File>
<File
RelativePath=".\DV3000Controller.cpp"
>
</File>
<File
RelativePath=".\DVDongleController.cpp"
>
</File>
<File
RelativePath=".\DVDongleThread.cpp"
>
</File>
<File
RelativePath=".\DVTOOLFileReader.cpp"
>
</File>
<File
RelativePath=".\DVTOOLFileWriter.cpp"
>
</File>
<File
RelativePath=".\ErrorEvent.cpp"
>
</File>
<File
RelativePath=".\FileReader.cpp"
>
</File>
<File
RelativePath=".\FileWriter.cpp"
>
</File>
<File
RelativePath=".\FIRFilter.cpp"
>
</File>
<File
RelativePath=".\HeaderData.cpp"
>
</File>
<File
RelativePath=".\HeaderEvent.cpp"
>
</File>
<File
RelativePath=".\Logger.cpp"
>
</File>
<File
RelativePath=".\MessageData.cpp"
>
</File>
<File
RelativePath=".\MessageEvent.cpp"
>
</File>
<File
RelativePath=".\MessageSet.cpp"
>
</File>
<File
RelativePath=".\MessageTextCtrl.cpp"
>
</File>
<File
RelativePath=".\PortTextCtrl.cpp"
>
</File>
<File
RelativePath=".\RestrictedTextCtrl.cpp"
>
</File>
<File
RelativePath=".\SerialDataController.cpp"
>
</File>
<File
RelativePath=".\SlowDataDecoder.cpp"
>
</File>
<File
RelativePath=".\SlowDataEncoder.cpp"
>
</File>
<File
RelativePath=".\SoundCardReaderWriter.cpp"
>
</File>
<File
RelativePath=".\SoundcardSet.cpp"
>
</File>
<File
RelativePath=".\UDPReaderWriter.cpp"
>
</File>
<File
RelativePath=".\Utils.cpp"
>
</File>
<File
RelativePath=".\WAVFileReader.cpp"
>
</File>
<File
RelativePath=".\WAVFileWriter.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\AddressTextCtrl.h"
>
</File>
<File
RelativePath=".\AMBE3000Thread.h"
>
</File>
<File
RelativePath=".\AMBEFileReader.h"
>
</File>
<File
RelativePath=".\AMBEFileWriter.h"
>
</File>
<File
RelativePath=".\AudioCallback.h"
>
</File>
<File
RelativePath=".\Bleeper.h"
>
</File>
<File
RelativePath=".\BleepSet.h"
>
</File>
<File
RelativePath=".\CallsignSet.h"
>
</File>
<File
RelativePath=".\CallsignTextCtrl.h"
>
</File>
<File
RelativePath=".\CCITTChecksumReverse.h"
>
</File>
<File
RelativePath=".\DecodeCallback.h"
>
</File>
<File
RelativePath=".\DongleSet.h"
>
</File>
<File
RelativePath=".\DongleThread.h"
>
</File>
<File
RelativePath=".\DStarDefines.h"
>
</File>
<File
RelativePath=".\DV3000Controller.h"
>
</File>
<File
RelativePath=".\DVDongleController.h"
>
</File>
<File
RelativePath=".\DVDongleThread.h"
>
</File>
<File
RelativePath=".\DVTOOLFileReader.h"
>
</File>
<File
RelativePath=".\DVTOOLFileWriter.h"
>
</File>
<File
RelativePath=".\EncodeCallback.h"
>
</File>
<File
RelativePath=".\ErrorEvent.h"
>
</File>
<File
RelativePath=".\FileReader.h"
>
</File>
<File
RelativePath=".\FileWriter.h"
>
</File>
<File
RelativePath=".\FIRFilter.h"
>
</File>
<File
RelativePath=".\HeaderData.h"
>
</File>
<File
RelativePath=".\HeaderEvent.h"
>
</File>
<File
RelativePath=".\Logger.h"
>
</File>
<File
RelativePath=".\MessageData.h"
>
</File>
<File
RelativePath=".\MessageEvent.h"
>
</File>
<File
RelativePath=".\MessageSet.h"
>
</File>
<File
RelativePath=".\MessageTextCtrl.h"
>
</File>
<File
RelativePath=".\PortTextCtrl.h"
>
</File>
<File
RelativePath=".\RestrictedTextCtrl.h"
>
</File>
<File
RelativePath=".\RingBuffer.h"
>
</File>
<File
RelativePath=".\SerialDataController.h"
>
</File>
<File
RelativePath=".\SlowDataDecoder.h"
>
</File>
<File
RelativePath=".\SlowDataEncoder.h"
>
</File>
<File
RelativePath=".\SoundCardReaderWriter.h"
>
</File>
<File
RelativePath=".\SoundcardSet.h"
>
</File>
<File
RelativePath=".\UDPReaderWriter.h"
>
</File>
<File
RelativePath=".\Utils.h"
>
</File>
<File
RelativePath=".\Version.h"
>
</File>
<File
RelativePath=".\WAVFileReader.h"
>
</File>
<File
RelativePath=".\WAVFileWriter.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -0,0 +1,124 @@
/*
* Copyright (C) 2009,2012 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef DStarDefines_H
#define DStarDefines_H
const unsigned int DSTAR_GMSK_SYMBOL_RATE = 4800U;
const float DSTAR_GMSK_BT = 0.5F;
const bool BIT_SYNC_BITS[] = {true, false, true, false};
const unsigned int BIT_SYNC_LENGTH_BITS = 4U;
const bool FRAME_SYNC_BITS[] = {true, true, true, false, true, true, false, false,
true, false, true, false, false, false, false};
const unsigned int FRAME_SYNC_LENGTH_BITS = 15U;
const unsigned char DATA_SYNC_BYTES[] = {0x55, 0x2D, 0x16};
const bool DATA_SYNC_BITS[] = {true, false, true, false, true, false, true, false,
true, false, true, true, false, true, false, false,
false, true, true, false, true, false, false, false};
const unsigned char END_PATTERN_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A};
const bool END_PATTERN_BITS[] = {true, false, true, false, true, false, true, false,
true, false, true, false, true, false, true, false,
true, false, true, false, true, false, true, false,
true, false, true, false, true, false, true, false,
false, false, false, true, false, false, true, true,
false, true, false, true, true, true, true, false};
const unsigned int END_PATTERN_LENGTH_BITS = 48U;
const unsigned int END_PATTERN_LENGTH_BYTES = END_PATTERN_LENGTH_BITS / 8U;
const unsigned char NULL_AMBE_DATA_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8};
const bool NULL_AMBE_DATA_BITS[] = {false, true, true, true, true, false, false, true,
true, false, true, true, false, false, false, true,
false, true, false, false, true, true, false, false,
false, false, false, true, false, false, false, true,
false, true, true, false, false, true, false, false,
false, true, false, true, true, false, false, false,
true, true, true, true, true, true, false, false,
true, false, false, false, false, true, true, false,
false, false, false, true, false, true, true, true};
// Note that these are already scrambled, 0x66 0x66 0x66 otherwise
const bool NULL_SLOW_DATA_BITS[] = {false, false, false, true, false, true, true, false,
false, false, true, false, true, false, false, true,
true, true, true, true, false, true, false, true};
const unsigned int VOICE_FRAME_LENGTH_BITS = 72U;
const unsigned int VOICE_FRAME_LENGTH_BYTES = VOICE_FRAME_LENGTH_BITS / 8U;
const unsigned int DATA_FRAME_LENGTH_BITS = 24U;
const unsigned int DATA_FRAME_LENGTH_BYTES = DATA_FRAME_LENGTH_BITS / 8U;
const unsigned int DV_FRAME_LENGTH_BITS = VOICE_FRAME_LENGTH_BITS + DATA_FRAME_LENGTH_BITS;
const unsigned int DV_FRAME_LENGTH_BYTES = VOICE_FRAME_LENGTH_BYTES + DATA_FRAME_LENGTH_BYTES;
const unsigned int FEC_SECTION_LENGTH_BITS = 660U;
const unsigned int RADIO_HEADER_LENGTH_BITS = 330U;
const unsigned int RADIO_HEADER_LENGTH_BYTES = 41U;
const unsigned int DATA_BLOCK_SIZE_BITS = 21U * DV_FRAME_LENGTH_BITS;
const unsigned int DATA_BLOCK_SIZE_BYTES = 21U * DV_FRAME_LENGTH_BYTES;
const unsigned char SLOW_DATA_TYPE_MASK = 0xF0;
const unsigned char SLOW_DATA_TYPE_GPSDATA = 0x30;
const unsigned char SLOW_DATA_TYPE_MESSAGE = 0x40;
const unsigned char SLOW_DATA_TYPE_HEADER = 0x50;
const unsigned char SLOW_DATA_TYPE_SQUELCH = 0xC0;
const unsigned char SLOW_DATA_LENGTH_MASK = 0x0F;
const unsigned int DSTAR_AUDIO_BLOCK_SIZE = 160U;
const unsigned int DSTAR_AUDIO_BLOCK_BYTES = DSTAR_AUDIO_BLOCK_SIZE * 2U;
const unsigned int DSTAR_RADIO_SAMPLE_RATE = 48000U;
const unsigned int DSTAR_RADIO_BLOCK_SIZE = 960U;
const unsigned int LONG_CALLSIGN_LENGTH = 8U;
const unsigned int SHORT_CALLSIGN_LENGTH = 4U;
const unsigned int MESSAGE_LENGTH = 20U;
const unsigned char DATA_MASK = 0x80U;
const unsigned char REPEATER_MASK = 0x40U;
const unsigned char INTERRUPTED_MASK = 0x20U;
const unsigned char CONTROL_SIGNAL_MASK = 0x10U;
const unsigned char URGENT_MASK = 0x08U;
const unsigned char REPEATER_CONTROL_MASK = 0x07U;
const unsigned char REPEATER_CONTROL = 0x07U;
const unsigned char AUTO_REPLY = 0x06U;
const unsigned char RESEND_REQUESTED = 0x04U;
const unsigned char ACK_FLAG = 0x03U;
const unsigned char NO_RESPONSE = 0x02U;
const unsigned char RELAY_UNAVAILABLE = 0x01U;
const unsigned int DSTAR_BLEEP_FREQ = 2000U;
const unsigned int DSTAR_BLEEP_LENGTH = 100U;
const float DSTAR_BLEEP_AMPL = 0.5F;
const unsigned int DSTAR_RADIO_BIT_LENGTH = DSTAR_RADIO_SAMPLE_RATE / DSTAR_GMSK_SYMBOL_RATE;
const unsigned int FRAME_TIME_MS = 20U;
const unsigned int FRAMES_BETWEEN_SYNC = 20U;
const unsigned int TICKS_PER_SEC = 50U;
enum DONGLE_TYPE {
DT_DVDONGLE,
DT_DV3000
};
#endif

@ -0,0 +1,223 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "DV3000Controller.h"
#include "DStarDefines.h"
#include "Utils.h"
const unsigned char DV3000_START_BYTE = 0x61U;
const unsigned char DV3000_TYPE_CONTROL = 0x00U;
const unsigned char DV3000_TYPE_AMBE = 0x01U;
const unsigned char DV3000_TYPE_AUDIO = 0x02U;
const unsigned char DV3000_CONTROL_RATEP = 0x0AU;
const unsigned char DV3000_CONTROL_PRODID = 0x30U;
const unsigned char DV3000_CONTROL_READY = 0x39U;
const unsigned char DV3000_REQ_PRODID[] = {DV3000_START_BYTE, 0x00U, 0x01U, DV3000_TYPE_CONTROL, DV3000_CONTROL_PRODID};
const unsigned int DV3000_REQ_PRODID_LEN = 5U;
const unsigned char DV3000_REQ_RATEP[] = {DV3000_START_BYTE, 0x00U, 0x0DU, DV3000_TYPE_CONTROL, DV3000_CONTROL_RATEP, 0x01U, 0x30U, 0x07U, 0x63U, 0x40U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x48U};
const unsigned int DV3000_REQ_RATEP_LEN = 17U;
const unsigned char DV3000_AUDIO_HEADER[] = {DV3000_START_BYTE, 0x01U, 0x42U, DV3000_TYPE_AUDIO, 0x00U, 0xA0U};
const unsigned char DV3000_AUDIO_HEADER_LEN = 6U;
const unsigned char DV3000_AMBE_HEADER[] = {DV3000_START_BYTE, 0x00U, 0x0BU, DV3000_TYPE_AMBE, 0x01U, 0x48U};
const unsigned char DV3000_AMBE_HEADER_LEN = 6U;
const unsigned int DV3000_HEADER_LEN = 4U;
const unsigned int BUFFER_LENGTH = 400U;
CDV3000Controller::CDV3000Controller(const wxString& address, unsigned int port) :
m_socket(address, port)
{
}
CDV3000Controller::~CDV3000Controller()
{
}
bool CDV3000Controller::open()
{
bool res = m_socket.open();
if (!res)
return false;
m_socket.write(DV3000_REQ_PRODID, DV3000_REQ_PRODID_LEN);
bool found = false;
for (unsigned int i = 0U; i < 10U; i++) {
unsigned char buffer[BUFFER_LENGTH];
RESP_TYPE type = getResponse(buffer, BUFFER_LENGTH);
if (type == RESP_ERROR) {
m_socket.close();
return false;
}
if (type == RESP_NAME) {
found = true;
break;
}
::wxMilliSleep(10UL);
}
if (!found) {
m_socket.close();
return false;
}
m_socket.write(DV3000_REQ_RATEP, DV3000_REQ_RATEP_LEN);
for (;;) {
unsigned char buffer[BUFFER_LENGTH];
RESP_TYPE type = getResponse(buffer, BUFFER_LENGTH);
if (type == RESP_ERROR) {
m_socket.close();
return false;
}
if (type == RESP_RATEP)
return true;
::wxMilliSleep(10UL);
}
}
void CDV3000Controller::encodeIn(const wxFloat32* audio, unsigned int length)
{
wxASSERT(audio != NULL);
wxASSERT(length == DSTAR_AUDIO_BLOCK_SIZE);
unsigned char buffer[DV3000_AUDIO_HEADER_LEN + DSTAR_AUDIO_BLOCK_BYTES];
::memcpy(buffer, DV3000_AUDIO_HEADER, DV3000_AUDIO_HEADER_LEN);
wxInt8* q = (wxInt8*)(buffer + DV3000_AUDIO_HEADER_LEN);
for (unsigned int i = 0; i < DSTAR_AUDIO_BLOCK_SIZE; i++, q += 2U) {
wxInt16 word = wxInt16(audio[i] * 32767.0F);
q[0U] = (word & 0xFF00) >> 8;
q[1U] = (word & 0x00FF) >> 0;
}
m_socket.write(buffer, DV3000_AUDIO_HEADER_LEN + DSTAR_AUDIO_BLOCK_BYTES);
}
bool CDV3000Controller::encodeOut(unsigned char* ambe, unsigned int length)
{
wxASSERT(ambe != NULL);
wxASSERT(length == VOICE_FRAME_LENGTH_BYTES);
unsigned char buffer[BUFFER_LENGTH];
RESP_TYPE type = getResponse(buffer, BUFFER_LENGTH);
if (type != RESP_AMBE)
return false;
::memcpy(ambe, buffer + DV3000_AMBE_HEADER_LEN, VOICE_FRAME_LENGTH_BYTES);
return true;
}
void CDV3000Controller::decodeIn(const unsigned char* ambe, unsigned int length)
{
wxASSERT(ambe != NULL);
wxASSERT(length == VOICE_FRAME_LENGTH_BYTES);
unsigned char buffer[DV3000_AMBE_HEADER_LEN + VOICE_FRAME_LENGTH_BYTES];
::memcpy(buffer, DV3000_AMBE_HEADER, DV3000_AMBE_HEADER_LEN);
::memcpy(buffer + DV3000_AMBE_HEADER_LEN, ambe, VOICE_FRAME_LENGTH_BYTES);
m_socket.write(buffer, DV3000_AMBE_HEADER_LEN + VOICE_FRAME_LENGTH_BYTES);
}
bool CDV3000Controller::decodeOut(wxFloat32* audio, unsigned int length)
{
wxASSERT(audio != NULL);
wxASSERT(length == DSTAR_AUDIO_BLOCK_SIZE);
unsigned char buffer[BUFFER_LENGTH];
RESP_TYPE type = getResponse(buffer, BUFFER_LENGTH);
if (type != RESP_AUDIO)
return false;
wxUint8* q = (wxUint8*)(buffer + DV3000_AUDIO_HEADER_LEN);
for (unsigned int i = 0U; i < DSTAR_AUDIO_BLOCK_SIZE; i++, q += 2U) {
wxInt16 word = (q[0] << 8) | (q[1U] << 0);
audio[i] = wxFloat32(word) / 32768.0F;
}
return true;
}
void CDV3000Controller::close()
{
m_socket.close();
}
CDV3000Controller::RESP_TYPE CDV3000Controller::getResponse(unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != NULL);
wxASSERT(length >= BUFFER_LENGTH);
int len = m_socket.read(buffer, length);
if (len == 0)
return RESP_NONE;
if (len < 0)
return RESP_ERROR;
if (buffer[0U] != DV3000_START_BYTE) {
wxLogError(wxT("Unknown byte from the DV3000, %02X"), buffer[0U]);
CUtils::dump(wxT("Bad data"), buffer, len);
return RESP_UNKNOWN;
}
unsigned int respLen = buffer[1U] * 256U + buffer[2U] + DV3000_HEADER_LEN;
if (len != int(respLen)) {
wxLogError(wxT("Invalid DV3000 data, %d != %u"), len, respLen);
CUtils::dump(wxT("Bad data"), buffer, len);
return RESP_ERROR;
}
if (buffer[3U] == DV3000_TYPE_AUDIO) {
return RESP_AUDIO;
} else if (buffer[3U] == DV3000_TYPE_AMBE) {
return RESP_AMBE;
} else if (buffer[3U] == DV3000_TYPE_CONTROL) {
if (buffer[4U] == DV3000_CONTROL_PRODID) {
return RESP_NAME;
} else if (buffer[4U] == DV3000_CONTROL_RATEP) {
return RESP_RATEP;
} else if (buffer[4U] == DV3000_CONTROL_READY) {
return RESP_UNKNOWN;
} else {
CUtils::dump(wxT("Unknown control data"), buffer, respLen);
return RESP_UNKNOWN;
}
} else {
CUtils::dump(wxT("Unknown data"), buffer, respLen);
return RESP_UNKNOWN;
}
}

@ -0,0 +1,57 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DV3000Controller_H
#define DV3000Controller_H
#include "UDPReaderWriter.h"
#include <wx/wx.h>
class CDV3000Controller {
public:
CDV3000Controller(const wxString& address, unsigned int port);
~CDV3000Controller();
bool open();
void encodeIn(const wxFloat32* audio, unsigned int length);
bool encodeOut(unsigned char* ambe, unsigned int length);
void decodeIn(const unsigned char* ambe, unsigned int length);
bool decodeOut(wxFloat32* audio, unsigned int length);
void close();
private:
CUDPReaderWriter m_socket;
enum RESP_TYPE {
RESP_NONE,
RESP_ERROR,
RESP_RATEP,
RESP_NAME,
RESP_AMBE,
RESP_AUDIO,
RESP_UNKNOWN
};
RESP_TYPE getResponse(unsigned char* buffer, unsigned int length);
};
#endif

@ -0,0 +1,361 @@
/*
* Copyright (C) 2010,2011,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "DVDongleController.h"
#include "DStarDefines.h"
const unsigned char DVD_RESP_NOP[] = {0x02, 0x00};
const unsigned int DVD_RESP_NOP_LEN = 2U;
const unsigned char DVD_REQ_START[] = {0x05, 0x00, 0x18, 0x00, 0x01};
const unsigned int DVD_REQ_START_LEN = 5U;
const unsigned char DVD_RESP_START[] = {0x05, 0x00, 0x18, 0x00, 0x01};
const unsigned int DVD_RESP_START_LEN = 5U;
const unsigned char DVD_REQ_STOP[] = {0x05, 0x00, 0x18, 0x00, 0x00};
const unsigned int DVD_REQ_STOP_LEN = 5U;
const unsigned char DVD_RESP_STOP[] = {0x05, 0x00, 0x18, 0x00, 0x00};
const unsigned int DVD_RESP_STOP_LEN = 5U;
const unsigned char DVD_REQ_NAME[] = {0x04, 0x20, 0x01, 0x00};
const unsigned int DVD_REQ_NAME_LEN = 4U;
const unsigned char DVD_RESP_NAME[] = {0x0E, 0x00, 0x01, 0x00, 'D', 'V', ' ', 'D', 'o', 'n', 'g', 'l', 'e', 0x00};
const unsigned int DVD_RESP_NAME_LEN = 14U;
const unsigned char DVD_AMBE_HEADER[] = {0x32, 0xA0};
const unsigned char DVD_AUDIO_HEADER[] = {0x42, 0x81};
const unsigned int DVD_HEADER_LEN = 2U;
const unsigned char DVD_AMBE_DEC_DATA[] = {0xEC, 0x13, 0x00, 0x00, 0x30, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x20, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char DVD_AMBE_ENC_DATA[] = {0xEC, 0x13, 0x00, 0x00, 0x30, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x04, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned int DVD_AMBE_HEADER_LEN = 24U;
const unsigned int DVD_AMBE_LENGTH_BYTES = 48U;
const unsigned int DVD_AUDIO_LENGTH_BYTES = 320U;
const unsigned int DVD_DATA_LEN = DVD_AMBE_LENGTH_BYTES + DVD_HEADER_LEN + DVD_AUDIO_LENGTH_BYTES + DVD_HEADER_LEN;
CDVDongleController::CDVDongleController(const wxString& device) :
m_serial(device, SERIAL_230400)
{
}
CDVDongleController::~CDVDongleController()
{
}
bool CDVDongleController::open()
{
bool res = m_serial.open();
if (!res)
return false;
m_serial.write(DVD_REQ_NAME, DVD_REQ_NAME_LEN);
for (;;) {
unsigned char buffer[DVD_AUDIO_LENGTH_BYTES];
RESP_TYPE type = getResponse(buffer, DVD_AUDIO_LENGTH_BYTES);
if (type == RESP_ERROR)
return false;
if (type == RESP_NAME)
return true;
::wxMilliSleep(5UL);
}
}
bool CDVDongleController::start()
{
m_serial.write(DVD_REQ_START, DVD_REQ_START_LEN);
for (;;) {
unsigned char buffer[DVD_AUDIO_LENGTH_BYTES];
RESP_TYPE type = getResponse(buffer, DVD_AUDIO_LENGTH_BYTES);
if (type == RESP_ERROR)
return false;
if (type == RESP_START)
return true;
::wxMilliSleep(5UL);
}
}
bool CDVDongleController::stop()
{
m_serial.write(DVD_REQ_STOP, DVD_REQ_STOP_LEN);
for (;;) {
unsigned char buffer[DVD_AUDIO_LENGTH_BYTES];
RESP_TYPE type = getResponse(buffer, DVD_AUDIO_LENGTH_BYTES);
if (type == RESP_ERROR)
return false;
if (type == RESP_STOP)
return true;
::wxMilliSleep(5UL);
}
}
void CDVDongleController::encodeIn(const wxFloat32* audio, unsigned int length)
{
wxASSERT(audio != NULL);
wxASSERT(length == DSTAR_AUDIO_BLOCK_SIZE);
unsigned char buffer[DVD_HEADER_LEN + DVD_AUDIO_LENGTH_BYTES];
unsigned char* p = buffer;
// First a dummy AMBE packet with parameter information in
::memcpy(p, DVD_AMBE_HEADER, DVD_HEADER_LEN);
p += DVD_HEADER_LEN;
::memcpy(p, DVD_AMBE_ENC_DATA, DVD_AMBE_LENGTH_BYTES);
m_serial.write(buffer, DVD_HEADER_LEN + DVD_AMBE_LENGTH_BYTES);
// Then the Audio data to be encoded
p = buffer;
::memcpy(p, DVD_AUDIO_HEADER, DVD_HEADER_LEN);
p += DVD_HEADER_LEN;
wxInt16* q = (wxInt16*)p;
for (unsigned int i = 0; i < DSTAR_AUDIO_BLOCK_SIZE; i++) {
wxInt16 word = wxInt16(audio[i] * 32767.0F);
*q++ = wxINT16_SWAP_ON_BE(word);
}
m_serial.write(buffer, DVD_HEADER_LEN + DVD_AUDIO_LENGTH_BYTES);
}
bool CDVDongleController::encodeOut(unsigned char* ambe, unsigned int length)
{
wxASSERT(ambe != NULL);
wxASSERT(length == VOICE_FRAME_LENGTH_BYTES);
bool ambeFound = false;
bool audioFound = false;
for (;;) {
unsigned char buffer[DVD_AUDIO_LENGTH_BYTES];
RESP_TYPE type = getResponse(buffer, DVD_AUDIO_LENGTH_BYTES);
if (type == RESP_ERROR)
return false;
if (type == RESP_AMBE) {
::memcpy(ambe, buffer + DVD_AMBE_HEADER_LEN, VOICE_FRAME_LENGTH_BYTES);
ambeFound = true;
} else if (type == RESP_AUDIO) {
audioFound = true;
}
if (ambeFound && audioFound)
return true;
::wxMilliSleep(5UL);
}
}
void CDVDongleController::decodeIn(const unsigned char* ambe, unsigned int length)
{
wxASSERT(ambe != NULL);
wxASSERT(length == VOICE_FRAME_LENGTH_BYTES);
unsigned char buffer[DVD_HEADER_LEN + DVD_AUDIO_LENGTH_BYTES];
unsigned char* p = buffer;
// First the received AMBE data for decoding
::memcpy(p, DVD_AMBE_HEADER, DVD_HEADER_LEN);
p += DVD_HEADER_LEN;
::memcpy(p, DVD_AMBE_DEC_DATA, DVD_AMBE_LENGTH_BYTES);
::memcpy(p + DVD_AMBE_HEADER_LEN, ambe, VOICE_FRAME_LENGTH_BYTES);
m_serial.write(buffer, DVD_HEADER_LEN + DVD_AMBE_LENGTH_BYTES);
// Then a dummy Audio packet
p = buffer;
::memcpy(p, DVD_AUDIO_HEADER, DVD_HEADER_LEN);
p += DVD_HEADER_LEN;
::memset(p, 0x00, DVD_AUDIO_LENGTH_BYTES);
m_serial.write(buffer, DVD_HEADER_LEN + DVD_AUDIO_LENGTH_BYTES);
}
bool CDVDongleController::decodeOut(wxFloat32* audio, unsigned int length)
{
wxASSERT(audio != NULL);
wxASSERT(length == DSTAR_AUDIO_BLOCK_SIZE);
bool ambeFound = false;
bool audioFound = false;
for (;;) {
unsigned char buffer[DVD_AUDIO_LENGTH_BYTES];
RESP_TYPE type = getResponse(buffer, DVD_AUDIO_LENGTH_BYTES);
if (type == RESP_ERROR)
return false;
if (type == RESP_AMBE) {
ambeFound = true;
} else if (type == RESP_AUDIO) {
wxInt16* q = (wxInt16*)buffer;
for (unsigned int i = 0U; i < DSTAR_AUDIO_BLOCK_SIZE; i++) {
wxInt16 word = wxINT16_SWAP_ON_BE(*q++);
audio[i] = wxFloat32(word) / 32768.0F;
}
audioFound = true;
}
if (ambeFound && audioFound)
return true;
::wxMilliSleep(5UL);
}
}
void CDVDongleController::close()
{
m_serial.close();
}
CDVDongleController::RESP_TYPE CDVDongleController::getResponse(unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != NULL);
wxASSERT(length >= DVD_AUDIO_LENGTH_BYTES);
unsigned char c1, c2;
int len = m_serial.read(&c1, 1U);
if (len == 0)
return RESP_NONE;
if (len < 0) {
wxLogError(wxT("Unable to receive the DVD header: len=%d"), len);
return RESP_ERROR;
}
switch (c1) {
case 0xA0U: // DVD_AMBE_HEADER
wxLogMessage(wxT("Re-synchronising with the DV-Dongle"));
buffer[0U] = 0x32U;
buffer[1U] = c1;
return processResponse(buffer, length);
case 0x81U: // DVD_AUDIO_HEADER
wxLogMessage(wxT("Re-synchronising with the DV-Dongle"));
buffer[0U] = 0x42U;
buffer[1U] = c1;
return processResponse(buffer, length);
default:
m_serial.read(&c2, 1U);
buffer[0U] = c1;
buffer[1U] = c2;
return processResponse(buffer, length);
}
}
CDVDongleController::RESP_TYPE CDVDongleController::processResponse(unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != NULL);
wxASSERT(length >= DVD_AUDIO_LENGTH_BYTES);
int len;
if (::memcmp(buffer, DVD_AUDIO_HEADER, DVD_HEADER_LEN) == 0) { // Audio data
do {
len = m_serial.read(buffer, DVD_AUDIO_LENGTH_BYTES);
if (len == 0)
::wxMilliSleep(5UL);
} while (len == 0);
if (len != int(DVD_AUDIO_LENGTH_BYTES)) {
wxLogError(wxT("Unable to receive the DVD audio data, len=%d"), len);
return RESP_ERROR;
}
return RESP_AUDIO;
} else if (::memcmp(buffer, DVD_AMBE_HEADER, DVD_HEADER_LEN) == 0) { // AMBE data
do {
len = m_serial.read(buffer, DVD_AMBE_LENGTH_BYTES);
if (len == 0)
::wxMilliSleep(5UL);
} while (len == 0);
if (len != int(DVD_AMBE_LENGTH_BYTES)) {
wxLogError(wxT("Unable to receive the DVD AMBE data, len=%d"), len);
return RESP_ERROR;
}
return RESP_AMBE;
} else if (::memcmp(buffer, DVD_RESP_STOP, DVD_HEADER_LEN) == 0) { // Start or Stop response
do {
len = m_serial.read(buffer + DVD_HEADER_LEN, DVD_RESP_STOP_LEN - DVD_HEADER_LEN);
if (len == 0)
::wxMilliSleep(5UL);
} while (len == 0);
if (len != int(DVD_RESP_STOP_LEN - DVD_HEADER_LEN)) {
wxLogError(wxT("Unable to receive the DVD start/stop response, len=%d"), len);
return RESP_ERROR;
}
bool res = ::memcmp(buffer, DVD_RESP_START, DVD_RESP_START_LEN) == 0;
if (res)
return RESP_START;
res = ::memcmp(buffer, DVD_RESP_STOP, DVD_RESP_STOP_LEN) == 0;
if (res)
return RESP_STOP;
wxLogError(wxT("Incorrect response to start/stop request: %02X %02X %02X %02X %02X"), buffer[0U], buffer[1U], buffer[2U], buffer[3U], buffer[4U]);
return RESP_ERROR;
} else if (::memcmp(buffer, DVD_RESP_NAME, DVD_HEADER_LEN) == 0) { // Dongle name
do {
len = m_serial.read(buffer + DVD_HEADER_LEN, DVD_RESP_NAME_LEN - DVD_HEADER_LEN);
if (len == 0)
::wxMilliSleep(5UL);
} while (len == 0);
if (len != int(DVD_RESP_NAME_LEN - DVD_HEADER_LEN)) {
wxLogError(wxT("Unable to receive the DVD name data, len=%d"), len);
return RESP_ERROR;
}
bool res = ::memcmp(buffer, DVD_RESP_NAME, DVD_RESP_NAME_LEN) == 0;
if (res)
return RESP_NAME;
wxLogError(wxT("Incorrect response to name request: %02X %02X %02X %02X %02X..."), buffer[0U], buffer[1U], buffer[2U], buffer[3U], buffer[4U]);
return RESP_ERROR;
} else if (::memcmp(buffer, DVD_RESP_NOP, DVD_HEADER_LEN) == 0) { // No op
return RESP_NOP;
} else { // Unknown data
wxLogError(wxT("Unknown DV Dongle header: %02X %02X"), buffer[0U], buffer[1U]);
return RESP_UNKNOWN;
}
}

@ -0,0 +1,62 @@
/*
* Copyright (C) 2010,2011,2012,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DVDongleController_H
#define DVDongleController_H
#include "SerialDataController.h"
#include <wx/wx.h>
class CDVDongleController {
public:
CDVDongleController(const wxString& device);
~CDVDongleController();
bool open();
bool start();
void encodeIn(const wxFloat32* audio, unsigned int length);
bool encodeOut(unsigned char* ambe, unsigned int length);
void decodeIn(const unsigned char* ambe, unsigned int length);
bool decodeOut(wxFloat32* audio, unsigned int length);
bool stop();
void close();
private:
CSerialDataController m_serial;
enum RESP_TYPE {
RESP_NONE,
RESP_ERROR,
RESP_START,
RESP_NAME,
RESP_STOP,
RESP_AMBE,
RESP_AUDIO,
RESP_NOP,
RESP_UNKNOWN
};
RESP_TYPE getResponse(unsigned char* buffer, unsigned int length);
RESP_TYPE processResponse(unsigned char* buffer, unsigned int length);
};
#endif

@ -0,0 +1,152 @@
/*
* Copyright (C) 2010,2011,2012,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "DVDongleThread.h"
#include "DStarDefines.h"
CDVDongleThread::CDVDongleThread(CDVDongleController* dongle) :
CDongleThread(),
m_dongle(dongle),
m_wantMode(DM_IDLE),
m_mode(DM_IDLE)
{
wxASSERT(dongle != NULL);
}
CDVDongleThread::~CDVDongleThread()
{
}
bool CDVDongleThread::open()
{
return m_dongle->open();
}
void* CDVDongleThread::Entry()
{
m_dongle->start();
while (!m_killed) {
if (m_mode != m_wantMode) {
if (m_mode == DM_DECODE && m_bleep)
sendBleep();
// Reset the FIR filter shift register
reset();
m_mode = m_wantMode;
}
switch (m_mode) {
case DM_IDLE:
processIdle();
break;
case DM_DECODE:
processDecode();
break;
case DM_ENCODE:
processEncode();
break;
}
}
m_dongle->stop();
m_dongle->close();
delete m_dongle;
return NULL;
}
void CDVDongleThread::setDecode()
{
if (m_mode == DM_ENCODE && m_decodeCallback == NULL)
return;
m_wantMode = DM_DECODE;
}
void CDVDongleThread::setEncode()
{
if (m_mode == DM_DECODE && m_encodeCallback == NULL)
return;
m_wantMode = DM_ENCODE;
}
void CDVDongleThread::setIdle()
{
m_wantMode = DM_IDLE;
}
void CDVDongleThread::processDecode()
{
unsigned char ambe[VOICE_FRAME_LENGTH_BYTES];
::memset(ambe, 0x00, VOICE_FRAME_LENGTH_BYTES);
m_decodeData.getData(ambe, VOICE_FRAME_LENGTH_BYTES);
// Convert the AMBE data to real audio, even if it's nonsense
m_dongle->decodeIn(ambe, VOICE_FRAME_LENGTH_BYTES);
wxFloat32 audioIn[DSTAR_AUDIO_BLOCK_SIZE];
bool res = m_dongle->decodeOut(audioIn, DSTAR_AUDIO_BLOCK_SIZE);
if (!res)
wxLogError(wxT("An error occurred in decodeOut"));
wxFloat32 audioOut[DSTAR_RADIO_BLOCK_SIZE];
upSample(audioIn, audioOut);
m_decodeCallback->decodeCallback(audioOut, DSTAR_RADIO_BLOCK_SIZE);
}
void CDVDongleThread::processEncode()
{
wxFloat32 audioIn[DSTAR_RADIO_BLOCK_SIZE];
::memset(audioIn, 0x00, DSTAR_RADIO_BLOCK_SIZE * sizeof(wxFloat32));
m_encodeAudio.getData(audioIn, DSTAR_RADIO_BLOCK_SIZE);
wxFloat32 audioOut[DSTAR_AUDIO_BLOCK_SIZE];
downSample(audioIn, audioOut);
// Convert the audio into AMBE data
m_dongle->encodeIn(audioOut, DSTAR_AUDIO_BLOCK_SIZE);
unsigned char ambe[VOICE_FRAME_LENGTH_BYTES];
bool res = m_dongle->encodeOut(ambe, VOICE_FRAME_LENGTH_BYTES);
if (!res)
wxLogError(wxT("An error occurred in encodeOut"));
m_encodeCallback->encodeCallback(ambe, VOICE_FRAME_LENGTH_BYTES);
}
void CDVDongleThread::processIdle()
{
unsigned char ambe[VOICE_FRAME_LENGTH_BYTES];
::memset(ambe, 0x00, VOICE_FRAME_LENGTH_BYTES);
// Convert the AMBE data to real audio, even if it's nonsense
m_dongle->decodeIn(ambe, VOICE_FRAME_LENGTH_BYTES);
wxFloat32 audio[DSTAR_RADIO_BLOCK_SIZE];
bool res = m_dongle->decodeOut(audio, DSTAR_AUDIO_BLOCK_SIZE);
if (!res)
wxLogError(wxT("An error occurred in decodeOut"));
}

@ -0,0 +1,56 @@
/*
* Copyright (C) 2010,2011,2012,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DVDongleThread_H
#define DVDongleThread_H
#include "DVDongleController.h"
#include "DongleThread.h"
#include <wx/wx.h>
class CDVDongleThread : public CDongleThread {
public:
CDVDongleThread(CDVDongleController* dongle);
virtual ~CDVDongleThread();
virtual bool open();
virtual void setEncode();
virtual void setDecode();
virtual void setIdle();
virtual void* Entry();
private:
enum DVDMODE {
DM_IDLE,
DM_DECODE,
DM_ENCODE
};
CDVDongleController* m_dongle;
DVDMODE m_wantMode;
DVDMODE m_mode;
void processDecode();
void processEncode();
void processIdle();
};
#endif

Binary file not shown.

@ -0,0 +1,137 @@
/*
* Copyright (C) 2009,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "DVTOOLFileReader.h"
#include <wx/wx.h>
static const char DVTOOL_SIGNATURE[] = "DVTOOL";
static const unsigned int DVTOOL_SIGNATURE_LENGTH = 6U;
static const char DSVT_SIGNATURE[] = "DSVT";
static const unsigned int DSVT_SIGNATURE_LENGTH = 4U;
static const unsigned int FIXED_DATA_LENGTH = 9U;
static const unsigned char HEADER_FLAG = 0x10;
static const unsigned char DATA_FLAG = 0x20;
static const unsigned char HEADER_MASK = 0x80;
static const unsigned char TRAILER_MASK = 0x40;
CDVTOOLFileReader::CDVTOOLFileReader() :
m_fileName(),
m_file(),
m_records(0U)
{
}
CDVTOOLFileReader::~CDVTOOLFileReader()
{
}
wxString CDVTOOLFileReader::getFileName()
{
return m_fileName;
}
bool CDVTOOLFileReader::open(const wxString& fileName)
{
m_fileName = fileName;
bool res = m_file.Open(fileName, wxT("rb"));
if (!res)
return false;
unsigned char buffer[DVTOOL_SIGNATURE_LENGTH];
size_t n = m_file.Read(buffer, DVTOOL_SIGNATURE_LENGTH);
if (n != DVTOOL_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
if (::memcmp(buffer, DVTOOL_SIGNATURE, DVTOOL_SIGNATURE_LENGTH) != 0) {
m_file.Close();
return false;
}
wxUint32 uint32;
n = m_file.Read(&uint32, sizeof(wxUint32));
if (n != sizeof(wxUint32)) {
m_file.Close();
return false;
}
m_records = wxUINT32_SWAP_ON_LE(uint32);
return true;
}
unsigned int CDVTOOLFileReader::read(unsigned char* buffer, unsigned int length, DVTFR_TYPE& type)
{
wxASSERT(buffer != 0);
wxASSERT(length > 0U);
wxUint16 uint16;
size_t n = m_file.Read(&uint16, sizeof(wxUint16));
if (n != sizeof(wxUint16))
return 0U;
wxUint16 len = wxUINT16_SWAP_ON_BE(uint16) - 15U;
if (len > length)
return 0U;
unsigned char bytes[FIXED_DATA_LENGTH];
n = m_file.Read(bytes, DSVT_SIGNATURE_LENGTH);
if (n != DSVT_SIGNATURE_LENGTH)
return 0U;
if (::memcmp(bytes, DSVT_SIGNATURE, DSVT_SIGNATURE_LENGTH) != 0)
return 0U;
char flag;
n = m_file.Read(&flag, 1U);
if (n != 1U)
return 0U;
type = (flag == HEADER_FLAG) ? DVTFR_HEADER : DVTFR_DETAIL;
n = m_file.Read(bytes, FIXED_DATA_LENGTH);
if (n != FIXED_DATA_LENGTH)
return 0U;
n = m_file.Read(&flag, 1U);
if (n != 1U)
return 0U;
if (type == DVTFR_DETAIL) {
if ((flag & TRAILER_MASK) == TRAILER_MASK)
type = DVTFR_TRAILER;
}
n = m_file.Read(buffer, len);
if (n != len)
return 0U;
return len;
}
void CDVTOOLFileReader::close()
{
m_file.Close();
}

@ -0,0 +1,44 @@
/*
* Copyright (C) 2009,2010,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DVTOOLFileReader_H
#define DVTOOLFileReader_H
#include "FileReader.h"
#include <wx/wx.h>
#include <wx/ffile.h>
class CDVTOOLFileReader : public IFileReader {
public:
CDVTOOLFileReader();
virtual ~CDVTOOLFileReader();
virtual wxString getFileName();
virtual bool open(const wxString& fileName);
virtual unsigned int read(unsigned char* buffer, unsigned int length, DVTFR_TYPE& type);
virtual void close();
private:
wxString m_fileName;
wxFFile m_file;
wxUint32 m_records;
};
#endif

@ -0,0 +1,277 @@
/*
* Copyright (C) 2009,2010,2012,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "CCITTChecksumReverse.h"
#include "DVTOOLFileWriter.h"
#include "DStarDefines.h"
#include <wx/wx.h>
static const char DVTOOL_SIGNATURE[] = "DVTOOL";
static unsigned int DVTOOL_SIGNATURE_LENGTH = 6U;
static const char DSVT_SIGNATURE[] = "DSVT";
static unsigned int DSVT_SIGNATURE_LENGTH = 4U;
static const unsigned char HEADER_FLAG = 0x10;
static const unsigned char DATA_FLAG = 0x20;
static const unsigned char FIXED_DATA[] = {0x00, 0x81, 0x00, 0x20, 0x00, 0x01, 0x02, 0xC0, 0xDE};
static unsigned int FIXED_DATA_LENGTH = 9U;
static const unsigned char TRAILER_DATA[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned int TRAILER_DATA_LENGTH = 12U;
static const unsigned char HEADER_MASK = 0x80;
static const unsigned char TRAILER_MASK = 0x40;
CDVTOOLFileWriter::CDVTOOLFileWriter(const wxString& filename) :
m_filename(filename),
m_file(),
m_count(0U),
m_sequence(0U),
m_offset(0)
{
}
CDVTOOLFileWriter::~CDVTOOLFileWriter()
{
}
wxString CDVTOOLFileWriter::getFilename()
{
return m_filename;
}
bool CDVTOOLFileWriter::open()
{
if (m_file.IsOpened())
close();
bool res = m_file.Open(m_filename, wxT("wb"));
if (!res)
return false;
size_t n = m_file.Write(DVTOOL_SIGNATURE, DVTOOL_SIGNATURE_LENGTH);
if (n != DVTOOL_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
m_offset = m_file.Tell();
wxUint32 dummy = 0U;
n = m_file.Write(&dummy, sizeof(wxUint32));
if (n != sizeof(wxUint32)) {
m_file.Close();
return false;
}
m_sequence = 0U;
m_count = 0U;
return true;
}
bool CDVTOOLFileWriter::writeHeader(const CHeaderData& header)
{
unsigned char buffer[RADIO_HEADER_LENGTH_BYTES];
buffer[0] = header.getFlag1();
buffer[1] = header.getFlag2();
buffer[2] = header.getFlag3();
for (unsigned int i = 0U; i < LONG_CALLSIGN_LENGTH; i++)
buffer[3 + i] = header.getRptCall1().GetChar(i);
for (unsigned int i = 0U; i < LONG_CALLSIGN_LENGTH; i++)
buffer[11 + i] = header.getRptCall2().GetChar(i);
for (unsigned int i = 0U; i < LONG_CALLSIGN_LENGTH; i++)
buffer[19 + i] = header.getYourCall().GetChar(i);
for (unsigned int i = 0U; i < LONG_CALLSIGN_LENGTH; i++)
buffer[27 + i] = header.getMyCall1().GetChar(i);
for (unsigned int i = 0U; i < SHORT_CALLSIGN_LENGTH; i++)
buffer[35 + i] = header.getMyCall2().GetChar(i);
// Get the checksum for the header
CCCITTChecksumReverse csum;
csum.update(buffer + 0, 4U * LONG_CALLSIGN_LENGTH + SHORT_CALLSIGN_LENGTH + 3U);
csum.result(buffer + 39);
return writeHeader(buffer, RADIO_HEADER_LENGTH_BYTES);
}
bool CDVTOOLFileWriter::writeHeader(const unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != 0);
wxASSERT(length > 0U);
wxUint16 len = wxUINT16_SWAP_ON_BE(length + 15U);
size_t n = m_file.Write(&len, sizeof(wxUint16));
if (n != sizeof(wxUint16)) {
m_file.Close();
return false;
}
n = m_file.Write(DSVT_SIGNATURE, DSVT_SIGNATURE_LENGTH);
if (n != DSVT_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
char byte = HEADER_FLAG;
n = m_file.Write(&byte, 1U);
if (n != 1U) {
m_file.Close();
return false;
}
n = m_file.Write(FIXED_DATA, FIXED_DATA_LENGTH);
if (n != FIXED_DATA_LENGTH) {
m_file.Close();
return false;
}
byte = HEADER_MASK;
n = m_file.Write(&byte, 1U);
if (n != 1U) {
m_file.Close();
return false;
}
n = m_file.Write(buffer, length);
if (n != length) {
m_file.Close();
return false;
}
m_count++;
return true;
}
bool CDVTOOLFileWriter::writeFrame(const unsigned char* buffer, unsigned int length)
{
wxASSERT(buffer != 0);
wxASSERT(length > 0U);
wxUint16 len = wxUINT16_SWAP_ON_BE(length + 15U);
size_t n = m_file.Write(&len, sizeof(wxUint16));
if (n != sizeof(wxUint16)) {
m_file.Close();
return false;
}
n = m_file.Write(DSVT_SIGNATURE, DSVT_SIGNATURE_LENGTH);
if (n != DSVT_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
char byte = DATA_FLAG;
n = m_file.Write(&byte, 1U);
if (n != 1U) {
m_file.Close();
return false;
}
n = m_file.Write(FIXED_DATA, FIXED_DATA_LENGTH);
if (n != FIXED_DATA_LENGTH) {
m_file.Close();
return false;
}
byte = m_sequence;
n = m_file.Write(&byte, 1U);
if (n != 1U) {
m_file.Close();
return false;
}
n = m_file.Write(buffer, length);
if (n != length) {
m_file.Close();
return false;
}
m_count++;
m_sequence++;
if (m_sequence >= 0x15U)
m_sequence = 0U;
return true;
}
void CDVTOOLFileWriter::close()
{
writeTrailer();
m_file.Seek(m_offset);
wxUint32 count = wxUINT32_SWAP_ON_LE(m_count);
m_file.Write(&count, sizeof(wxUint32));
m_file.Close();
}
bool CDVTOOLFileWriter::writeTrailer()
{
wxUint16 len = wxUINT16_SWAP_ON_BE(27U);
size_t n = m_file.Write(&len, sizeof(wxUint16));
if (n != sizeof(wxUint16)) {
m_file.Close();
return false;
}
n = m_file.Write(DSVT_SIGNATURE, DSVT_SIGNATURE_LENGTH);
if (n != DSVT_SIGNATURE_LENGTH) {
m_file.Close();
return false;
}
char byte = DATA_FLAG;
n = m_file.Write(&byte, 1U);
if (n != 1U) {
m_file.Close();
return false;
}
n = m_file.Write(FIXED_DATA, FIXED_DATA_LENGTH);
if (n != FIXED_DATA_LENGTH) {
m_file.Close();
return false;
}
byte = TRAILER_MASK | m_sequence;
n = m_file.Write(&byte, 1U);
if (n != 1U) {
m_file.Close();
return false;
}
n = m_file.Write(TRAILER_DATA, TRAILER_DATA_LENGTH);
if (n != TRAILER_DATA_LENGTH) {
m_file.Close();
return false;
}
return true;
}

@ -0,0 +1,50 @@
/*
* Copyright (C) 2009,2010,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DVTOOLFileWriter_H
#define DVTOOLFileWriter_H
#include "FileWriter.h"
#include <wx/wx.h>
#include <wx/ffile.h>
class CDVTOOLFileWriter : public IFileWriter {
public:
CDVTOOLFileWriter(const wxString& filename);
virtual ~CDVTOOLFileWriter();
virtual wxString getFilename();
virtual bool open();
virtual bool writeHeader(const CHeaderData& header);
virtual bool writeHeader(const unsigned char* buffer, unsigned int length);
virtual bool writeFrame(const unsigned char* buffer, unsigned int length);
virtual void close();
private:
wxString m_filename;
wxFFile m_file;
wxUint32 m_count;
unsigned int m_sequence;
wxFileOffset m_offset;
bool writeTrailer();
};
#endif

@ -0,0 +1,26 @@
/*
* Copyright (C) 2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef DecodeCallback_H
#define DecodeCallback_H
#include <wx/wx.h>
class IDecodeCallback {
public:
virtual void decodeCallback(const wxFloat32* audio, unsigned int length) = 0;
private:
};
#endif

@ -0,0 +1,189 @@
/*
* Copyright (C) 2010,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "SerialDataController.h"
#include "DongleSet.h"
const unsigned int BORDER_SIZE = 5U;
const unsigned int CONTROL_WIDTH = 150U;
const unsigned int ADDRESS_LENGTH = 15U;
const unsigned int PORT_LENGTH = 5U;
const int CHOICE_TYPE = 8750;
BEGIN_EVENT_TABLE(CDongleSet, wxPanel)
EVT_CHOICE(CHOICE_TYPE, CDongleSet::onType)
END_EVENT_TABLE()
CDongleSet::CDongleSet(wxWindow* parent, int id, const wxString& title, DONGLE_TYPE type, const wxString& device, const wxString& address, unsigned int port) :
wxPanel(parent, id),
m_title(title),
m_type(NULL),
m_device(NULL),
m_address(NULL),
m_port(NULL)
{
wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
wxStaticText* typeLabel = new wxStaticText(this, -1, _("Type"));
sizer->Add(typeLabel, 0, wxALL, BORDER_SIZE);
m_type = new wxChoice(this, CHOICE_TYPE, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_type->Append(wxT("DV-Dongle"));
m_type->Append(wxT("DV3000"));
sizer->Add(m_type, 0, wxALL, BORDER_SIZE);
m_type->SetSelection(int(type));
wxArrayString devices = CSerialDataController::getDevices();
wxStaticText* deviceLabel = new wxStaticText(this, -1, _("Device"));
sizer->Add(deviceLabel, 0, wxALL, BORDER_SIZE);
m_device = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1), devices);
m_device->Insert(_("<none>"), 0U);
sizer->Add(m_device, 0, wxALL, BORDER_SIZE);
if (devices.GetCount() == 0U) {
m_device->SetSelection(0);
} else {
bool res = m_device->SetStringSelection(device);
if (!res)
m_device->SetSelection(0);
}
wxStaticText* addressLabel = new wxStaticText(this, -1, _("Address"));
sizer->Add(addressLabel, 0, wxALL, BORDER_SIZE);
m_address = new CAddressTextCtrl(this, -1, address, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_address->SetMaxLength(ADDRESS_LENGTH);
sizer->Add(m_address, 0, wxALL, BORDER_SIZE);
wxStaticText* portLabel = new wxStaticText(this, -1, _("Port"));
sizer->Add(portLabel, 0, wxALL, BORDER_SIZE);
wxString text;
text.Printf(wxT("%u"), port);
m_port = new CPortTextCtrl(this, -1, text, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_port->SetMaxLength(PORT_LENGTH);
sizer->Add(m_port, 0, wxALL, BORDER_SIZE);
if (type == DT_DV3000) {
m_device->Disable();
} else {
m_address->Disable();
m_port->Disable();
}
SetAutoLayout(true);
//sizer->Fit(this);
//sizer->SetSizeHints(this);
SetSizer(sizer);
}
CDongleSet::~CDongleSet()
{
}
bool CDongleSet::Validate()
{
int n = m_type->GetSelection();
if (n == wxNOT_FOUND) {
wxMessageDialog dialog(this, _("The AMBE Dongle type is not set"), m_title + _(" Error"), wxICON_ERROR);
dialog.ShowModal();
return false;
}
if (n == 0) {
n = m_device->GetSelection();
if (n == wxNOT_FOUND) {
wxMessageDialog dialog(this, _("The AMBE Dongle device is not set"), m_title + _(" Error"), wxICON_ERROR);
dialog.ShowModal();
return false;
}
} else {
unsigned int port = getPort();
if (port == 0U || port > 65535U) {
wxMessageDialog dialog(this, _("The Dongle Port is not valid"), m_title + _(" Error"), wxICON_ERROR);
dialog.ShowModal();
return false;
}
}
return true;
}
DONGLE_TYPE CDongleSet::getType() const
{
int n = m_type->GetSelection();
if (n == wxNOT_FOUND)
return DT_DVDONGLE;
return DONGLE_TYPE(n);
}
wxString CDongleSet::getDevice() const
{
wxString device = m_device->GetStringSelection();
if (device.IsSameAs(_("<none>")))
return wxEmptyString;
else
return device;
}
wxString CDongleSet::getAddress() const
{
return m_address->GetValue();
}
unsigned int CDongleSet::getPort() const
{
unsigned long n;
m_port->GetValue().ToULong(&n);
return n;
}
void CDongleSet::onType(wxCommandEvent& event)
{
int n = event.GetSelection();
switch (n) {
default: // DV-Dongle
m_device->Enable();
m_address->Disable();
m_port->Disable();
break;
case 1: // DV3000
m_device->Disable();
m_address->Enable();
m_port->Enable();
break;
}
}

@ -0,0 +1,52 @@
/*
* Copyright (C) 2010,2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DongleSet_H
#define DongleSet_H
#include "AddressTextCtrl.h"
#include "PortTextCtrl.h"
#include "DStarDefines.h"
#include <wx/wx.h>
class CDongleSet : public wxPanel {
public:
CDongleSet(wxWindow* parent, int id, const wxString& title, DONGLE_TYPE type, const wxString& device, const wxString& address, unsigned int port);
virtual ~CDongleSet();
virtual bool Validate();
virtual DONGLE_TYPE getType() const;
virtual wxString getDevice() const;
virtual wxString getAddress() const;
virtual unsigned int getPort() const;
virtual void onType(wxCommandEvent& event);
private:
wxString m_title;
wxChoice* m_type;
wxChoice* m_device;
CAddressTextCtrl* m_address;
CPortTextCtrl* m_port;
DECLARE_EVENT_TABLE()
};
#endif

Binary file not shown.

@ -0,0 +1,146 @@
/*
* Copyright (C) 2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "DongleThread.h"
#include "DStarDefines.h"
#include "Bleeper.h"
// A 3 kHz low pass filter at a sample rate of 48000 samples/sec. Calculated by the fir1 command in
// MATLAB.
const wxFloat32 FIR_TAPS[] = {
0.001215122399171F, 0.001363519692447F, 0.001447384226195F, 0.001287712318712F, 0.000614680825630F,
-0.000833383976996F, -0.003176495118124F, -0.006261958697776F, -0.009578203328048F, -0.012249770207721F,
-0.013132705407240F, -0.011005254575316F, -0.004822958879920F, 0.006013373011413F, 0.021438048217733F,
0.040605942188804F, 0.061921094815680F, 0.083217403172960F, 0.102067175368858F, 0.116163746412471F,
0.123705527541065F, 0.123705527541065F, 0.116163746412471F, 0.102067175368858F, 0.083217403172960F,
0.061921094815680F, 0.040605942188804F, 0.021438048217733F, 0.006013373011413F, -0.004822958879920F,
-0.011005254575316F, -0.013132705407240F, -0.012249770207721F, -0.009578203328048F, -0.006261958697776F,
-0.003176495118124F, -0.000833383976996F, 0.000614680825630F, 0.001287712318712F, 0.001447384226195F,
0.001363519692447F, 0.001215122399171F};
const unsigned int FIR_LEN = 42U;
const wxFloat32 UPSAMPLE_AMP = 6.0F;
const wxFloat32 DOWNSAMPLE_AMP = 0.9F;
CDongleThread::CDongleThread() :
wxThread(wxTHREAD_JOINABLE),
m_encodeCallback(NULL),
m_decodeCallback(NULL),
m_encodeAudio(DSTAR_RADIO_BLOCK_SIZE * 30U),
m_decodeData(VOICE_FRAME_LENGTH_BYTES * 30U),
m_bleep(true),
m_killed(false),
m_filter(FIR_TAPS, FIR_LEN)
{
}
CDongleThread::~CDongleThread()
{
}
void CDongleThread::setEncodeCallback(IEncodeCallback* callback)
{
wxASSERT(callback != NULL);
m_encodeCallback = callback;
}
void CDongleThread::setDecodeCallback(IDecodeCallback* callback)
{
wxASSERT(callback != NULL);
m_decodeCallback = callback;
}
unsigned int CDongleThread::getEncodeSpace() const
{
return m_encodeAudio.freeSpace();
}
unsigned int CDongleThread::getDecodeSpace() const
{
return m_decodeData.freeSpace();
}
unsigned int CDongleThread::writeEncode(const wxFloat32* audio, unsigned int length)
{
wxASSERT(audio != NULL);
return m_encodeAudio.addData(audio, length);
}
unsigned int CDongleThread::writeDecode(const unsigned char* ambe, unsigned int length)
{
wxASSERT(ambe != NULL);
return m_decodeData.addData(ambe, length);
}
void CDongleThread::setBleep(bool on)
{
m_bleep = on;
}
void CDongleThread::kill()
{
m_killed = true;
Wait();
}
void CDongleThread::reset()
{
m_filter.reset();
}
void CDongleThread::sendBleep()
{
wxFloat32 audio[DSTAR_RADIO_BLOCK_SIZE];
unsigned int n;
CBleeper bleep(DSTAR_RADIO_SAMPLE_RATE, DSTAR_BLEEP_FREQ, DSTAR_BLEEP_LENGTH, DSTAR_BLEEP_AMPL);
while ((n = bleep.getAudio(audio, DSTAR_RADIO_BLOCK_SIZE)) > 0U)
m_decodeCallback->decodeCallback(audio, n);
}
// Convert from 8000 samples/sec to 48000 samples/sec
void CDongleThread::upSample(const wxFloat32* audioIn, wxFloat32* audioOut)
{
unsigned int out = 0U;
for (unsigned int in = 0U; in < DSTAR_AUDIO_BLOCK_SIZE; in++) {
audioOut[out++] = m_filter.process(audioIn[in]) * UPSAMPLE_AMP;
audioOut[out++] = m_filter.process(0.0F) * UPSAMPLE_AMP;
audioOut[out++] = m_filter.process(0.0F) * UPSAMPLE_AMP;
audioOut[out++] = m_filter.process(0.0F) * UPSAMPLE_AMP;
audioOut[out++] = m_filter.process(0.0F) * UPSAMPLE_AMP;
audioOut[out++] = m_filter.process(0.0F) * UPSAMPLE_AMP;
}
}
// Convert from 48000 samples/sec to 8000 samples/sec
void CDongleThread::downSample(const wxFloat32* audioIn, wxFloat32* audioOut)
{
unsigned int in = 0U;
for (unsigned int out = 0U; out < DSTAR_AUDIO_BLOCK_SIZE; out++) {
audioOut[out] = m_filter.process(audioIn[in++]) * DOWNSAMPLE_AMP;
m_filter.process(audioIn[in++]);
m_filter.process(audioIn[in++]);
m_filter.process(audioIn[in++]);
m_filter.process(audioIn[in++]);
m_filter.process(audioIn[in++]);
}
}

@ -0,0 +1,72 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef DongleThread_H
#define DongleThread_H
#include "EncodeCallback.h"
#include "DecodeCallback.h"
#include "RingBuffer.h"
#include "FIRFilter.h"
#include <wx/wx.h>
class CDongleThread : public wxThread {
public:
CDongleThread();
virtual ~CDongleThread();
virtual void setEncodeCallback(IEncodeCallback* callback);
virtual void setDecodeCallback(IDecodeCallback* callback);
virtual bool open() = 0;
virtual void setEncode() = 0;
virtual void setDecode() = 0;
virtual void setIdle() = 0;
virtual unsigned int getEncodeSpace() const;
virtual unsigned int getDecodeSpace() const;
virtual unsigned int writeEncode(const wxFloat32* audio, unsigned int length);
virtual unsigned int writeDecode(const unsigned char* ambe, unsigned int length);
virtual void setBleep(bool on);
virtual void kill();
protected:
IEncodeCallback* m_encodeCallback;
IDecodeCallback* m_decodeCallback;
CRingBuffer<wxFloat32> m_encodeAudio;
CRingBuffer<unsigned char> m_decodeData;
bool m_bleep;
bool m_killed;
void reset();
void upSample(const wxFloat32* audioIn, wxFloat32* audioOut);
void downSample(const wxFloat32* audioIn, wxFloat32* audioOut);
void sendBleep();
private:
CFIRFilter m_filter;
};
#endif

Binary file not shown.

@ -0,0 +1,26 @@
/*
* Copyright (C) 2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef EncodeCallback_H
#define EncodeCallback_H
#include <wx/wx.h>
class IEncodeCallback {
public:
virtual void encodeCallback(const unsigned char* ambe, unsigned int length) = 0;
private:
};
#endif

@ -0,0 +1,45 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ErrorEvent.h"
CErrorEvent::CErrorEvent(const wxString& text, wxEventType type, int id) :
wxEvent(id, type),
m_text(text)
{
}
CErrorEvent::CErrorEvent(const CErrorEvent& event) :
wxEvent(event),
m_text(event.m_text)
{
}
CErrorEvent::~CErrorEvent()
{
}
wxString CErrorEvent::getText() const
{
return m_text;
}
wxEvent* CErrorEvent::Clone() const
{
return new CErrorEvent(*this);
}

@ -0,0 +1,40 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef ErrorEvent_H
#define ErrorEvent_H
#include <wx/wx.h>
class CErrorEvent : public wxEvent {
public:
CErrorEvent(const wxString& text, wxEventType type, int id = 0);
virtual ~CErrorEvent();
virtual wxString getText() const;
virtual wxEvent* Clone() const;
protected:
CErrorEvent(const CErrorEvent& event);
private:
wxString m_text;
};
#endif

Binary file not shown.

@ -0,0 +1,109 @@
/*
* Copyright (C) 2001, 2002, 2003 by Tomi Manninen, OH2BNS
* Copyright (C) 2009 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "FIRFilter.h"
CFIRFilter::CFIRFilter(const wxFloat32* taps, unsigned int length) :
m_taps(NULL),
m_length(length),
m_buffer(NULL),
m_bufLen(20U * m_length),
m_pointer(length)
{
wxASSERT(taps != NULL);
wxASSERT(length > 0U);
m_taps = new wxFloat32[m_length];
m_buffer = new wxFloat32[m_bufLen];
::memcpy(m_taps, taps, m_length * sizeof(wxFloat32));
::memset(m_buffer, 0x00, m_bufLen * sizeof(wxFloat32));
}
CFIRFilter::CFIRFilter() :
m_taps(NULL),
m_length(0U),
m_buffer(NULL),
m_bufLen(0U),
m_pointer(0U)
{
}
CFIRFilter::~CFIRFilter()
{
delete[] m_taps;
delete[] m_buffer;
}
void CFIRFilter::setTaps(const wxFloat32* taps, unsigned int length)
{
wxASSERT(taps != NULL);
wxASSERT(length > 0U);
delete[] m_taps;
delete[] m_buffer;
m_length = length;
m_pointer = length;
m_bufLen = 20U * m_length;
m_taps = new wxFloat32[m_length];
m_buffer = new wxFloat32[m_bufLen];
::memcpy(m_taps, taps, m_length * sizeof(wxFloat32));
::memset(m_buffer, 0x00, m_bufLen * sizeof(wxFloat32));
}
wxFloat32 CFIRFilter::process(wxFloat32 val)
{
wxFloat32* ptr = m_buffer + m_pointer++;
*ptr = val;
wxFloat32* a = ptr - m_length;
wxFloat32* b = m_taps;
wxFloat32 out = 0.0F;
for (unsigned int i = 0U; i < m_length; i++)
out += (*a++) * (*b++);
if (m_pointer == m_bufLen) {
::memcpy(m_buffer, m_buffer + m_bufLen - m_length, m_length * sizeof(wxFloat32));
m_pointer = m_length;
}
return out;
}
void CFIRFilter::process(wxFloat32* inOut, unsigned int length)
{
wxASSERT(inOut != NULL);
for (unsigned int i = 0U; i < length; i++)
inOut[i] = process(inOut[i]);
}
void CFIRFilter::process(const wxFloat32* in, wxFloat32* out, unsigned int length)
{
wxASSERT(in != NULL);
wxASSERT(out != NULL);
for (unsigned int i = 0U; i < length; i++)
out[i] = process(in[i]);
}
void CFIRFilter::reset()
{
::memset(m_buffer, 0x00, m_bufLen * sizeof(wxFloat32));;
}

@ -0,0 +1,41 @@
/*
* Copyright (C) 2009,2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef FIRFilter_H
#define FIRFilter_H
#include <wx/wx.h>
class CFIRFilter {
public:
CFIRFilter(const wxFloat32* taps, unsigned int length);
CFIRFilter();
~CFIRFilter();
void setTaps(const wxFloat32* taps, unsigned int length);
wxFloat32 process(wxFloat32 val);
void process(wxFloat32* inOut, unsigned int length);
void process(const wxFloat32* in, wxFloat32* out, unsigned int length);
void reset();
private:
wxFloat32* m_taps;
unsigned int m_length;
wxFloat32* m_buffer;
unsigned int m_bufLen;
unsigned int m_pointer;
};
#endif

Binary file not shown.

@ -0,0 +1,18 @@
/*
* Copyright (C) 2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "FileReader.h"
IFileReader::~IFileReader()
{
}

@ -0,0 +1,41 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef FileReader_H
#define FileReader_H
enum DVTFR_TYPE {
DVTFR_HEADER,
DVTFR_DETAIL,
DVTFR_TRAILER
};
#include <wx/wx.h>
class IFileReader {
public:
virtual ~IFileReader() = 0;
virtual wxString getFileName() = 0;
virtual bool open(const wxString& fileName) = 0;
virtual unsigned int read(unsigned char* buffer, unsigned int length, DVTFR_TYPE& type) = 0;
virtual void close() = 0;
};
#endif

Binary file not shown.

@ -0,0 +1,18 @@
/*
* Copyright (C) 2014 by Jonathan Naylor, G4KLX
*
* 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
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "FileWriter.h"
IFileWriter::~IFileWriter()
{
}

@ -0,0 +1,39 @@
/*
* Copyright (C) 2014 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef FileWriter_H
#define FileWriter_H
#include "HeaderData.h"
#include <wx/wx.h>
class IFileWriter {
public:
virtual ~IFileWriter() = 0;
virtual wxString getFilename() = 0;
virtual bool open() = 0;
virtual bool writeHeader(const CHeaderData& header) = 0;
virtual bool writeHeader(const unsigned char* buffer, unsigned int length) = 0;
virtual bool writeFrame(const unsigned char* buffer, unsigned int length) = 0;
virtual void close() = 0;
};
#endif

Binary file not shown.

@ -0,0 +1,270 @@
/*
* Copyright (C) 2009,2012 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "CCITTChecksumReverse.h"
#include "HeaderData.h"
#include "DStarDefines.h"
CHeaderData::CHeaderData() :
m_time(),
m_myCall1(),
m_myCall2(),
m_yourCall(),
m_rptCall1(),
m_rptCall2(),
m_flag1(0x00),
m_flag2(0x00),
m_flag3(0x00),
m_valid(false)
{
}
CHeaderData::CHeaderData(const CHeaderData& header) :
m_time(header.m_time),
m_myCall1(header.m_myCall1),
m_myCall2(header.m_myCall2),
m_yourCall(header.m_yourCall),
m_rptCall1(header.m_rptCall1),
m_rptCall2(header.m_rptCall2),
m_flag1(header.m_flag1),
m_flag2(header.m_flag2),
m_flag3(header.m_flag3),
m_valid(header.m_valid)
{
}
CHeaderData::CHeaderData(const unsigned char* data, unsigned int length, bool check) :
m_time(),
m_myCall1(),
m_myCall2(),
m_yourCall(),
m_rptCall1(),
m_rptCall2(),
m_flag1(0x00),
m_flag2(0x00),
m_flag3(0x00),
m_valid(true)
{
wxASSERT(data != NULL);
wxASSERT(length >= (RADIO_HEADER_LENGTH_BYTES - 2U));
const unsigned char* p = data;
m_flag1 = *p++;
m_flag2 = *p++;
m_flag3 = *p++;
m_rptCall2 = wxString((const char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
p += LONG_CALLSIGN_LENGTH;
m_rptCall1 = wxString((const char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
p += LONG_CALLSIGN_LENGTH;
m_yourCall = wxString((const char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
p += LONG_CALLSIGN_LENGTH;
m_myCall1 = wxString((const char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
p += LONG_CALLSIGN_LENGTH;
m_myCall2 = wxString((const char*)p, wxConvLocal, SHORT_CALLSIGN_LENGTH);
m_time.SetToCurrent();
// We have a checksum, check it if asked
if (length >= RADIO_HEADER_LENGTH_BYTES && check) {
CCCITTChecksumReverse cksum;
cksum.update(data, RADIO_HEADER_LENGTH_BYTES - 2U);
m_valid = cksum.check(data + RADIO_HEADER_LENGTH_BYTES - 2U);
}
}
CHeaderData::CHeaderData(const wxString& myCall1, const wxString& myCall2, const wxString& yourCall,
const wxString& rptCall1, const wxString& rptCall2, unsigned char flag1,
unsigned char flag2, unsigned char flag3) :
m_time(),
m_myCall1(myCall1),
m_myCall2(myCall2),
m_yourCall(yourCall),
m_rptCall1(rptCall1),
m_rptCall2(rptCall2),
m_flag1(flag1),
m_flag2(flag2),
m_flag3(flag3),
m_valid(true)
{
m_time.SetToCurrent();
m_myCall1.Append(wxT(' '), LONG_CALLSIGN_LENGTH);
m_myCall2.Append(wxT(' '), SHORT_CALLSIGN_LENGTH);
m_yourCall.Append(wxT(' '), LONG_CALLSIGN_LENGTH);
m_rptCall1.Append(wxT(' '), LONG_CALLSIGN_LENGTH);
m_rptCall2.Append(wxT(' '), LONG_CALLSIGN_LENGTH);
m_myCall1.Truncate(LONG_CALLSIGN_LENGTH);
m_myCall2.Truncate(SHORT_CALLSIGN_LENGTH);
m_yourCall.Truncate(LONG_CALLSIGN_LENGTH);
m_rptCall1.Truncate(LONG_CALLSIGN_LENGTH);
m_rptCall2.Truncate(LONG_CALLSIGN_LENGTH);
}
CHeaderData::~CHeaderData()
{
}
wxDateTime CHeaderData::getTime() const
{
return m_time;
}
wxString CHeaderData::getMyCall1() const
{
return m_myCall1;
}
wxString CHeaderData::getMyCall2() const
{
return m_myCall2;
}
wxString CHeaderData::getYourCall() const
{
return m_yourCall;
}
wxString CHeaderData::getRptCall1() const
{
return m_rptCall1;
}
wxString CHeaderData::getRptCall2() const
{
return m_rptCall2;
}
unsigned char CHeaderData::getFlag1() const
{
return m_flag1;
}
unsigned char CHeaderData::getFlag2() const
{
return m_flag2;
}
unsigned char CHeaderData::getFlag3() const
{
return m_flag3;
}
void CHeaderData::setRepeaterMode(bool set)
{
if (set) {
m_flag1 |= REPEATER_MASK;
} else {
m_flag1 &= ~REPEATER_MASK;
m_rptCall1 = wxT("DIRECT ");
m_rptCall2 = wxT("DIRECT ");
}
}
bool CHeaderData::isRepeaterMode() const
{
return (m_flag1 & REPEATER_MASK) == REPEATER_MASK;
}
void CHeaderData::setDataPacket(bool set)
{
if (set)
m_flag1 |= DATA_MASK;
else
m_flag1 &= ~DATA_MASK;
}
bool CHeaderData::isDataPacket() const
{
return (m_flag1 & DATA_MASK) == DATA_MASK;
}
void CHeaderData::setInterrupted(bool set)
{
if (set)
m_flag1 |= INTERRUPTED_MASK;
else
m_flag1 &= ~INTERRUPTED_MASK;
}
bool CHeaderData::isInterrupted() const
{
return (m_flag1 & INTERRUPTED_MASK) == INTERRUPTED_MASK;
}
void CHeaderData::setControlSignal(bool set)
{
if (set)
m_flag1 |= CONTROL_SIGNAL_MASK;
else
m_flag1 &= ~CONTROL_SIGNAL_MASK;
}
bool CHeaderData::isControlSignal() const
{
return (m_flag1 & CONTROL_SIGNAL_MASK) == CONTROL_SIGNAL_MASK;
}
void CHeaderData::setUrgent(bool set)
{
if (set)
m_flag1 |= URGENT_MASK;
else
m_flag1 &= ~URGENT_MASK;
}
bool CHeaderData::isUrgent() const
{
return (m_flag1 & URGENT_MASK) == URGENT_MASK;
}
void CHeaderData::setRepeaterFlags(unsigned char set)
{
m_flag1 &= ~REPEATER_CONTROL_MASK;
m_flag1 |= set & REPEATER_CONTROL_MASK;
}
unsigned char CHeaderData::getRepeaterFlags() const
{
return m_flag1 & REPEATER_CONTROL_MASK;
}
bool CHeaderData::isValid() const
{
return m_valid;
}
void CHeaderData::reset()
{
m_myCall1 = wxT(" ");
m_myCall2 = wxT(" ");
m_yourCall = wxT("CQCQCQ ");
m_rptCall1 = wxT("DIRECT ");
m_rptCall2 = wxT("DIRECT ");
m_flag1 = 0x00;
m_flag2 = 0x00;
m_flag3 = 0x00;
}

@ -0,0 +1,76 @@
/*
* Copyright (C) 2009,2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef HeaderData_H
#define HeaderData_H
#include <wx/wx.h>
class CHeaderData {
public:
CHeaderData();
CHeaderData(const CHeaderData& header);
CHeaderData(const unsigned char* data, unsigned int length, bool check);
CHeaderData(const wxString& myCall1, const wxString& myCall2, const wxString& yourCall,
const wxString& rptCall1, const wxString& rptCall2, unsigned char flag1 = 0x00,
unsigned char flag2 = 0x00, unsigned char flag3 = 0x00);
~CHeaderData();
wxDateTime getTime() const;
wxString getMyCall1() const;
wxString getMyCall2() const;
wxString getYourCall() const;
wxString getRptCall1() const;
wxString getRptCall2() const;
unsigned char getFlag1() const;
unsigned char getFlag2() const;
unsigned char getFlag3() const;
bool isRepeaterMode() const;
bool isDataPacket() const;
bool isInterrupted() const;
bool isControlSignal() const;
bool isUrgent() const;
unsigned char getRepeaterFlags() const;
void setRepeaterMode(bool set);
void setDataPacket(bool set);
void setInterrupted(bool set);
void setControlSignal(bool set);
void setUrgent(bool set);
void setRepeaterFlags(unsigned char set);
bool isValid() const;
void reset();
private:
wxDateTime m_time;
wxString m_myCall1;
wxString m_myCall2;
wxString m_yourCall;
wxString m_rptCall1;
wxString m_rptCall2;
unsigned char m_flag1;
unsigned char m_flag2;
unsigned char m_flag3;
bool m_valid;
};
#endif

Binary file not shown.

@ -0,0 +1,45 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "HeaderEvent.h"
CHeaderEvent::CHeaderEvent(CHeaderData* header, wxEventType type, int id) :
wxEvent(id, type),
m_header(header)
{
}
CHeaderEvent::CHeaderEvent(const CHeaderEvent& event) :
wxEvent(event),
m_header(event.m_header)
{
}
CHeaderEvent::~CHeaderEvent()
{
}
CHeaderData* CHeaderEvent::getHeaderData() const
{
return m_header;
}
wxEvent* CHeaderEvent::Clone() const
{
return new CHeaderEvent(*this);
}

@ -0,0 +1,42 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef HeaderEvent_H
#define HeaderEvent_H
#include <wx/wx.h>
#include "HeaderData.h"
class CHeaderEvent : public wxEvent {
public:
CHeaderEvent(CHeaderData* header, wxEventType type, int id = 0);
virtual ~CHeaderEvent();
virtual CHeaderData* getHeaderData() const;
virtual wxEvent* Clone() const;
protected:
CHeaderEvent(const CHeaderEvent& event);
private:
CHeaderData* m_header;
};
#endif

Binary file not shown.

@ -0,0 +1,75 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Logger.h"
CLogger::CLogger(const wxString& fileName) :
wxLog(),
m_file(NULL)
{
m_file = new wxFFile;
m_file->Open(fileName, wxT("a+t"));
}
CLogger::~CLogger()
{
wxASSERT(m_file != NULL);
m_file->Close();
delete m_file;
}
void CLogger::DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp)
{
wxASSERT(m_file != NULL);
wxASSERT(m_file->IsOpened());
wxASSERT(msg != NULL);
wxString letter;
switch (level) {
case wxLOG_FatalError: letter = wxT("F"); break;
case wxLOG_Error: letter = wxT("E"); break;
case wxLOG_Warning: letter = wxT("W"); break;
case wxLOG_Info: letter = wxT("I"); break;
case wxLOG_Message: letter = wxT("M"); break;
case wxLOG_Status: letter = wxT("M"); break;
case wxLOG_Trace: letter = wxT("T"); break;
case wxLOG_Debug: letter = wxT("D"); break;
default: letter = wxT("U"); break;
}
wxDateTime dateTime(timestamp);
wxString timeText = dateTime.Format(wxT(": %Y-%m-%d %H:%M:%S: "));
wxString message = letter + timeText + msg + wxT("\n");
DoLogString(message.c_str(), timestamp);
if (level == wxLOG_FatalError)
::abort();
}
void CLogger::DoLogString(const wxChar* msg, time_t timestamp)
{
wxASSERT(m_file != NULL);
wxASSERT(m_file->IsOpened());
wxASSERT(msg != NULL);
m_file->Write(wxString(msg));
m_file->Flush();
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef Logger_H
#define Logger_H
#include <wx/wx.h>
#include <wx/ffile.h>
class CLogger : public wxLog {
public:
CLogger(const wxString& fileName);
virtual ~CLogger();
virtual void DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp);
virtual void DoLogString(const wxChar* msg, time_t timestamp);
private:
wxFFile* m_file;
};
#endif

Binary file not shown.

@ -0,0 +1,126 @@
all: Common.a
OBJS := AddressTextCtrl.o AMBE3000Thread.o AMBEFileReader.o AMBEFileWriter.o Bleeper.o BleepSet.o CallsignSet.o CallsignTextCtrl.o CCITTChecksumReverse.o \
DongleThread.o DV3000Controller.o DVDongleController.o DongleSet.o DVDongleThread.o DVTOOLFileReader.o DVTOOLFileWriter.o ErrorEvent.o FileReader.o \
FileWriter.o FIRFilter.o HeaderData.o HeaderEvent.o Logger.o MessageData.o MessageEvent.o MessageSet.o MessageTextCtrl.o PortTextCtrl.o RestrictedTextCtrl.o \
SerialDataController.o SlowDataDecoder.o SlowDataEncoder.o SoundCardReaderWriter.o SoundcardSet.o UDPReaderWriter.o Utils.o WAVFileReader.o WAVFileWriter.o
Common.a: $(OBJS)
ar rcs Common.a $(OBJS)
AddressTextCtrl.o: AddressTextCtrl.cpp AddressTextCtrl.h RestrictedTextCtrl.h
$(CC) $(CFLAGS) -c AddressTextCtrl.cpp
AMBE3000Thread.o: AMBE3000Thread.cpp AMBE3000Thread.h DongleThread.h DV3000Controller.h DStarDefines.h
$(CC) $(CFLAGS) -c AMBE3000Thread.cpp
AMBEFileReader.o: AMBEFileReader.cpp AMBEFileReader.h FileReader.h DStarDefines.h
$(CC) $(CFLAGS) -c AMBEFileReader.cpp
AMBEFileWriter.o: AMBEFileWriter.cpp AMBEFileWriter.h FileWriter.h DStarDefines.h
$(CC) $(CFLAGS) -c AMBEFileWriter.cpp
Bleeper.o: Bleeper.cpp Bleeper.h
$(CC) $(CFLAGS) -c Bleeper.cpp
BleepSet.o: BleepSet.cpp BleepSet.h
$(CC) $(CFLAGS) -c BleepSet.cpp
CallsignSet.o: CallsignSet.cpp CallsignSet.h CallsignTextCtrl.h DStarDefines.h
$(CC) $(CFLAGS) -c CallsignSet.cpp
CallsignTextCtrl.o: CallsignTextCtrl.cpp CallsignTextCtrl.h RestrictedTextCtrl.h
$(CC) $(CFLAGS) -c CallsignTextCtrl.cpp
CCITTChecksumReverse.o: CCITTChecksumReverse.cpp CCITTChecksumReverse.h Utils.h
$(CC) $(CFLAGS) -c CCITTChecksumReverse.cpp
DongleThread.o: DongleThread.cpp DongleThread.h EncodeCallback.h DecodeCallback.h FIRFilter.h Bleeper.h RingBuffer.h
$(CC) $(CFLAGS) -c DongleThread.cpp
DV3000Controller.o: DV3000Controller.cpp DV3000Controller.h DStarDefines.h UDPReaderWriter.h Utils.h
$(CC) $(CFLAGS) -c DV3000Controller.cpp
DongleSet.o: DongleSet.cpp DongleSet.h SerialDataController.h AddressTextCtrl.h PortTextCtrl.h
$(CC) $(CFLAGS) -c DongleSet.cpp
DVDongleController.o: DVDongleController.cpp DVDongleController.h DStarDefines.h SerialDataController.h
$(CC) $(CFLAGS) -c DVDongleController.cpp
DVDongleThread.o: DVDongleThread.cpp DVDongleThread.h DongleThread.h DVDongleController.h DStarDefines.h
$(CC) $(CFLAGS) -c DVDongleThread.cpp
DVTOOLFileReader.o: DVTOOLFileReader.cpp DVTOOLFileReader.h FileReader.h
$(CC) $(CFLAGS) -c DVTOOLFileReader.cpp
DVTOOLFileWriter.o: DVTOOLFileWriter.cpp DVTOOLFileWriter.h FileWriter.h CCITTChecksumReverse.h DStarDefines.h
$(CC) $(CFLAGS) -c DVTOOLFileWriter.cpp
ErrorEvent.o: ErrorEvent.cpp ErrorEvent.h
$(CC) $(CFLAGS) -c ErrorEvent.cpp
FileReader.o: FileReader.cpp FileReader.h
$(CC) $(CFLAGS) -c FileReader.cpp
FileWriter.o: FileWriter.cpp FileWriter.h HeaderData.h
$(CC) $(CFLAGS) -c FileWriter.cpp
FIRFilter.o: FIRFilter.cpp FIRFilter.h
$(CC) $(CFLAGS) -c FIRFilter.cpp
HeaderData.o: HeaderData.cpp HeaderData.h DStarDefines.h CCITTChecksumReverse.h
$(CC) $(CFLAGS) -c HeaderData.cpp
HeaderEvent.o: HeaderEvent.cpp HeaderEvent.h HeaderData.h
$(CC) $(CFLAGS) -c HeaderEvent.cpp
Logger.o: Logger.cpp Logger.h
$(CC) $(CFLAGS) -c Logger.cpp
MessageData.o: MessageData.cpp MessageData.h
$(CC) $(CFLAGS) -c MessageData.cpp
MessageEvent.o: MessageEvent.cpp MessageEvent.h MessageData.h
$(CC) $(CFLAGS) -c MessageEvent.cpp
MessageSet.o: MessageSet.cpp MessageSet.h MessageTextCtrl.h
$(CC) $(CFLAGS) -c MessageSet.cpp
MessageTextCtrl.o: MessageTextCtrl.cpp MessageTextCtrl.h RestrictedTextCtrl.h
$(CC) $(CFLAGS) -c MessageTextCtrl.cpp
PortTextCtrl.o: PortTextCtrl.cpp PortTextCtrl.h RestrictedTextCtrl.h
$(CC) $(CFLAGS) -c PortTextCtrl.cpp
RestrictedTextCtrl.o: RestrictedTextCtrl.cpp RestrictedTextCtrl.h
$(CC) $(CFLAGS) -c RestrictedTextCtrl.cpp
SerialDataController.o: SerialDataController.cpp SerialDataController.h
$(CC) $(CFLAGS) -c SerialDataController.cpp
SlowDataDecoder.o: SlowDataDecoder.cpp SlowDataDecoder.h DStarDefines.h MessageData.h HeaderData.h
$(CC) $(CFLAGS) -c SlowDataDecoder.cpp
SlowDataEncoder.o: SlowDataEncoder.cpp SlowDataEncoder.h DStarDefines.h CCITTChecksumReverse.h MessageData.h HeaderData.h
$(CC) $(CFLAGS) -c SlowDataEncoder.cpp
SoundCardReaderWriter.o: SoundCardReaderWriter.cpp SoundCardReaderWriter.h AudioCallback.h
$(CC) $(CFLAGS) -c SoundCardReaderWriter.cpp
SoundcardSet.o: SoundcardSet.cpp SoundcardSet.h SoundCardReaderWriter.h
$(CC) $(CFLAGS) -c SoundcardSet.cpp
UDPReaderWriter.o: UDPReaderWriter.cpp UDPReaderWriter.h Utils.h
$(CC) $(CFLAGS) -c UDPReaderWriter.cpp
Utils.o: Utils.cpp Utils.h
$(CC) $(CFLAGS) -c Utils.cpp
WAVFileReader.o: WAVFileReader.cpp WAVFileReader.h
$(CC) $(CFLAGS) -c WAVFileReader.cpp
WAVFileWriter.o: WAVFileWriter.cpp WAVFileWriter.h
$(CC) $(CFLAGS) -c WAVFileWriter.cpp
clean:
rm -f core Common.a *.o *~ *.bak

@ -0,0 +1,47 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "MessageData.h"
CMessageData::CMessageData(const CMessageData& message) :
m_msgText(message.m_msgText)
{
}
CMessageData::CMessageData(const unsigned char* msgText, unsigned int length) :
m_msgText()
{
wxASSERT(msgText != NULL);
wxASSERT(length > 0U);
m_msgText = wxString((const char*)msgText, wxConvLocal, length);
}
CMessageData::CMessageData(const wxString& msgText) :
m_msgText(msgText)
{
}
CMessageData::~CMessageData()
{
}
wxString CMessageData::getMsgText() const
{
return m_msgText;
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2009,2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MessageData_H
#define MessageData_H
#include <wx/wx.h>
class CMessageData {
public:
CMessageData(const CMessageData& message);
CMessageData(const unsigned char* msgText, unsigned int length);
CMessageData(const wxString& msgText);
~CMessageData();
wxString getMsgText() const;
private:
wxString m_msgText;
};
#endif

Binary file not shown.

@ -0,0 +1,45 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "MessageEvent.h"
CMessageEvent::CMessageEvent(CMessageData* message, wxEventType type, int id) :
wxEvent(id, type),
m_message(message)
{
}
CMessageEvent::CMessageEvent(const CMessageEvent& event) :
wxEvent(event),
m_message(event.m_message)
{
}
CMessageEvent::~CMessageEvent()
{
}
CMessageData* CMessageEvent::getMessageData() const
{
return m_message;
}
wxEvent* CMessageEvent::Clone() const
{
return new CMessageEvent(*this);
}

@ -0,0 +1,42 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MessageEvent_H
#define MessageEvent_H
#include <wx/wx.h>
#include "MessageData.h"
class CMessageEvent : public wxEvent {
public:
CMessageEvent(CMessageData* message, wxEventType type, int id = 0);
virtual ~CMessageEvent();
virtual CMessageData* getMessageData() const;
virtual wxEvent* Clone() const;
protected:
CMessageEvent(const CMessageEvent& event);
private:
CMessageData* m_message;
};
#endif

Binary file not shown.

@ -0,0 +1,56 @@
/*
* Copyright (C) 2009,2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "MessageSet.h"
const unsigned int MAX_MESSAGE_LENGTH = 20U;
const unsigned int CONTROL_SIZE = 200U;
const unsigned int BORDER_SIZE = 5U;
CMessageSet::CMessageSet(wxWindow* parent, int id, const wxString& title, const wxString& message) :
wxPanel(parent, id),
m_title(title),
m_message(NULL)
{
wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
wxStaticText* messageText = new wxStaticText(this, -1, _("Message"));
sizer->Add(messageText, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_message = new CMessageTextCtrl(this, -1, message, wxDefaultPosition, wxSize(CONTROL_SIZE, -1));
m_message->SetMaxLength(MAX_MESSAGE_LENGTH);
sizer->Add(m_message, 0, wxALL, BORDER_SIZE);
SetAutoLayout(true);
sizer->Fit(this);
sizer->SetSizeHints(this);
SetSizer(sizer);
}
CMessageSet::~CMessageSet()
{
}
wxString CMessageSet::getMessage() const
{
return m_message->GetValue();
}

@ -0,0 +1,38 @@
/*
* Copyright (C) 2009,2010 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MessageSet_H
#define MessageSet_H
#include "MessageTextCtrl.h"
#include <wx/wx.h>
class CMessageSet : public wxPanel {
public:
CMessageSet(wxWindow* parent, int id, const wxString& title, const wxString& message);
virtual ~CMessageSet();
virtual wxString getMessage() const;
private:
wxString m_title;
CMessageTextCtrl* m_message;
};
#endif

Binary file not shown.

@ -0,0 +1,29 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "MessageTextCtrl.h"
CMessageTextCtrl::CMessageTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos, const wxSize& size, long style) :
CRestrictedTextCtrl(parent, id, value, pos, size, style, MSG_CHARS)
{
}
CMessageTextCtrl::~CMessageTextCtrl()
{
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MessageTextCtrl_H
#define MessageTextCtrl_H
#include <wx/wx.h>
#include "RestrictedTextCtrl.h"
const wxString MSG_CHARS = wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ");
class CMessageTextCtrl : public CRestrictedTextCtrl {
public:
CMessageTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0L);
virtual ~CMessageTextCtrl();
private:
};
#endif

@ -0,0 +1,29 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "PortTextCtrl.h"
CPortTextCtrl::CPortTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos, const wxSize& size, long style) :
CRestrictedTextCtrl(parent, id, value, pos, size, style, PORT_CHARS)
{
}
CPortTextCtrl::~CPortTextCtrl()
{
}

@ -0,0 +1,37 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PortTextCtrl_H
#define PortTextCtrl_H
#include <wx/wx.h>
#include "RestrictedTextCtrl.h"
const wxString PORT_CHARS = wxT("0123456789");
class CPortTextCtrl : public CRestrictedTextCtrl {
public:
CPortTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0L);
virtual ~CPortTextCtrl();
private:
};
#endif

Binary file not shown.

@ -0,0 +1,40 @@
/*
* Copyright (C) 2002,2003,2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "RestrictedTextCtrl.h"
CRestrictedTextCtrl::CRestrictedTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxString& wantedChars) :
wxTextCtrl()
{
wxASSERT(parent != NULL);
wxArrayString charList;
for (unsigned int i = 0; i < wantedChars.Length(); i++)
charList.Add(wantedChars.Mid(i, 1));
wxTextValidator validator(wxFILTER_INCLUDE_CHAR_LIST);
validator.SetIncludes(charList);
Create(parent, id, value, pos, size, style, validator);
}
CRestrictedTextCtrl::~CRestrictedTextCtrl()
{
}

@ -0,0 +1,32 @@
/*
* Copyright (C) 2002,2003 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef RestrictedTextCtrl_H
#define RestrictedTextCtrl_H
#include <wx/wx.h>
class CRestrictedTextCtrl : public wxTextCtrl {
public:
CRestrictedTextCtrl(wxWindow* parent, int id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxString& wantedChars);
virtual ~CRestrictedTextCtrl();
private:
};
#endif

@ -0,0 +1,148 @@
/*
* Copyright (C) 2006-2009 by Jonathan Naylor G4KLX
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef RingBuffer_H
#define RingBuffer_H
#include <wx/wx.h>
enum RBSTATE {
RBSTATE_EMPTY,
RBSTATE_FULL,
RBSTATE_DATA
};
template<class T> class CRingBuffer {
public:
CRingBuffer(unsigned int length) :
m_length(length),
m_buffer(NULL),
m_iPtr(0U),
m_oPtr(0U),
m_state(RBSTATE_EMPTY)
{
wxASSERT(length > 0U);
m_buffer = new T[length];
::memset(m_buffer, 0x00, length * sizeof(T));
}
~CRingBuffer()
{
delete[] m_buffer;
}
unsigned int addData(const T* buffer, unsigned int nSamples)
{
unsigned int space = freeSpace();
if (nSamples >= space) {
nSamples = space;
m_state = RBSTATE_FULL;
} else {
m_state = RBSTATE_DATA;
}
for (unsigned int i = 0U; i < nSamples; i++) {
m_buffer[m_iPtr++] = buffer[i];
if (m_iPtr == m_length)
m_iPtr = 0U;
}
return nSamples;
}
unsigned int getData(T* buffer, unsigned int nSamples)
{
unsigned int space = dataSpace();
if (nSamples >= space) {
nSamples = space;
m_state = RBSTATE_EMPTY;
} else {
m_state = RBSTATE_DATA;
}
for (unsigned int i = 0U; i < nSamples; i++) {
buffer[i] = m_buffer[m_oPtr++];
if (m_oPtr == m_length)
m_oPtr = 0U;
}
return nSamples;
}
void clear()
{
m_iPtr = 0U;
m_oPtr = 0U;
m_state = RBSTATE_EMPTY;
::memset(m_buffer, 0x00, m_length * sizeof(T));
}
unsigned int freeSpace() const
{
if (isEmpty())
return m_length;
if (isFull())
return 0U;
if (m_oPtr > m_iPtr)
return m_oPtr - m_iPtr;
return m_length - (m_iPtr - m_oPtr);
}
unsigned int dataSpace() const
{
if (isEmpty())
return 0U;
if (isFull())
return m_length;
if (m_iPtr >= m_oPtr)
return m_iPtr - m_oPtr;
return m_length - (m_oPtr - m_iPtr);
}
bool isEmpty() const
{
return m_state == RBSTATE_EMPTY;
}
bool isFull() const
{
return m_state == RBSTATE_FULL;
}
private:
unsigned int m_length;
T* m_buffer;
unsigned int m_iPtr;
unsigned int m_oPtr;
RBSTATE m_state;
};
#endif

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.