All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cansniffer: increase resolution for timeout values
@ 2014-06-24 19:31 Oliver Hartkopp
  2014-06-24 19:39 ` Oliver Hartkopp
  2014-06-24 21:19 ` Marc Kleine-Budde
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Hartkopp @ 2014-06-24 19:31 UTC (permalink / raw)
  To: linux-can; +Cc: Oliver Hartkopp

From: Marc Kleine-Budde <mkl@pengutronix.de>

As requested by Felix Seitz the timeout for screen updates should be
configurable to values smaller than 100ms. Marc Kleine-Budde provided the
original patch to increase the resolution of the timing relevant variables.

The rotating animation was replaced by a rolling screen update counter.
Additionally the CAN-ID is now printed in the same ASCII hex representation
as the CAN data.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
 cansniffer.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/cansniffer.c b/cansniffer.c
index c8ee58e..39b3e2b 100644
--- a/cansniffer.c
+++ b/cansniffer.c
@@ -86,16 +86,13 @@
 
 /* time defaults */
 
-#define TIMEOUT 50 /* in 100ms */
-#define HOLD    10 /* in 100ms */
-#define LOOP     2 /* in 100ms */
-
-#define MAXANI 8
-const char anichar[MAXANI] = {'|', '/', '-', '\\', '|', '/', '-', '\\'};
+#define TIMEOUT 500 /* in 10ms */
+#define HOLD    100 /* in 10ms */
+#define LOOP     20 /* in 10ms */
 
 #define ATTCOLOR ATTBOLD FGRED
 
-#define STARTLINESTR "X  time    ID  data ... "
+#define STARTLINESTR "XX delta   ID  data ... "
 
 struct snif {
 	int flags;
@@ -172,9 +169,9 @@ void print_usage(char *prg)
 	fprintf(stderr, "         -B         (start with binary mode with gap - exceeds 80 chars!)\n");
 	fprintf(stderr, "         -c         (color changes)\n");
 	fprintf(stderr, "         -f         (filter on CAN-ID only)\n");
-	fprintf(stderr, "         -t <time>  (timeout for ID display [x100ms] default: %d, 0 = OFF)\n", TIMEOUT);
-	fprintf(stderr, "         -h <time>  (hold marker on changes [x100ms] default: %d)\n", HOLD);
-	fprintf(stderr, "         -l <time>  (loop time (display) [x100ms] default: %d)\n", LOOP);
+	fprintf(stderr, "         -t <time>  (timeout for ID display [x10ms] default: %d, 0 = OFF)\n", TIMEOUT);
+	fprintf(stderr, "         -h <time>  (hold marker on changes [x10ms] default: %d)\n", HOLD);
+	fprintf(stderr, "         -l <time>  (loop time (display) [x10ms] default: %d)\n", LOOP);
 	fprintf(stderr, "Use interface name '%s' to receive from all can-interfaces\n", ANYDEV);
 	fprintf(stderr, "\n");
 	fprintf(stderr, "%s", manual);
@@ -329,7 +326,7 @@ int main(int argc, char **argv)
 		FD_SET(s, &rdfs);
 
 		timeo.tv_sec  = 0;
-		timeo.tv_usec = 100000 * loop;
+		timeo.tv_usec = 10000 * loop;
 
 		if ((ret = select(s+1, &rdfs, NULL, NULL, &timeo)) < 0) {
 			//perror("select");
@@ -338,7 +335,7 @@ int main(int argc, char **argv)
 		}
 
 		gettimeofday(&tv, NULL);
-		currcms = (tv.tv_sec - start_tv.tv_sec) * 10 + (tv.tv_usec / 100000);
+		currcms = (tv.tv_sec - start_tv.tv_sec) * 100 + (tv.tv_usec / 10000);
 
 		if (FD_ISSET(0, &rdfs))
 			running &= handle_keyb(s);
@@ -538,6 +535,7 @@ int handle_timeo(int fd, long currcms){
 
 	int i;
 	int force_redraw = 0;
+	static unsigned int frame_count;
 
 	if (clearscreen) {
 		char startline[80];
@@ -555,7 +553,8 @@ int handle_timeo(int fd, long currcms){
 	}
 
 	printf("%s", CSR_HOME);
-	printf("%c\n", anichar[currcms % MAXANI]); /* funny animation */
+	printf("%02d\n", frame_count++); /* rolling display update counter */
+	frame_count %= 100;
 
 	for (i=0; i < 2048; i++) {
 
@@ -608,7 +607,7 @@ void print_snifline(int id){
 	if (diffsec > 10)
 		diffsec = 9, diffusec = 999999;
 
-	printf("%ld.%06ld  %3x  ", diffsec, diffusec, id);
+	printf("%ld.%06ld  %3X  ", diffsec, diffusec, id);
 
 	if (binary) {
 
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cansniffer: increase resolution for timeout values
  2014-06-24 19:31 [PATCH] cansniffer: increase resolution for timeout values Oliver Hartkopp
@ 2014-06-24 19:39 ` Oliver Hartkopp
  2014-06-24 21:20   ` Marc Kleine-Budde
  2014-06-24 21:19 ` Marc Kleine-Budde
  1 sibling, 1 reply; 5+ messages in thread
From: Oliver Hartkopp @ 2014-06-24 19:39 UTC (permalink / raw)
  To: linux-can; +Cc: Marc Kleine-Budde, Felix Seitz

Applied and pushed to master.

Tnx
Oliver

On 24.06.2014 21:31, Oliver Hartkopp wrote:
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> As requested by Felix Seitz the timeout for screen updates should be
> configurable to values smaller than 100ms. Marc Kleine-Budde provided the
> original patch to increase the resolution of the timing relevant variables.
> 
> The rotating animation was replaced by a rolling screen update counter.
> Additionally the CAN-ID is now printed in the same ASCII hex representation
> as the CAN data.
> 
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> ---
>  cansniffer.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/cansniffer.c b/cansniffer.c
> index c8ee58e..39b3e2b 100644
> --- a/cansniffer.c
> +++ b/cansniffer.c
> @@ -86,16 +86,13 @@
>  
>  /* time defaults */
>  
> -#define TIMEOUT 50 /* in 100ms */
> -#define HOLD    10 /* in 100ms */
> -#define LOOP     2 /* in 100ms */
> -
> -#define MAXANI 8
> -const char anichar[MAXANI] = {'|', '/', '-', '\\', '|', '/', '-', '\\'};
> +#define TIMEOUT 500 /* in 10ms */
> +#define HOLD    100 /* in 10ms */
> +#define LOOP     20 /* in 10ms */
>  
>  #define ATTCOLOR ATTBOLD FGRED
>  
> -#define STARTLINESTR "X  time    ID  data ... "
> +#define STARTLINESTR "XX delta   ID  data ... "
>  
>  struct snif {
>  	int flags;
> @@ -172,9 +169,9 @@ void print_usage(char *prg)
>  	fprintf(stderr, "         -B         (start with binary mode with gap - exceeds 80 chars!)\n");
>  	fprintf(stderr, "         -c         (color changes)\n");
>  	fprintf(stderr, "         -f         (filter on CAN-ID only)\n");
> -	fprintf(stderr, "         -t <time>  (timeout for ID display [x100ms] default: %d, 0 = OFF)\n", TIMEOUT);
> -	fprintf(stderr, "         -h <time>  (hold marker on changes [x100ms] default: %d)\n", HOLD);
> -	fprintf(stderr, "         -l <time>  (loop time (display) [x100ms] default: %d)\n", LOOP);
> +	fprintf(stderr, "         -t <time>  (timeout for ID display [x10ms] default: %d, 0 = OFF)\n", TIMEOUT);
> +	fprintf(stderr, "         -h <time>  (hold marker on changes [x10ms] default: %d)\n", HOLD);
> +	fprintf(stderr, "         -l <time>  (loop time (display) [x10ms] default: %d)\n", LOOP);
>  	fprintf(stderr, "Use interface name '%s' to receive from all can-interfaces\n", ANYDEV);
>  	fprintf(stderr, "\n");
>  	fprintf(stderr, "%s", manual);
> @@ -329,7 +326,7 @@ int main(int argc, char **argv)
>  		FD_SET(s, &rdfs);
>  
>  		timeo.tv_sec  = 0;
> -		timeo.tv_usec = 100000 * loop;
> +		timeo.tv_usec = 10000 * loop;
>  
>  		if ((ret = select(s+1, &rdfs, NULL, NULL, &timeo)) < 0) {
>  			//perror("select");
> @@ -338,7 +335,7 @@ int main(int argc, char **argv)
>  		}
>  
>  		gettimeofday(&tv, NULL);
> -		currcms = (tv.tv_sec - start_tv.tv_sec) * 10 + (tv.tv_usec / 100000);
> +		currcms = (tv.tv_sec - start_tv.tv_sec) * 100 + (tv.tv_usec / 10000);
>  
>  		if (FD_ISSET(0, &rdfs))
>  			running &= handle_keyb(s);
> @@ -538,6 +535,7 @@ int handle_timeo(int fd, long currcms){
>  
>  	int i;
>  	int force_redraw = 0;
> +	static unsigned int frame_count;
>  
>  	if (clearscreen) {
>  		char startline[80];
> @@ -555,7 +553,8 @@ int handle_timeo(int fd, long currcms){
>  	}
>  
>  	printf("%s", CSR_HOME);
> -	printf("%c\n", anichar[currcms % MAXANI]); /* funny animation */
> +	printf("%02d\n", frame_count++); /* rolling display update counter */
> +	frame_count %= 100;
>  
>  	for (i=0; i < 2048; i++) {
>  
> @@ -608,7 +607,7 @@ void print_snifline(int id){
>  	if (diffsec > 10)
>  		diffsec = 9, diffusec = 999999;
>  
> -	printf("%ld.%06ld  %3x  ", diffsec, diffusec, id);
> +	printf("%ld.%06ld  %3X  ", diffsec, diffusec, id);
>  
>  	if (binary) {
>  
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cansniffer: increase resolution for timeout values
  2014-06-24 19:31 [PATCH] cansniffer: increase resolution for timeout values Oliver Hartkopp
  2014-06-24 19:39 ` Oliver Hartkopp
@ 2014-06-24 21:19 ` Marc Kleine-Budde
  1 sibling, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-06-24 21:19 UTC (permalink / raw)
  To: Oliver Hartkopp, linux-can

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

On 06/24/2014 09:31 PM, Oliver Hartkopp wrote:
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> As requested by Felix Seitz the timeout for screen updates should be
> configurable to values smaller than 100ms. Marc Kleine-Budde provided the
> original patch to increase the resolution of the timing relevant variables.
> 
> The rotating animation was replaced by a rolling screen update counter.
> Additionally the CAN-ID is now printed in the same ASCII hex representation
> as the CAN data.
> 
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>

Looks good, please re-add my S-o-b before yours.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cansniffer: increase resolution for timeout values
  2014-06-24 19:39 ` Oliver Hartkopp
@ 2014-06-24 21:20   ` Marc Kleine-Budde
  2014-06-25  6:30     ` Oliver Hartkopp
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-06-24 21:20 UTC (permalink / raw)
  To: Oliver Hartkopp, linux-can; +Cc: Felix Seitz

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

On 06/24/2014 09:39 PM, Oliver Hartkopp wrote:
> Applied and pushed to master.

:) I was too slow.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cansniffer: increase resolution for timeout values
  2014-06-24 21:20   ` Marc Kleine-Budde
@ 2014-06-25  6:30     ` Oliver Hartkopp
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Hartkopp @ 2014-06-25  6:30 UTC (permalink / raw)
  To: Marc Kleine-Budde, linux-can; +Cc: Felix Seitz

At least I managed with this "From:" statement in my commit message to
announce you as the original author of the patch. Interesting.
There're always new features of git to be experienced by me :-)

Tnx,
Oliver

On 24.06.2014 23:20, Marc Kleine-Budde wrote:
> On 06/24/2014 09:39 PM, Oliver Hartkopp wrote:
>> Applied and pushed to master.
> 
> :) I was too slow.
> 
> Marc
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-25  6:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-24 19:31 [PATCH] cansniffer: increase resolution for timeout values Oliver Hartkopp
2014-06-24 19:39 ` Oliver Hartkopp
2014-06-24 21:20   ` Marc Kleine-Budde
2014-06-25  6:30     ` Oliver Hartkopp
2014-06-24 21:19 ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.