// do communication cycle uint64_t HI_moxa::write_read_hardware(long int nsec, int timeouts_to_print) { struct timespec start_time, current_time, read_time; clock_gettime(CLOCK_MONOTONIC, &start_time); uint64_t ret; if ((ret = write_hardware()) != 0) { clock_gettime(CLOCK_MONOTONIC, ¤t_time); long int current_delay = (current_time.tv_sec - start_time.tv_sec) * 1000000000 + (current_time.tv_nsec - start_time.tv_nsec); if (current_delay > longest_delay_) { longest_delay_ = current_delay; // std::cout << std::dec << "longest_delay_: " << longest_delay_ << std::endl; } struct timespec delay; delay.tv_nsec = nsec; delay.tv_sec = 0; // clock_nanosleep(CLOCK_MONOTONIC,0, &delay, NULL); nanosleep(&delay, NULL); // std::cout << std::dec << "longest_delay_: " << longest_delay_ << std::endl; /* hi_sleep(nsec); */ ret = read_hardware(timeouts_to_print); clock_gettime(CLOCK_MONOTONIC, &read_time); long int read_delay = (read_time.tv_sec - current_time.tv_sec) * 1000000000 + (read_time.tv_nsec - current_time.tv_nsec); if (read_delay > longest_read_delay_) { longest_read_delay_ = read_delay; // std::cout << std::dec << "longest_read_delay_: " << longest_read_delay_ << std::endl; } } // std::cout <<"write_read_hardware ret: " << ret << std::endl; return ret; }
// do communication cycle uint64_t HI_moxa::write_read_hardware(void) { uint64_t ret; if ((ret = write_hardware()) != 0) { struct timespec delay; delay.tv_nsec = 1000000; delay.tv_sec = 0; nanosleep(&delay, NULL); ret = read_hardware(); } // std::cout <<"write_read_hardware ret: " << ret << std::endl; return ret; }
//after ransdomization.... non_virtual void start_ () { out_of_reset (); write_hardware (); run_traffic (); }