sum += h->data[i];
cum = sum;
for (i = 0; i < h->allocated; i++) {
- if (h->data[i] != 0)
- fprintf(f, "%d %lld\n", i*h->resolution, cum);
+ if (h->data[i] != 0) {
+ if (!getenv("CANPING_MS"))
+ fprintf(f, "%d %lld\n", i*h->resolution, cum);
+ else
+ fprintf(f, "%g %lld\n", 1e-3*(i*h->resolution), cum);
+ }
cum -= h->data[i];
}
}
struct canfilt_t canfilt; /* filter for received messages */
if (!option_open_once) {
- /* Open can driver */
- if(vca_open_handle(&vcah, option_device, NULL, 0) < 0) {
+ /* Open the CAN driver and disable (D) reception of
+ * all messages until we setup a filter below. */
+ if(vca_open_handle(&vcah, option_device, "D", 0) < 0) {
perror("open");
fprintf(stderr, "Error opening %s (for id %d)\n", option_device, ping_id);
exit(EXIT_CANNOT_OPEN);
int i;
snprintf(buf, sizeof(buf), "%s-%d.dat", option_save_all_times, ping_id);
f = fopen(buf, "w");
- for (i=0; i<option_count; i++)
- fprintf(f, "%u\n", td->times[i]);
+ for (i=0; i<option_count; i++) {
+ if (!getenv("CANPING_MS"))
+ fprintf(f, "%u\n", td->times[i]);
+ else
+ fprintf(f, "%g\n", 1e-3*td->times[i]);
+ }
fclose(f);
}
struct canfilt_t canfilt; /* filter for received messages */
if (!option_open_once) {
- /* Open the CAN driver */
- if(vca_open_handle(&vcah, option_device, NULL, 0) < 0) {
+ /* Open the CAN driver and disable (D) reception of
+ * all messages until we setup a filter below. */
+ if(vca_open_handle(&vcah, option_device, "D", 0) < 0) {
perror("open");
printf("Error opening %s (for id %d)\n", option_device, ping_id);
exit(EXIT_CANNOT_OPEN);