Exemple #1
0
/* function: getting some systems informations
 * return: nothing, yust fill the struct statistics
 */
int get_sysinfos(void)
{
    // getting the hostname
    statistics.hostname=Strdup(read_hostname());
    // the revision of the image
    statistics.rev=Strdup(read_hardware(1));
    // the vendor + model
    statistics.vendor=Strdup(read_hardware(2));
    // the uptime
    statistics.uptime=Strdup(get_uptime());
    // the kernel version
    statistics.kernel=Strdup(kernelversion());
    // the CPU version
    statistics.cpu=Strdup(get_cpuinfo());
    return 0;
}
Exemple #2
0
// 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, &current_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;
}
Exemple #3
0
// 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;
}
Exemple #4
0
// read the xml file
int read_xml(){
	
	init_config();

	debug_printf ("Reading hardware element...\n");	

	// read the hardaware element
	if (read_hardware() != 0){
		return -1;	
	}
	debug_printf ("OK\n");	

	// read the kernel element	
	if (read_kernel() != 0){
		return -1;	
	}

	// read the ports element
	if (read_ports() != 0){
		return -1;	
	}

	// read the partitions element
	if (read_partitions() != 0){
		return -1;	
	}

	// check if every port has been assigned to a partition
	int i;
	for (i=0; i<nb_ports; i++){
		if (ports[i].partition_id == -1){
			printf("WARNING: port %d has not been assigned to any partition!\n",ports[i].user_port_id);
		}	
	}

	return 0;

}