mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2025-12-06 03:01:59 +01:00
Switch to FTD2XX library for serial communication to ThumbDV
This commit is contained in:
parent
f5891bc89d
commit
c5bd30c090
|
|
@ -14,7 +14,7 @@
|
|||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816" name="ThumbDV_Release" parent="cdt.managedbuild.config.gnu.exe.release" postbuildStep="">
|
||||
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816" name="ThumbDV_Release" parent="cdt.managedbuild.config.gnu.exe.release" postbuildStep="cp thumbdv /nfsroots/microburst/home/root">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.2071852954" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1507208472" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
|
||||
|
|
@ -25,11 +25,12 @@
|
|||
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.659391275" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1471059699" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1305639214" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
|
||||
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1305639214" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.647544514" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.exe.release.option.debugging.level.1653886956" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1892851487" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/ThumbDV}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/SmartSDR_Interface}""/>
|
||||
</option>
|
||||
|
|
@ -39,19 +40,23 @@
|
|||
<option id="gnu.c.compiler.option.dialect.std.1831515322" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1381777350" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-gnueabi-gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.539834230" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
|
||||
<tool command="arm-angstrom-linux-gnueabi-gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.539834230" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
|
||||
<option id="gnu.c.link.option.paths.593721395" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""../../Firmware/lib""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.libs.1868504239" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="ftd2xx"/>
|
||||
<listOptionValue builtIn="false" value="rt"/>
|
||||
<listOptionValue builtIn="false" value="pthread"/>
|
||||
<listOptionValue builtIn="false" value="dl"/>
|
||||
<listOptionValue builtIn="false" value="m"/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.other.890688482" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-Map=Firmware.map"/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.ldflags.827896357" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="" valueType="string"/>
|
||||
<option id="gnu.c.link.option.noshared.504312789" name="No shared libraries (-static)" superClass="gnu.c.link.option.noshared" value="false" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1207451390" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
|
|
@ -69,7 +74,7 @@
|
|||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool command="arm-linux-gnueabi-as" id="cdt.managedbuild.tool.gnu.assembler.exe.release.825234294" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
|
||||
<tool command="arm-angstrom-linux-gnueabi-as" id="cdt.managedbuild.tool.gnu.assembler.exe.release.825234294" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1550773879" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
|
|
@ -91,7 +96,7 @@
|
|||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819" name="ThumbDV_Debug" parent="cdt.managedbuild.config.gnu.exe.debug" postbuildStep="" prebuildStep="">
|
||||
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819" name="ThumbDV_Debug" parent="cdt.managedbuild.config.gnu.exe.debug" postbuildStep="cp thumbdv /nfsroots/microburst/home/root/" prebuildStep="">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.537899118" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.192715654" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
|
||||
|
|
@ -106,11 +111,12 @@
|
|||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1562312530" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.2095437572" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.2095437572" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.686601172" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" value="gnu.c.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.exe.debug.option.debugging.level.50794825" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1981926866" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/ThumbDV}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/SmartSDR_Interface}""/>
|
||||
</option>
|
||||
|
|
@ -126,15 +132,18 @@
|
|||
<option id="gnu.c.compiler.option.dialect.std.224213537" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.252305069" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} " id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.2144927630" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
|
||||
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} " id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.2144927630" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
|
||||
<option id="gnu.c.link.option.ldflags.1025040973" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="-rdynamic" valueType="string"/>
|
||||
<option id="gnu.c.link.option.libs.2079493028" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="rt"/>
|
||||
<listOptionValue builtIn="false" value="dl"/>
|
||||
<listOptionValue builtIn="false" value="pthread"/>
|
||||
<listOptionValue builtIn="false" value="m"/>
|
||||
<listOptionValue builtIn="false" value="ftd2xx"/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.paths.971526928" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""../../Firmware/lib""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.shared.2014214536" name="Shared (-shared)" superClass="gnu.c.link.option.shared" value="false" valueType="boolean"/>
|
||||
<option id="gnu.c.link.option.other.1419802631" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
|
||||
|
|
@ -144,6 +153,7 @@
|
|||
<option id="gnu.c.link.option.debugging.gprof.1336488789" name="Generate gprof information (-pg)" superClass="gnu.c.link.option.debugging.gprof" value="false" valueType="boolean"/>
|
||||
<option id="gnu.c.link.option.userobjs.723775110" name="Other objects" superClass="gnu.c.link.option.userobjs"/>
|
||||
<option id="gnu.c.link.option.soname.1263316050" name="Shared object name (-Wl,-soname=)" superClass="gnu.c.link.option.soname" value="" valueType="string"/>
|
||||
<option id="gnu.c.link.option.noshared.164821868" name="No shared libraries (-static)" superClass="gnu.c.link.option.noshared" value="false" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.966428107" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
|
|
@ -161,7 +171,7 @@
|
|||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool command="arm-linux-gnueabi-as" id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1079285663" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
|
||||
<tool command="arm-angstrom-linux-gnueabi-as" id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1079285663" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.906031255" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
#include <errno.h> // for errno
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "discovery_client.h"
|
||||
#include "cmd.h" // for tokenize
|
||||
|
|
@ -253,6 +255,7 @@ static BOOL _dc_ListenerRecv(uint8* buffer, int32* len, struct sockaddr_in* send
|
|||
static void* _dc_ListenerLoop(void* param)
|
||||
{
|
||||
//printf("_dc_ListenerLoop\n");
|
||||
prctl(PR_SET_NAME, "DV-ListenerLoop");
|
||||
|
||||
struct sockaddr_in sender;
|
||||
uint8 buf[ETH_FRAME_LEN];
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include <errno.h> // for errno
|
||||
#include <unistd.h> // for usleep
|
||||
#include <netdb.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
// #define LOG_MODULE LOG_MODULE_HAL_LISTENER
|
||||
|
||||
|
|
@ -430,6 +431,7 @@ static void* _hal_ListenerLoop(void* param)
|
|||
|
||||
struct sockaddr_in sender;
|
||||
uint8 buf[ETH_FRAME_LEN];
|
||||
prctl(PR_SET_NAME, "DV-halListener");
|
||||
|
||||
while(!hal_listen_abort)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "datatypes.h"
|
||||
|
|
@ -51,6 +52,7 @@
|
|||
#include "dstar.h"
|
||||
#include "DStarDefines.h"
|
||||
#include "slow_data.h"
|
||||
#include "ftd2xx.h"
|
||||
|
||||
//static Queue sched_fft_queue;
|
||||
static pthread_rwlock_t _list_lock;
|
||||
|
|
@ -185,7 +187,7 @@ Circular_Short_Buffer TX3_cb = &tx3_cb;
|
|||
circular_float_buffer tx4_cb;
|
||||
Circular_Float_Buffer TX4_cb = &tx4_cb;
|
||||
|
||||
static int _dv_serial_fd = 0;
|
||||
static FT_HANDLE _dv_serial_handle = 0;
|
||||
|
||||
static GMSK_DEMOD _gmsk_demod = NULL;
|
||||
static GMSK_MOD _gmsk_mod = NULL;
|
||||
|
|
@ -353,8 +355,8 @@ void sched_waveform_setMessage( uint32 slice, const char * message)
|
|||
output( "TX Message: '%s' : strlen() = %d \n", _dstar->slow_encoder->message , strlen(_dstar->slow_encoder->message));
|
||||
}
|
||||
|
||||
void sched_waveform_setFD( int fd ) {
|
||||
_dv_serial_fd = fd;
|
||||
void sched_waveform_setHandle( FT_HANDLE * handle ) {
|
||||
_dv_serial_handle = *handle;
|
||||
}
|
||||
|
||||
void sched_waveform_setEndOfTX( BOOL end_of_transmission ) {
|
||||
|
|
@ -369,6 +371,8 @@ void sched_waveform_setDSTARSlice( uint32 slice )
|
|||
}
|
||||
|
||||
static void * _sched_waveform_thread( void * param ) {
|
||||
|
||||
prctl(PR_SET_NAME, "DV-SchedWav");
|
||||
int nout;
|
||||
|
||||
int i; // for loop counter
|
||||
|
|
@ -405,7 +409,7 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
|
||||
// ======================= Initialization Section =========================
|
||||
|
||||
thumbDV_init( &_dv_serial_fd );
|
||||
thumbDV_init( &_dv_serial_handle );
|
||||
|
||||
// Initialize the Circular Buffers
|
||||
|
||||
|
|
@ -516,7 +520,7 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
|
||||
if ( ambe_packet_out == TRUE ) {
|
||||
nout = 0;
|
||||
nout = thumbDV_decode( _dv_serial_fd, ambe_out, speech_out, DV_PACKET_SAMPLES );
|
||||
nout = thumbDV_decode( _dv_serial_handle, ambe_out, speech_out, DV_PACKET_SAMPLES );
|
||||
uint32 j = 0;
|
||||
|
||||
for ( j = 0 ; j < nout ; j++ )
|
||||
|
|
@ -632,7 +636,7 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
}
|
||||
|
||||
/* DECODE */
|
||||
decode_out = thumbDV_encode( _dv_serial_fd, speech_in, mod_out, DV_PACKET_SAMPLES );
|
||||
decode_out = thumbDV_encode( _dv_serial_handle, speech_in, mod_out, DV_PACKET_SAMPLES );
|
||||
}
|
||||
|
||||
if ( initial_tx ) {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#define SCHED_WAVEFORM_H_
|
||||
|
||||
#include "hal_buffer.h"
|
||||
#include "ftd2xx.h"
|
||||
|
||||
void sched_waveform_Schedule(BufferDescriptor buf);
|
||||
void sched_waveform_Init(void);
|
||||
|
|
@ -49,7 +50,7 @@ void sched_waveform_setOwnCall2(uint32 slice , const char * owncall2 );
|
|||
void sched_waveform_setMessage( uint32 slice, const char * message);
|
||||
|
||||
void sched_waveform_sendStatus(uint32 slice);
|
||||
void sched_waveform_setFD(int fd);
|
||||
void sched_waveform_setHandle( FT_HANDLE * handle );
|
||||
void sched_waveform_setEndOfTX(BOOL end_of_transmission);
|
||||
void sched_waveform_setDSTARSlice( uint32 slice );
|
||||
#endif /* SCHED_WAVEFORM_H_ */
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <fcntl.h> // File Control functions
|
||||
|
||||
#include "common.h"
|
||||
|
|
@ -92,6 +93,7 @@ void SmartSDR_API_Shutdown(void)
|
|||
|
||||
void* _console_thread(void* param)
|
||||
{
|
||||
prctl(PR_SET_NAME, "DV-Console");
|
||||
cmd_banner();
|
||||
output(PROMPT);
|
||||
// let everybody know we're through printing
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "traffic_cop.h"
|
||||
|
|
@ -343,6 +344,8 @@ static void* _tc_thread(void* arg)
|
|||
{
|
||||
uint32 result;
|
||||
|
||||
prctl(PR_SET_NAME, "DV-TrafficCop");
|
||||
|
||||
memset(&__local, 0, sizeof(receive_data));
|
||||
__local.last_ping.tv_sec = 0;
|
||||
__local.recv_buf = safe_malloc(RECV_BUF_SIZE);
|
||||
|
|
@ -575,6 +578,8 @@ static void* _keepalive_thread(void* param)
|
|||
{
|
||||
char* response;
|
||||
|
||||
prctl(PR_SET_NAME, "DV-KeepAlive");
|
||||
|
||||
/* Sleep 2 seconds */
|
||||
usleep(2000000);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,13 @@
|
|||
#include <termios.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
|
@ -56,10 +58,7 @@
|
|||
#include "vita_output.h"
|
||||
#include "thumbDV.h"
|
||||
#include "sched_waveform.h"
|
||||
|
||||
|
||||
#define DV3000_TTY "/dev/ttyAMA0"
|
||||
#define DV3000_VERSION "2014-04-23"
|
||||
#include "ftd2xx.h"
|
||||
|
||||
#define AMBE3000_HEADER_LEN 4U
|
||||
#define AMBE3000_START_BYTE 0x61U
|
||||
|
|
@ -278,104 +277,82 @@ void thumbDV_dump( char * text, unsigned char * data, unsigned int length ) {
|
|||
}
|
||||
}
|
||||
|
||||
static void thumbDV_writeSerial( int serial_fd, const unsigned char * buffer, uint32 bytes ) {
|
||||
fd_set fds;
|
||||
static void thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint32 bytes )
|
||||
{
|
||||
FT_STATUS status = FT_OK;
|
||||
DWORD written = 0;
|
||||
|
||||
FD_ZERO( &fds );
|
||||
FD_SET( serial_fd, &fds );
|
||||
if ( handle != NULL )
|
||||
{
|
||||
status = FT_Write(handle, buffer, bytes, &written);
|
||||
|
||||
int32 n = 0;
|
||||
errno = 0;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
select( serial_fd + 1, NULL, &fds, NULL, &timeout );
|
||||
|
||||
if ( FD_ISSET( serial_fd, &fds ) ) {
|
||||
n = write( serial_fd , buffer, bytes );
|
||||
|
||||
if ( n != bytes ) {
|
||||
if ( status != FT_OK || written != bytes ) {
|
||||
output( ANSI_RED "Could not write to serial port. errno = %d\n", errno );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
output( ANSI_RED "Could not write to serial port. Timeout\n" ANSI_WHITE );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int _check_serial( int fd ) {
|
||||
static int _check_serial( FT_HANDLE handle )
|
||||
{
|
||||
|
||||
unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 };
|
||||
thumbDV_writeSerial( fd, reset, 5 );
|
||||
thumbDV_writeSerial( handle, reset, 5 );
|
||||
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
int ret = thumbDV_processSerial(handle);
|
||||
|
||||
FD_ZERO( &fds );
|
||||
FD_SET( fd, &fds );
|
||||
errno = 0;
|
||||
timeout.tv_sec = 2;
|
||||
timeout.tv_usec = 0;
|
||||
select( fd + 1, &fds, NULL, NULL, &timeout );
|
||||
|
||||
if ( FD_ISSET( fd, &fds ) ) {
|
||||
int ret = thumbDV_processSerial( fd );
|
||||
|
||||
if ( ret != 0 ) {
|
||||
output( "Could not reset serial port FD = %d \n", fd );
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
output( "Could not reset serial port FD = %d \n", fd );
|
||||
if ( ret != 0 )
|
||||
{
|
||||
output( "Could not reset serial port FD = %d \n", handle );
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned char get_prodID[5] = {0x61, 0x00, 0x01, 0x00, 0x30 };
|
||||
thumbDV_writeSerial( fd, get_prodID, 5 );
|
||||
thumbDV_writeSerial( handle, get_prodID, 5 );
|
||||
|
||||
FD_ZERO( &fds );
|
||||
FD_SET( fd, &fds );
|
||||
errno = 0;
|
||||
timeout.tv_sec = 2;
|
||||
timeout.tv_usec = 0;
|
||||
select( fd + 1, &fds, NULL, NULL, &timeout );
|
||||
ret = thumbDV_processSerial(handle);
|
||||
|
||||
if ( FD_ISSET( fd, &fds ) ) {
|
||||
int ret = thumbDV_processSerial( fd );
|
||||
|
||||
if ( ret != 0 ) {
|
||||
output( "Could not get prodID serial port FD = %d \n", fd );
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
output( "Could not prodID serial port FD = %d \n", fd );
|
||||
if ( ret != 0 )
|
||||
{
|
||||
output( "Could not reset serial port FD = %d \n", handle );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int thumbDV_openSerial( const char * tty_name ) {
|
||||
struct termios tty;
|
||||
int fd;
|
||||
FT_HANDLE thumbDV_openSerial( FT_DEVICE_LIST_INFO_NODE device )
|
||||
{
|
||||
//struct termios tty;
|
||||
FT_HANDLE handle = NULL;
|
||||
FT_STATUS status = FT_OK;
|
||||
|
||||
/* TODO: Sanitize tty_name */
|
||||
output("Trying to open serial port %s", device.SerialNumber);
|
||||
|
||||
fd = open( tty_name, O_RDWR | O_NOCTTY | O_SYNC );
|
||||
status = FT_OpenEx(device.SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &handle);
|
||||
|
||||
if ( fd < 0 ) {
|
||||
output( "ThumbDV: error when opening %s, errno=%d\n", tty_name, errno );
|
||||
return fd;
|
||||
if ( status != FT_OK || handle == NULL )
|
||||
{
|
||||
if ( device.SerialNumber )
|
||||
output("Error opening device %s - error 0x%X\n", device.SerialNumber, status);
|
||||
else
|
||||
output("Error opening device - error 0x%X\n", status);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( tcgetattr( fd, &tty ) != 0 ) {
|
||||
output( "ThumbDV: error %d from tcgetattr\n", errno );
|
||||
return -1;
|
||||
}
|
||||
FT_SetBaudRate(handle, FT_BAUD_460800);
|
||||
|
||||
cfsetospeed( &tty, B460800 );
|
||||
cfsetispeed( &tty, B460800 );
|
||||
// Set read and write timeout to 2seconds */
|
||||
FT_SetTimeouts(handle, 2000, 2000);
|
||||
|
||||
/*
|
||||
tty.c_cflag = ( tty.c_cflag & ~CSIZE ) | CS8;
|
||||
tty.c_iflag &= ~IGNBRK;
|
||||
tty.c_lflag = 0;
|
||||
|
|
@ -397,72 +374,55 @@ int thumbDV_openSerial( const char * tty_name ) {
|
|||
close( fd );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( _check_serial( fd ) != 0 ) {
|
||||
*/
|
||||
if ( _check_serial(handle) != 0 ) {
|
||||
output( "Could not detect ThumbDV at 460800 Baud. Trying 230400\n" );
|
||||
close( fd );
|
||||
FT_Close(handle);
|
||||
handle = (FT_HANDLE)NULL;
|
||||
} else {
|
||||
return fd;
|
||||
return handle;
|
||||
}
|
||||
|
||||
fd = open( tty_name, O_RDWR | O_NOCTTY | O_SYNC );
|
||||
status = FT_OpenEx(device.SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &handle);
|
||||
|
||||
if ( fd < 0 ) {
|
||||
output( "ThumbDV: error when opening %s, errno=%d\n", tty_name, errno );
|
||||
return fd;
|
||||
if ( status != FT_OK || handle == NULL )
|
||||
{
|
||||
if ( device.SerialNumber )
|
||||
output("Error opening device %s - error 0x%X\n", device.SerialNumber, status);
|
||||
else
|
||||
output("Error opening device - error 0x%X\n", status);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( tcgetattr( fd, &tty ) != 0 ) {
|
||||
output( "ThumbDV: error %d from tcgetattr\n", errno );
|
||||
return -1;
|
||||
}
|
||||
FT_SetBaudRate(handle, FT_BAUD_230400 );
|
||||
|
||||
cfsetospeed( &tty, B230400 );
|
||||
cfsetispeed( &tty, B230400 );
|
||||
FT_SetTimeouts(handle, 2000, 2000);
|
||||
|
||||
tty.c_cflag = ( tty.c_cflag & ~CSIZE ) | CS8;
|
||||
tty.c_iflag &= ~IGNBRK;
|
||||
tty.c_lflag = 0;
|
||||
|
||||
tty.c_oflag = 0;
|
||||
tty.c_cc[VMIN] = 1;
|
||||
tty.c_cc[VTIME] = 5;
|
||||
|
||||
tty.c_iflag &= ~( IXON | IXOFF | IXANY );
|
||||
|
||||
tty.c_cflag |= ( CLOCAL | CREAD );
|
||||
|
||||
tty.c_cflag &= ~( PARENB | PARODD );
|
||||
tty.c_cflag &= ~CSTOPB;
|
||||
tty.c_cflag &= ~CRTSCTS;
|
||||
|
||||
if ( tcsetattr( fd, TCSANOW, &tty ) != 0 ) {
|
||||
output( "ThumbDV: error %d from tcsetattr\n", errno );
|
||||
close( fd );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( _check_serial( fd ) != 0 ) {
|
||||
if ( _check_serial( handle ) != 0 ) {
|
||||
output( "Could not detect THumbDV at 230400 Baud\n" );
|
||||
close( fd );
|
||||
return -1;
|
||||
FT_Close(handle);
|
||||
handle = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fd;
|
||||
return handle;
|
||||
}
|
||||
|
||||
int thumbDV_processSerial( int serial_fd ) {
|
||||
int thumbDV_processSerial( FT_HANDLE handle )
|
||||
{
|
||||
unsigned char buffer[BUFFER_LENGTH];
|
||||
unsigned int respLen;
|
||||
unsigned int offset;
|
||||
ssize_t len;
|
||||
|
||||
unsigned char packet_type;
|
||||
FT_STATUS status = FT_OK;
|
||||
DWORD rx_bytes = 0;
|
||||
|
||||
errno = 0;
|
||||
len = read( serial_fd, buffer, 1 );
|
||||
status = FT_Read(handle, buffer, AMBE3000_HEADER_LEN, &rx_bytes);
|
||||
|
||||
if ( len != 1 ) {
|
||||
output( ANSI_RED "ThumbDV: Process serial. error when reading from the serial port, len = %d, errno=%d\n" ANSI_WHITE, len, errno );
|
||||
if ( status != FT_OK || rx_bytes != AMBE3000_HEADER_LEN)
|
||||
{
|
||||
output( ANSI_RED "ThumbDV: Process serial. error when reading from the serial port, len = %d, status=%d\n" ANSI_WHITE, rx_bytes, status );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -471,28 +431,36 @@ int thumbDV_processSerial( int serial_fd ) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
offset = 0U;
|
||||
|
||||
while ( offset < ( AMBE3000_HEADER_LEN - 1U ) ) {
|
||||
len = read( serial_fd, buffer + 1U + offset, AMBE3000_HEADER_LEN - 1 - offset );
|
||||
|
||||
if ( len == 0 )
|
||||
delay( 5UL );
|
||||
|
||||
offset += len;
|
||||
}
|
||||
// offset = 0U;
|
||||
//
|
||||
// while ( offset < ( AMBE3000_HEADER_LEN - 1U ) )
|
||||
// {
|
||||
// len = read( serial_fd, buffer + 1U + offset, AMBE3000_HEADER_LEN - 1 - offset );
|
||||
//
|
||||
// if ( len == 0 )
|
||||
// delay( 5UL );
|
||||
//
|
||||
// offset += len;
|
||||
// }
|
||||
|
||||
respLen = buffer[1U] * 256U + buffer[2U];
|
||||
|
||||
offset = 0U;
|
||||
// offset = 0U;
|
||||
//
|
||||
// while ( offset < respLen ) {
|
||||
// len = read( serial_fd, buffer + AMBE3000_HEADER_LEN + offset, respLen - offset );
|
||||
//
|
||||
// if ( len == 0 )
|
||||
// delay( 5UL );
|
||||
//
|
||||
// offset += len;
|
||||
// }
|
||||
|
||||
while ( offset < respLen ) {
|
||||
len = read( serial_fd, buffer + AMBE3000_HEADER_LEN + offset, respLen - offset );
|
||||
status = FT_Read(handle, buffer + AMBE3000_HEADER_LEN, respLen, &rx_bytes);
|
||||
|
||||
if ( len == 0 )
|
||||
delay( 5UL );
|
||||
|
||||
offset += len;
|
||||
if ( status != FT_OK || rx_bytes != respLen )
|
||||
{
|
||||
output( ANSI_RED "ThumbDV: Process serial. error when reading from the serial port, len = %d, status=%d\n" ANSI_WHITE, rx_bytes, status );
|
||||
}
|
||||
|
||||
respLen += AMBE3000_HEADER_LEN;
|
||||
|
|
@ -526,12 +494,12 @@ int thumbDV_processSerial( int serial_fd ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int thumbDV_decode( int serial_fd, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet ) {
|
||||
int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet ) {
|
||||
uint32 i = 0;
|
||||
|
||||
unsigned char full_packet[15] = {0};
|
||||
|
||||
if ( packet_in != NULL && serial_fd > 0 ) {
|
||||
if ( packet_in != NULL && handle != NULL ) {
|
||||
full_packet[0] = 0x61;
|
||||
full_packet[1] = 0x00;
|
||||
full_packet[2] = 0x0B;
|
||||
|
|
@ -546,7 +514,7 @@ int thumbDV_decode( int serial_fd, unsigned char * packet_in, short * speech_out
|
|||
|
||||
// thumbDV_dump("Just AMBE", packet_in, 9);
|
||||
// thumbDV_dump("Encoded packet:", full_packet, 15);
|
||||
thumbDV_writeSerial( serial_fd, full_packet, 15 );
|
||||
thumbDV_writeSerial( handle, full_packet, 15 );
|
||||
}
|
||||
|
||||
int32 samples_returned = 0;
|
||||
|
|
@ -584,7 +552,8 @@ int thumbDV_decode( int serial_fd, unsigned char * packet_in, short * speech_out
|
|||
return samples_returned;
|
||||
}
|
||||
|
||||
int thumbDV_encode( int serial_fd, short * speech_in, unsigned char * packet_out, uint8 num_of_samples ) {
|
||||
int thumbDV_encode( FT_HANDLE handle, short * speech_in, unsigned char * packet_out, uint8 num_of_samples )
|
||||
{
|
||||
unsigned char packet[THUMBDV_MAX_PACKET_LEN];
|
||||
uint16 speech_d_bytes = num_of_samples * sizeof( uint16 ); /* Should be 2 times the number of samples */
|
||||
|
||||
|
|
@ -634,8 +603,8 @@ int thumbDV_encode( int serial_fd, short * speech_in, unsigned char * packet_out
|
|||
idx[1] = ( speech_in[i] & 0x00FF ) ;
|
||||
}
|
||||
|
||||
if ( serial_fd > 0 )
|
||||
thumbDV_writeSerial( serial_fd, packet, length + AMBE3000_HEADER_LEN );
|
||||
if ( handle != NULL )
|
||||
thumbDV_writeSerial( handle, packet, length + AMBE3000_HEADER_LEN );
|
||||
|
||||
int32 samples_returned = 0;
|
||||
BufferDescriptor desc = _thumbDVEncodedList_UnlinkHead();
|
||||
|
|
@ -655,112 +624,123 @@ int thumbDV_encode( int serial_fd, short * speech_in, unsigned char * packet_out
|
|||
|
||||
}
|
||||
|
||||
|
||||
static void _connectSerial( int * serial_fd ) {
|
||||
static void _connectSerial( FT_HANDLE * ftHandle )
|
||||
{
|
||||
int i = 0 ;
|
||||
char device[256] = {0} ;
|
||||
|
||||
output("ConnectSerial\n");
|
||||
|
||||
DWORD numDevs = 0;
|
||||
FT_DEVICE_LIST_INFO_NODE *devInfo = NULL;
|
||||
FT_STATUS status = FT_OK;
|
||||
|
||||
do {
|
||||
for ( i = 0 ; i < 25 ; i++ ) {
|
||||
sprintf( device, "/dev/ttyUSB%d", i );
|
||||
*serial_fd = thumbDV_openSerial( device );
|
||||
|
||||
if ( *serial_fd > 0 ) {
|
||||
/* We opened a valid port */
|
||||
status = FT_CreateDeviceInfoList(&numDevs);
|
||||
|
||||
devInfo = (FT_DEVICE_LIST_INFO_NODE *) safe_malloc(sizeof(FT_DEVICE_LIST_INFO_NODE) * numDevs);
|
||||
|
||||
status = FT_GetDeviceInfoList(devInfo, &numDevs);
|
||||
|
||||
for ( i = 0 ; i < numDevs ; i++ )
|
||||
{
|
||||
|
||||
*ftHandle = thumbDV_openSerial(devInfo[i]);
|
||||
|
||||
if ( *ftHandle != NULL )
|
||||
{
|
||||
/* We opened a valid port and detected the ThumbDV */
|
||||
break;
|
||||
}
|
||||
}
|
||||
safe_free(devInfo);
|
||||
|
||||
if ( * serial_fd < 0 ) {
|
||||
if ( *ftHandle == NULL ) {
|
||||
output( "Could not open serial. Waiting 1 second before trying again.\n" );
|
||||
usleep( 1000 * 1000 );
|
||||
}
|
||||
} while ( *serial_fd < 0 ) ;
|
||||
} while ( *ftHandle == NULL ) ;
|
||||
|
||||
unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 };
|
||||
thumbDV_writeSerial( *serial_fd, reset, 5 );
|
||||
thumbDV_writeSerial( *ftHandle, reset, 5 );
|
||||
/* Block until we get data from serial port after reset */
|
||||
thumbDV_processSerial( *serial_fd );
|
||||
thumbDV_processSerial( *ftHandle );
|
||||
//
|
||||
// unsigned char reset_softcfg[11] = {0x61, 0x00, 0x07, 0x00, 0x34, 0x05, 0x03, 0xEB, 0xFF, 0xFF, 0xFF};
|
||||
// thumbDV_writeSerial(*serial_fd, reset_softcfg, 11);
|
||||
// thumbDV_processSerial(*serial_fd);
|
||||
// thumbDV_writeSerial(*ftHandle, reset_softcfg, 11);
|
||||
// thumbDV_processSerial(*ftHandle);
|
||||
|
||||
unsigned char disable_parity[6] = {0x61, 0x00, 0x02, 0x00, 0x3F, 0x00};
|
||||
thumbDV_writeSerial( *serial_fd, disable_parity, 6 );
|
||||
thumbDV_processSerial( *serial_fd );
|
||||
thumbDV_writeSerial( *ftHandle, disable_parity, 6 );
|
||||
thumbDV_processSerial( *ftHandle );
|
||||
|
||||
unsigned char get_prodID[5] = {0x61, 0x00, 0x01, 0x00, 0x30 };
|
||||
unsigned char get_version[5] = {0x61, 0x00, 0x01, 0x00, 0x31};
|
||||
unsigned char read_cfg[5] = {0x61, 0x00, 0x01, 0x00, 0x37};
|
||||
unsigned char dstar_mode[17] = {0x61, 0x00, 0x0D, 0x00, 0x0A, 0x01, 0x30, 0x07, 0x63, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48};
|
||||
|
||||
thumbDV_writeSerial( *serial_fd, get_prodID, 5 );
|
||||
thumbDV_writeSerial( *serial_fd, get_version, 5 );
|
||||
thumbDV_writeSerial( *serial_fd, read_cfg, 5 );
|
||||
thumbDV_writeSerial( *serial_fd, dstar_mode, 17 );
|
||||
thumbDV_writeSerial( *ftHandle, get_prodID, 5 );
|
||||
thumbDV_writeSerial( *ftHandle, get_version, 5 );
|
||||
thumbDV_writeSerial( *ftHandle, read_cfg, 5 );
|
||||
thumbDV_writeSerial( *ftHandle, dstar_mode, 17 );
|
||||
|
||||
//// /* Init */
|
||||
unsigned char pkt_init[6] = { 0x61, 0x00, 0x02, 0x00, 0x0B, 0x07 };
|
||||
thumbDV_writeSerial( *serial_fd, pkt_init, 6 );
|
||||
thumbDV_writeSerial( *ftHandle, pkt_init, 6 );
|
||||
|
||||
/* PKT GAIN - set to 0dB */
|
||||
unsigned char pkt_gain[7] = { 0x61, 0x00, 0x03, 0x00, 0x4B, 0x00, 0x00 };
|
||||
thumbDV_writeSerial( *serial_fd, pkt_gain, 7 );
|
||||
thumbDV_writeSerial( *ftHandle, pkt_gain, 7 );
|
||||
|
||||
/* Companding off so it uses 16bit linear */
|
||||
unsigned char pkt_compand[6] = { 0x61, 0x00, 0x02, 0x00, 0x32, 0x00 };
|
||||
thumbDV_writeSerial( *serial_fd, pkt_compand, 6 );
|
||||
thumbDV_writeSerial( *ftHandle, pkt_compand, 6 );
|
||||
|
||||
unsigned char test_coded[15] = {0x61, 0x00 , 0x0B , 0x01 , 0x01 , 0x48 , 0x5E , 0x83 , 0x12 , 0x3B , 0x98 , 0x79 , 0xDE , 0x13 , 0x90};
|
||||
|
||||
thumbDV_writeSerial( *serial_fd, test_coded, 15 );
|
||||
thumbDV_writeSerial( *ftHandle, test_coded, 15 );
|
||||
|
||||
unsigned char pkt_fmt[7] = {0x61, 0x00, 0x3, 0x00, 0x15, 0x00, 0x00};
|
||||
thumbDV_writeSerial( *serial_fd, pkt_fmt, 7 );
|
||||
thumbDV_writeSerial( *ftHandle, pkt_fmt, 7 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void * _thumbDV_readThread( void * param ) {
|
||||
int topFd;
|
||||
fd_set fds;
|
||||
static void * _thumbDV_readThread( void * param )
|
||||
{
|
||||
int ret;
|
||||
DWORD rx_bytes;
|
||||
DWORD tx_bytes;
|
||||
DWORD event_dword;
|
||||
|
||||
int serial_fd = *( int * )param;
|
||||
topFd = serial_fd + 1;
|
||||
FT_STATUS status = FT_OK;
|
||||
FT_HANDLE handle = *( FT_HANDLE * )param;
|
||||
|
||||
output( "Serial FD = %d in thumbDV_readThread(). TopFD = %d\n", serial_fd, topFd );
|
||||
prctl(PR_SET_NAME, "DV-Read");
|
||||
|
||||
struct timeval timeout;
|
||||
while ( !_readThreadAbort )
|
||||
{
|
||||
status = FT_GetStatus(handle, &rx_bytes, &tx_bytes, &event_dword);
|
||||
|
||||
while ( !_readThreadAbort ) {
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO( &fds );
|
||||
FD_SET( serial_fd, &fds );
|
||||
|
||||
errno = 0;
|
||||
ret = select( topFd, &fds, NULL, NULL, &timeout );
|
||||
|
||||
if ( ret < 0 ) {
|
||||
fprintf( stderr, "ThumbDV: error from select, errno=%d\n", errno );
|
||||
if ( status != FT_OK )
|
||||
{
|
||||
fprintf( stderr, "ThumbDV: error from select, status=%d\n", status );
|
||||
|
||||
/* Set invalid FD in sched_waveform so we don't call write functions */
|
||||
handle = NULL;
|
||||
sched_waveform_setHandle(&handle);
|
||||
/* This function hangs until a new connection is made */
|
||||
_connectSerial( &handle );
|
||||
/* Update the sched_waveform to new valid serial */
|
||||
sched_waveform_setHandle( &handle );
|
||||
}
|
||||
|
||||
if ( FD_ISSET( serial_fd, &fds ) ) {
|
||||
ret = thumbDV_processSerial( serial_fd );
|
||||
|
||||
if ( ret != 0 ) {
|
||||
/* Set invalid FD in sched_waveform so we don't call write functions */
|
||||
sched_waveform_setFD( -1 );
|
||||
/* This function hangs until a new connection is made */
|
||||
_connectSerial( &serial_fd );
|
||||
/* Update the sched_waveform to new valid serial */
|
||||
sched_waveform_setFD( serial_fd );
|
||||
topFd = serial_fd + 1;
|
||||
}
|
||||
else if ( rx_bytes > 0 )
|
||||
{
|
||||
ret = thumbDV_processSerial( handle );
|
||||
}
|
||||
else
|
||||
{
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -768,7 +748,7 @@ static void * _thumbDV_readThread( void * param ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void thumbDV_init( int * serial_fd ) {
|
||||
void thumbDV_init( FT_HANDLE * handle ) {
|
||||
pthread_rwlock_init( &_encoded_list_lock, NULL );
|
||||
pthread_rwlock_init( &_decoded_list_lock, NULL );
|
||||
|
||||
|
|
@ -786,9 +766,9 @@ void thumbDV_init( int * serial_fd ) {
|
|||
_decoded_root->prev = _decoded_root;
|
||||
pthread_rwlock_unlock( &_decoded_list_lock );
|
||||
|
||||
_connectSerial( serial_fd );
|
||||
_connectSerial( handle );
|
||||
|
||||
pthread_create( &_read_thread, NULL, &_thumbDV_readThread, serial_fd );
|
||||
pthread_create( &_read_thread, NULL, &_thumbDV_readThread, handle );
|
||||
|
||||
struct sched_param fifo_param;
|
||||
fifo_param.sched_priority = 30;
|
||||
|
|
|
|||
|
|
@ -36,12 +36,14 @@
|
|||
#ifndef THUMBDV_THUMBDV_H_
|
||||
#define THUMBDV_THUMBDV_H_
|
||||
|
||||
void thumbDV_init( int * serial_fd );
|
||||
int thumbDV_openSerial( const char * tty_name );
|
||||
int thumbDV_processSerial( int serial_fd );
|
||||
#include "ftd2xx.h"
|
||||
|
||||
int thumbDV_encode( int serial_fd, short * speech_in, unsigned char * packet_out, uint8 num_of_samples );
|
||||
int thumbDV_decode( int serial_fd, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet );
|
||||
void thumbDV_init( FT_HANDLE * serial_fd );
|
||||
FT_HANDLE thumbDV_openSerial( FT_DEVICE_LIST_INFO_NODE device );
|
||||
int thumbDV_processSerial( FT_HANDLE handle );
|
||||
|
||||
int thumbDV_encode( FT_HANDLE handle, short * speech_in, unsigned char * packet_out, uint8 num_of_samples );
|
||||
int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet );
|
||||
|
||||
void thumbDV_dump( char * text, unsigned char * data, unsigned int length );
|
||||
void thumbDV_flushLists(void);
|
||||
|
|
|
|||
136
DSP_API/include/WinTypes.h
Normal file
136
DSP_API/include/WinTypes.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
#ifndef __WINDOWS_TYPES__
|
||||
#define __WINDOWS_TYPES__
|
||||
|
||||
#define WINAPI
|
||||
|
||||
typedef unsigned int DWORD;
|
||||
typedef unsigned int ULONG;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short SHORT;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned char BYTE;
|
||||
typedef BYTE *LPBYTE;
|
||||
typedef unsigned int BOOLU;
|
||||
typedef unsigned char BOOLEAN;
|
||||
typedef unsigned char CHAR;
|
||||
typedef BOOLU *LPBOOL;
|
||||
typedef UCHAR *PUCHAR;
|
||||
typedef const char *LPCSTR;
|
||||
typedef char *PCHAR;
|
||||
typedef void *PVOID;
|
||||
typedef void *HANDLE;
|
||||
typedef unsigned int LONG;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef char *LPSTR;
|
||||
typedef char *LPTSTR;
|
||||
typedef const char *LPCTSTR;
|
||||
typedef DWORD *LPDWORD;
|
||||
typedef WORD *LPWORD;
|
||||
typedef ULONG *PULONG;
|
||||
typedef LONG *LPLONG;
|
||||
typedef PVOID LPVOID;
|
||||
typedef void VOID;
|
||||
typedef unsigned long long int ULONGLONG;
|
||||
|
||||
typedef struct _OVERLAPPED {
|
||||
DWORD Internal;
|
||||
DWORD InternalHigh;
|
||||
DWORD Offset;
|
||||
DWORD OffsetHigh;
|
||||
HANDLE hEvent;
|
||||
} OVERLAPPED, *LPOVERLAPPED;
|
||||
|
||||
typedef struct _SECURITY_ATTRIBUTES {
|
||||
DWORD nLength;
|
||||
LPVOID lpSecurityDescriptor;
|
||||
BOOL bInheritHandle;
|
||||
} SECURITY_ATTRIBUTES , *LPSECURITY_ATTRIBUTES;
|
||||
|
||||
#include <pthread.h>
|
||||
// Substitute for HANDLE returned by Windows CreateEvent API.
|
||||
// FT_SetEventNotification expects parameter 3 to be the address
|
||||
// of one of these structures.
|
||||
typedef struct _EVENT_HANDLE
|
||||
{
|
||||
pthread_cond_t eCondVar;
|
||||
pthread_mutex_t eMutex;
|
||||
int iVar;
|
||||
} EVENT_HANDLE;
|
||||
|
||||
typedef struct timeval SYSTEMTIME;
|
||||
typedef struct timeval FILETIME;
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
//
|
||||
// Modem Status Flags
|
||||
//
|
||||
#define MS_CTS_ON ((DWORD)0x0010)
|
||||
#define MS_DSR_ON ((DWORD)0x0020)
|
||||
#define MS_RING_ON ((DWORD)0x0040)
|
||||
#define MS_RLSD_ON ((DWORD)0x0080)
|
||||
|
||||
//
|
||||
// Error Flags
|
||||
//
|
||||
#define CE_RXOVER 0x0001 // Receive Queue overflow
|
||||
#define CE_OVERRUN 0x0002 // Receive Overrun Error
|
||||
#define CE_RXPARITY 0x0004 // Receive Parity Error
|
||||
#define CE_FRAME 0x0008 // Receive Framing error
|
||||
#define CE_BREAK 0x0010 // Break Detected
|
||||
#define CE_TXFULL 0x0100 // TX Queue is full
|
||||
#define CE_PTO 0x0200 // LPTx Timeout
|
||||
#define CE_IOE 0x0400 // LPTx I/O Error
|
||||
#define CE_DNS 0x0800 // LPTx Device not selected
|
||||
#define CE_OOP 0x1000 // LPTx Out-Of-Paper
|
||||
#define CE_MODE 0x8000 // Requested mode unsupported
|
||||
|
||||
//
|
||||
// Events
|
||||
//
|
||||
#define EV_RXCHAR 0x0001 // Any Character received
|
||||
#define EV_RXFLAG 0x0002 // Received certain character
|
||||
#define EV_TXEMPTY 0x0004 // Transmit Queue Empty
|
||||
#define EV_CTS 0x0008 // CTS changed state
|
||||
#define EV_DSR 0x0010 // DSR changed state
|
||||
#define EV_RLSD 0x0020 // RLSD changed state
|
||||
#define EV_BREAK 0x0040 // BREAK received
|
||||
#define EV_ERR 0x0080 // Line status error occurred
|
||||
#define EV_RING 0x0100 // Ring signal detected
|
||||
#define EV_PERR 0x0200 // Printer error occured
|
||||
#define EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
|
||||
#define EV_EVENT1 0x0800 // Provider specific event 1
|
||||
#define EV_EVENT2 0x1000 // Provider specific event 2
|
||||
|
||||
//
|
||||
// Escape Functions
|
||||
//
|
||||
#define SETXOFF 1 // Simulate XOFF received
|
||||
#define SETXON 2 // Simulate XON received
|
||||
#define SETRTS 3 // Set RTS high
|
||||
#define CLRRTS 4 // Set RTS low
|
||||
#define SETDTR 5 // Set DTR high
|
||||
#define CLRDTR 6 // Set DTR low
|
||||
#define RESETDEV 7 // Reset device if possible
|
||||
#define SETBREAK 8 // Set the device break line.
|
||||
#define CLRBREAK 9 // Clear the device break line.
|
||||
|
||||
//
|
||||
// PURGE function flags.
|
||||
//
|
||||
#define PURGE_TXABORT 0x0001 // Kill the pending/current writes to the comm port.
|
||||
#define PURGE_RXABORT 0x0002 // Kill the pending/current reads to the comm port.
|
||||
#define PURGE_TXCLEAR 0x0004 // Kill the transmit queue if there.
|
||||
#define PURGE_RXCLEAR 0x0008 // Kill the typeahead buffer if there.
|
||||
|
||||
#ifndef INVALID_HANDLE_VALUE
|
||||
#define INVALID_HANDLE_VALUE 0xFFFFFFFF
|
||||
#endif
|
||||
|
||||
#endif /* __WINDOWS_TYPES__ */
|
||||
1427
DSP_API/include/ftd2xx.h
Normal file
1427
DSP_API/include/ftd2xx.h
Normal file
File diff suppressed because it is too large
Load diff
BIN
DSP_API/lib/libftd2xx.a
Normal file
BIN
DSP_API/lib/libftd2xx.a
Normal file
Binary file not shown.
Loading…
Reference in a new issue