Esempio n. 1
0
void h8_adc_device::sampling()
{
	if(mode & COUNTED)
		channel = get_channel_index(start_count - count);
	if(mode & DUAL) {
		buffer_value(channel, 0);
		buffer_value(channel+1, 1);
	} else
		buffer_value(channel);
}
Esempio n. 2
0
// Run a test command, and store the result in two separate strings
//
// Example:
//   out, err, rc, major, minor = target.test_and_store_results_separately("find /etc -type l", "nobody")
// Input:
//   command: the command to run
//   user: the user under which to run the command
//         (optional, defaults to "root")
//   timeout: the time in seconds after which the command is aborted 
//            (optional, defaults to 60L)
// Output:
//   out: the standard output of the command
//   err: the standard error of the command
//   rc: the return code of the testing platform
//   major: the return code of the system under test
//   minor: the return code of the command
VALUE method_test_and_store_results_separately(VALUE self, VALUE ruby_args)
{
  long len;
  VALUE ruby_command,
        ruby_user,
        ruby_timeout;
  struct twopence_target *target;
  twopence_buf_t stdout_buf, stderr_buf;
  twopence_status_t status;
  int rc;

  Check_Type(ruby_args, T_ARRAY);
  len = RARRAY_LEN(ruby_args);
  if (len < 1 || len > 3)
    rb_raise(rb_eArgError, "wrong number of arguments");
  ruby_command = rb_ary_entry(ruby_args, 0);
  if (len >= 2)
  {
    ruby_user = rb_ary_entry(ruby_args, 1);
    Check_Type(ruby_user, T_STRING);
  }
  else ruby_user = rb_str_new2("root");
  if (len >= 3)
  {
    ruby_timeout = rb_ary_entry(ruby_args, 2);
    Check_Type(ruby_timeout, T_FIXNUM);
  }
  else ruby_timeout = LONG2NUM(60L);
  Data_Get_Struct(self, struct twopence_target, target);

  twopence_buf_init(&stdout_buf);
  twopence_buf_init(&stderr_buf);
  twopence_buf_resize(&stdout_buf, 65536);
  twopence_buf_resize(&stderr_buf, 65536);

  rc = twopence_test_and_store_results_separately(target,
         StringValueCStr(ruby_user), NUM2LONG(ruby_timeout), StringValueCStr(ruby_command),
         &stdout_buf, &stderr_buf, &status);

  return rb_ary_new3(5,
                     buffer_value(&stdout_buf),
                     buffer_value(&stderr_buf),
                     INT2NUM(rc), INT2NUM(status.major), INT2NUM(status.minor));
}
Esempio n. 3
0
static void uemis_weight_unit(char *buffer, void *_unused)
{
	input_units.weight = buffer_value(buffer) ? LBS : KG;
}
Esempio n. 4
0
static void uemis_temperature_unit(char *buffer, void *_unused)
{
	input_units.temperature = buffer_value(buffer) ? FAHRENHEIT : CELSIUS;
}
Esempio n. 5
0
static void uemis_pressure_unit(char *buffer, void *_unused)
{
#if 0
	input_units.pressure = buffer_value(buffer) ? PSI : BAR;
#endif
}
Esempio n. 6
0
static void uemis_volume_unit(char *buffer, void *_unused)
{
	input_units.volume = buffer_value(buffer) ? CUFT : LITER;
}
Esempio n. 7
0
static void uemis_length_unit(char *buffer, void *_unused)
{
	input_units.length = buffer_value(buffer) ? FEET : METERS;
}