Permalink
Browse files

Fix get functions to return values

  • Loading branch information...
mmontero committed May 9, 2011
1 parent ee807b8 commit 9637d54f84cf14069c574763824854eb4f46e1f4
Showing with 40 additions and 28 deletions.
  1. +13 −7 src/cli_mt9p031.vala
  2. +7 −7 src/ipipe-client.vala
  3. +20 −14 src/ipiped-mt9p031.vala
View
@@ -3,10 +3,11 @@ using GLib;
public interface Imt9p031: Object{
public abstract int set_sensor_gain(double r_gain, double g_gain,
double b_gain) throws IOError;
- public abstract int get_sensor_gain() throws IOError;
+ public abstract bool get_sensor_gain(out double _red_gain,
+ out double blue_gain, out double green_gain) throws IOError;
public abstract int sensor_flip_vertically(string state) throws IOError;
public abstract int sensor_flip_horizontally(string state) throws IOError;
- public abstract int get_exposure_time() throws IOError;
+ public abstract bool get_exposure_time(out int exp_time) throws IOError;
public abstract int set_exposure_time(int _exp_time) throws IOError;
}
@@ -53,11 +54,15 @@ public class cli_mt9p031 : AbstcCliRegister{
public int cmd_get_sensor_gain( string[]? args) {
try {
- int ret = sensor.get_sensor_gain();
- if (ret != 0) {
- stderr.printf("Error:\n Failed to get sensor gain\n");
+ double red_gain = 0, green_gain = 0, blue_gain = 0;
+
+ if (!sensor.get_sensor_gain(out red_gain,
+ out green_gain, out blue_gain)) {
+ stderr.printf("Error:\n Failed to get the sensor gain\n");
return -1;
} else {
+ Posix.stdout.printf("Sensor gain: R=%f G=%f B=%f\n",
+ red_gain,green_gain,blue_gain);
if (_debug)
stdout.printf("Ok.Get sensor gain\n");
return 0;
@@ -141,11 +146,12 @@ public class cli_mt9p031 : AbstcCliRegister{
public int cmd_get_exposure_time( string[]? args) {
try {
- int ret = sensor.get_exposure_time();
- if (ret != 0) {
+ int exp_time = 0;
+ if (!sensor.get_exposure_time(out exp_time)) {
stderr.printf("Error:\n Failed to set exposure time\n");
return -1;
} else {
+ stdout.printf("Exposure time: %u\n", exp_time);
if (_debug)
stdout.printf("Ok.Get exposure time\n");
return 0;
View
@@ -163,7 +163,7 @@ public class IpipeCli: GLib.Object {
}
private int cli_run_config_script(string[]? args) {
- string dir ="usr/share/ipiped/";
+ string dir ="/usr/share/ipiped/";
string data, filename;
if (args[1] == null) {
Posix.stdout.printf("Error:\nMissing argument.Execute:'help <command>'\n");
@@ -201,12 +201,12 @@ public class IpipeCli: GLib.Object {
}
i++;
}
- int wait_time = args[5].to_int();
- int min_fps = args[6].to_int();
- int width = args[8].to_int();
- int height = args[9].to_int();
- int segment_factor = args[7].to_int();
- int center_percentage = args[10].to_int();
+ int wait_time = int.parse(args[5]);
+ int min_fps = int.parse(args[6]);
+ int width = int.parse(args[8]);
+ int height = int.parse(args[9]);
+ int segment_factor = int.parse(args[7]);
+ int center_percentage = int.parse(args[10]);
try {
int ret = ipipe.init_aew(args[1], args[2], args[3], args[4], wait_time,
min_fps, segment_factor, width, height, center_percentage);
View
@@ -153,21 +153,24 @@ public class Ipiped_mt9p031 : AbstcSensor{
* Use the get_sensor_gain_i function to obtain the RGB sensor gains
* and print them
*/
- public int get_sensor_gain() throws IOError{
+ public bool get_sensor_gain(out double _red_gain, out double _green_gain,
+ out double _blue_gain) throws IOError{
uint32 q10red_gain=0,q10green_gain=0,q10blue_gain=0;
if (this.capture_fd < 0){
if (open_sensor() < 0)
- return -1;
+ return false;
}
if (get_sensor_gain_i(&this.capture_fd, &this.owner_capture_fd,
- &q10red_gain, &q10green_gain, &q10blue_gain)<0){
- return -1;
+ &q10red_gain, &q10green_gain, &q10blue_gain) != 0) {
+ Posix.stderr.printf("Error:\n Failed to get the sensor gain\n");
+ return false;
+ } else {
+ _red_gain = ((double)(q10red_gain))/1024;
+ _green_gain= ((double)(q10green_gain))/1024;
+ _blue_gain = ((double)(q10blue_gain))/1024;
+ return true;
}
- Posix.stdout.printf("Set gain to R=%f G=%f B=%f\n",
- (float)(q10red_gain)/1024, (float)(q10green_gain)/1024,
- (float)(q10blue_gain)/1024);
- return 0;
}
/**
@@ -290,15 +293,18 @@ public class Ipiped_mt9p031 : AbstcSensor{
}
- public int get_exposure_time() throws IOError{
- uint32 exp_time = 0;
+ public bool get_exposure_time(out int exp_time) throws IOError{
if (this.capture_fd < 0){
if (open_sensor() < 0)
- return -1;
+ return false;
}
- get_exposure_time_i(&this.capture_fd, &this.owner_capture_fd, &exp_time);
- Posix.stdout.printf("Exposure time: %u\n", exp_time);
- return 0;
+
+ if (get_exposure_time_i(&this.capture_fd, &this.owner_capture_fd, &exp_time) != 0) {
+ Posix.stderr.printf("Error:\n Failed to get the exposure time\n");
+ return false;
+ }
+
+ return true;
}
#if (RRAEW)

0 comments on commit 9637d54

Please sign in to comment.