From 98930f140335c73d0689af8a5717fd89239cec6f Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Fri, 13 Jul 2012 07:36:52 +0200 Subject: [PATCH] cangen: allow double value for gap This way a user can specify a gap below 1ms. This is somehwat similar to setting the gap to 0, but the ENOBUFS are greatly reduced, so a given amount of CAN messages by -n is still usefull and useable. Signed-off-by: Alexander Stein Signed-off-by: Oliver Hartkopp --- cangen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cangen.c b/cangen.c index 20cc921..4f37808 100644 --- a/cangen.c +++ b/cangen.c @@ -132,7 +132,7 @@ void sigterm(int signo) int main(int argc, char **argv) { - unsigned long gap = DEFAULT_GAP; + double gap = DEFAULT_GAP; unsigned long polltimeout = 0; unsigned char ignore_enobufs = 0; unsigned char extended = 0; @@ -173,7 +173,7 @@ int main(int argc, char **argv) break; case 'g': - gap = strtoul(optarg, NULL, 10); + gap = strtod(optarg, NULL); break; case 'e': @@ -251,7 +251,7 @@ int main(int argc, char **argv) } ts.tv_sec = gap / 1000; - ts.tv_nsec = (gap % 1000) * 1000000; + ts.tv_nsec = ((int)(gap * 1000000)) % 1000000000; if (id_mode == MODE_FIX) {