cnping

Minimal Graphical Ping Tool
git clone https://git.sinitax.com/cnlohr/cnping
Log | Files | Refs | Submodules | README | LICENSE | sfeed.txt

commit 2d9e0ca3844391eb07d07fe24e26be54e516bffc
parent 50d754a4603888ea6703f4155ac10b752c0b9429
Author: cnlohr <charles@cnlohr.com>
Date:   Mon, 13 Mar 2017 11:39:47 -0400

Merge branch 'dreua-master'

Diffstat:
A.gitignore | 5+++++
MMakefile | 3++-
Mcnping.c | 18++++++++++++------
Mcnping.exe | 0
Mos_generic.c | 1+
5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,5 @@ +*.o +*.exe +cnping +cnping-mousey +searchnet diff --git a/Makefile b/Makefile @@ -4,7 +4,8 @@ CFLAGS:=$(CFLAGS) -g -Os -I/opt/X11/include CXXFLAGS:=$(CFLAGS) LDFLAGS:=-g -L/opt/X11/lib/ -MINGW32:=/usr/bin/i686-w64-mingw32- +#MINGW32:=/usr/bin/i686-w64-mingw32- +MINGW32:=i686-w64-mingw32- cnping.exe : cnping.c DrawFunctions.c WinDriver.c os_generic.c ping.c $(MINGW32)windres resources.rc -o resources.o diff --git a/cnping.c b/cnping.c @@ -126,6 +126,7 @@ void DrawFrame( void ) double totaltime = 0; int totalcountok = 0; + int totalcountloss = 0; double mintime = 10000; double maxtime = 0; double stddev = 0; @@ -140,7 +141,7 @@ void DrawFrame( void ) double dt = 0; - if( rt > st ) + if( rt > st ) // ping received { CNFGColor( 0xffffff ); dt = rt - st; @@ -149,13 +150,20 @@ void DrawFrame( void ) if( dt < mintime ) mintime = dt; if( dt > maxtime ) maxtime = dt; totalcountok++; + if( last < 0) + last = dt; } - else + else if (st != 0) // ping sent but not received { CNFGColor( 0xff ); dt = now - st; dt *= 1000; - + totalcountloss++; + } + else // no ping sent for this point in time (after startup) + { + CNFGColor( 0x0 ); + dt = 99 * 1000; // assume 99s to fill screen black } if (!GuiYscaleFactorIsConstant) @@ -163,8 +171,6 @@ void DrawFrame( void ) GuiYScaleFactor = (screeny - 50) / globmaxtime; } - if( last < 0 && rt > st ) - last = dt; int h = dt*GuiYScaleFactor; int top = screeny - h; if( top < 0 ) top = 0; @@ -172,7 +178,7 @@ void DrawFrame( void ) } double avg = totaltime / totalcountok; - loss = (double) (screenx - totalcountok) / screenx * 100; + loss = (double) totalcountloss / (totalcountok + totalcountloss) * 100; for( i = 0; i < screenx; i++ ) { diff --git a/cnping.exe b/cnping.exe Binary files differ. diff --git a/os_generic.c b/os_generic.c @@ -159,6 +159,7 @@ void OGDeleteSema( og_sema_t os ) #include <pthread.h> #include <sys/time.h> #include <semaphore.h> +#include <unistd.h> pthread_mutex_t g_RawMutexStart = PTHREAD_MUTEX_INITIALIZER;