From: drowe67 Date: Tue, 23 Jun 2015 02:28:52 +0000 (+0000) Subject: some code for logging debug messages to windows X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=93c54adba48c9abcd95c8a6a7a33413f2eae024f;p=freetel-svn-tracking.git some code for logging debug messages to windows git-svn-id: https://svn.code.sf.net/p/freetel/code@2210 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2-dev/README.Win32 b/fdmdv2-dev/README.Win32 deleted file mode 100644 index 0fc91828..00000000 --- a/fdmdv2-dev/README.Win32 +++ /dev/null @@ -1,89 +0,0 @@ -README.Win32 -David Rowe 27 Oct 2012 - -Debugging Under Windows ------------------------ - -printfs don't appear until after the program finishes. wxLogDebug() -works but you need to run DebugView available from -http://www.sysinternals.com to capture the messages. - -Building fdmdv2 & fdmdv-dev for Windows ---------------------------------------- - -Richard is currently working on a cmake build system for Win32, until -then the approach below is being used by David Rowe.Many variations -are possible: - -1. Install MinGW & the mysys shell - + pwd -W prints true Win32 directory - + I also installed emacs, "tortise svn", and "cmake" - -2. "make install" for various packages below put DLLs in /usr/local/lib - "cd /usr/local/lib; pwd -W" to find the Win32 directory - add this to the Windows PATH (Control Panel - System - Advanced) - -3. WxWidgets: - download 2.9.4 tar ball - mkdir build-debug; cd build-debug - ./configure --with-msw - make && make install - -4. PortAudio: - download latest V19 - ./configure --enable-cxx - make && make install - -5. libsndfile: - download lastest source tar ball (not Win32 binaries) - ./configure && make && make install - -6. libsamplerate: - download latest source tar ball: - http://www.mega-nerd.com/SRC/libsamplerate-0.1.8.tar.gz(not Win32 binaries) - ./configure && make && make install - -7. hamlib - - I couldn't get this to compile from source, so used the pre-built Win32 - DLLs: - - Download https://downloads.sourceforge.net/project/hamlib/hamlib/1.2.15.3/hamlib-win32-1.2.15.3.zip - Open hamlib-win32-1.2.15.3.zip with a GUI archive tool - Copy hamlib/include/* to /usr/local/include - Copy hamlib/bin/hamlib*.dll to /usr/local/lib - Copy hamlib/lib/gcc to /usr/local/lib - -8. sox (used for Filter - EQ) - - $ wget http://sourceforge.net/projects/sox/files/sox/14.4.0/sox-14.4.0.tar.gz - $ tar xvzf sox-14.4.0.tar.gz - $ ./configure --enable-shared=no --without-id3tag --without-png --disable-gomp --with-oggvorbis=no --with-oss=no --with-flac=no --disable-dl-sndfile --with-waveaudio=no - $ make && make install - - I couldn't find an install command line that worked, so manually copied the libs and include files. - -9. Speex (we use the DSP lib for noise reduction): - - $ wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz - $ tar xvzf speex-1.2rc1.tar.gz - $ cd speex-1.2rc1 - $ ./configure && make install - (ignore libogg warnings, we just want libspeexdsp.a) - -10. Codec 2 - $ check out codec-dev using tortise svn from: - wget https://freetel.svn.sourceforge.net/svnroot/freetel/codec2-dev - $ cd codec2-dev - $ mkdir build_win32 - $ cd build_win32 - $ cmake -DSPEEXDSP_INCLUDE_DIR=/usr/local/include/ -G "MSYS Makefiles" .. - $ make - $ cp src/libcodec2.dll* /usr/local/lib - -11. freedv (dev version) - $ check out fdmdv2-dev using tortise svn from: - wget https://freetel.svn.sourceforge.net/svnroot/freetel/fdmdv2-dev - $ cd fdmdv2-dev/src - $ make -f Makefile.Win32 - diff --git a/fdmdv2-dev/README.txt b/fdmdv2-dev/README.txt index d7faee3c..54bf87ea 100644 --- a/fdmdv2-dev/README.txt +++ b/fdmdv2-dev/README.txt @@ -57,14 +57,14 @@ Quickstart 2 3/ Checkout a fresh copy of codec2-dev and build for Windows, pointing to the generate_codebook built by a linux build of generate_codebook, using this cmake line - $ cmake .. -DCMAKE_TOOLCHAIN_FILE=../fdmdv2-dev/cmake/Toolchain-Ubuntu-mingw32.cmake -DUNITTEST=FALSE -DGENERATE_CODEBOOK=/home/david/codec2-dev/build_linux/src/generate_codebook + $ cmake .. -DCMAKE_TOOLCHAIN_FILE=../fdmdv2-dev/cmake/Toolchain-Ubuntu-mingw32.cmake -DUNITTEST=FALSE -DGENERATE_CODEBOOK=/home/david/codec2-dev/build_linux/src/generate_codebook 4/ Build WxWidgets $ cd /path/to/fdmdv2-dev $ mkdir build_windows $ cd build_windows - $ cmake -DBOOTSTRAP_WXWIDGETS=TRUE .. -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-Ubuntu-mingw32.cmake + $ cmake -DBOOTSTRAP_WXWIDGETS=TRUE .. -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-Ubuntu-mingw32.cmake -DCMAKE_BUILD_TYPE=Debug $ make 5/ Download and install the Windows version of Hamlib: @@ -74,7 +74,7 @@ Quickstart 2 6/ Build All the libraries and FreeDV: - $ cmake -DBOOTSTRAP_WXWIDGETS=TRUE -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-Ubuntu-mingw32.cmake -DUSE_STATIC_PORTAUDIO=TRUE -DUSE_STATIC_SNDFILE=TRUE -DUSE_STATIC_SAMPLERATE=TRUE -DUSE_STATIC_SOX=TRUE -DUSE_STATIC_CODEC2=FALSE -DCODEC2_INCLUDE_DIRS=/home/david/tmp/codec2-dev/src -DCODEC2_LIBRARY=/home/david/tmp/codec2-dev/build_windows/src/libcodec2.dll.a -DHAMLIB_INCLUDE_DIR=hamlib-win32-1.2.15.3/include -DHAMLIB_LIBRARY=hamlib-win32-1.2.15.3/lib/gcc/libhamlib.dll.a .. + $ cmake -DBOOTSTRAP_WXWIDGETS=TRUE -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-Ubuntu-mingw32.cmake -DUSE_STATIC_PORTAUDIO=TRUE -DUSE_STATIC_SNDFILE=TRUE -DUSE_STATIC_SAMPLERATE=TRUE -DUSE_STATIC_SOX=TRUE -DUSE_STATIC_CODEC2=FALSE -DCODEC2_INCLUDE_DIRS=/home/david/tmp/codec2-dev/src -DCODEC2_LIBRARY=/home/david/tmp/codec2-dev/build_windows/src/libcodec2.dll.a -DHAMLIB_INCLUDE_DIR=hamlib-win32-1.2.15.3/include -DHAMLIB_LIBRARY=hamlib-win32-1.2.15.3/lib/gcc/libhamlib.dll.a -DCMAKE_BUILD_TYPE=Debug .. $ make ==================================== diff --git a/fdmdv2-dev/src/fdmdv2_main.cpp b/fdmdv2-dev/src/fdmdv2_main.cpp index 80713ef3..e31209ef 100644 --- a/fdmdv2-dev/src/fdmdv2_main.cpp +++ b/fdmdv2-dev/src/fdmdv2_main.cpp @@ -124,6 +124,7 @@ SpeexPreprocessState *g_speex_st; // WxWidgets - initialize the application IMPLEMENT_APP(MainApp); +FILE *g_logfile; //------------------------------------------------------------------------- // OnInit() @@ -166,6 +167,7 @@ bool MainApp::OnInit() frame->Layout(); frame->Show(); g_parent =frame; + return true; } @@ -184,6 +186,12 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) { m_zoom = 1.; + #ifdef __WXMSW__ + g_logfile = fopen("log.txt","wt"); + #else + g_logfile = stderr; + #endif + SetMinSize(wxSize(400,400)); // Init Hamlib library, but we dont start talking to any rigs yet @@ -207,14 +215,12 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) // sanitise frame position as a first pass at Win32 registry bug - printf("x = %d y = %d w = %d h = %d\n", x,y,w,h); + fprintf(g_logfile, "x = %d y = %d w = %d h = %d\n", x,y,w,h); if (x < 0 || x > 2048) x = 20; if (y < 0 || y > 2048) y = 20; if (w < 0 || w > 2048) w = 800; if (h < 0 || h > 2048) h = 550; - // note: run DebugView program to see this message under windows - //wxLogDebug("x = %d y = %d w = %d h = %d\n", x,y,w,h); wxGetApp().m_show_wf = pConfig->Read(wxT("/MainFrame/show_wf"), 1); wxGetApp().m_show_spect = pConfig->Read(wxT("/MainFrame/show_spect"), 1); wxGetApp().m_show_scatter = pConfig->Read(wxT("/MainFrame/show_scatter"), 1); @@ -500,6 +506,10 @@ MainFrame::~MainFrame() int w; int h; + #ifdef __WXMSW__ + fclose(g_logfile); + #endif + if (optionsDlg != NULL) { delete optionsDlg; optionsDlg = NULL; @@ -2126,10 +2136,10 @@ void MainFrame::stopRxStream() { m_RxRunning = false; - wxLogDebug("waiting for thread to stop"); + fprintf(g_logfile, "waiting for thread to stop"); m_txRxThread->m_run = 0; m_txRxThread->Wait(); - wxLogDebug("thread stopped"); + fprintf(g_logfile, "thread stopped"); m_rxInPa->stop(); m_rxInPa->streamClose();