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 <alexander.stein@systec-electronic.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
pull/7/head
Oliver Hartkopp 2012-07-13 07:36:52 +02:00
parent 5d2964c5ff
commit 98930f1403
1 changed files with 3 additions and 3 deletions

View File

@ -132,7 +132,7 @@ void sigterm(int signo)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
unsigned long gap = DEFAULT_GAP; double gap = DEFAULT_GAP;
unsigned long polltimeout = 0; unsigned long polltimeout = 0;
unsigned char ignore_enobufs = 0; unsigned char ignore_enobufs = 0;
unsigned char extended = 0; unsigned char extended = 0;
@ -173,7 +173,7 @@ int main(int argc, char **argv)
break; break;
case 'g': case 'g':
gap = strtoul(optarg, NULL, 10); gap = strtod(optarg, NULL);
break; break;
case 'e': case 'e':
@ -251,7 +251,7 @@ int main(int argc, char **argv)
} }
ts.tv_sec = gap / 1000; ts.tv_sec = gap / 1000;
ts.tv_nsec = (gap % 1000) * 1000000; ts.tv_nsec = ((int)(gap * 1000000)) % 1000000000;
if (id_mode == MODE_FIX) { if (id_mode == MODE_FIX) {