Skip to content

Commit f9ca4fe

Browse files
committed
Fix some small errors in vala binding
1 parent 8884761 commit f9ca4fe

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

vala/ev3dev-lib.vala

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ namespace ev3dev
1010

1111
public class Device : GLib.Object
1212
{
13-
string device_root { get; protected set; }
13+
public string device_root { get; protected set; }
1414
public bool connected { get; protected set; }
1515

1616
private string connect_error = "You must connect to a device before you can read from it.";
17-
private string read_error = "There was an error reading from the file.";
18-
private string write_error = "There was an error writing to the file.";
17+
private string read_error = "There was an error reading from the file";
18+
private string write_error = "There was an error writing to the file";
1919

2020
public Device()
2121
{
@@ -54,9 +54,10 @@ namespace ev3dev
5454
var input_stream = new DataInputStream(file.read());
5555
result = input_stream.read_line();
5656
}
57-
catch (GLib.Error error)
57+
catch (Error error)
5858
{
59-
throw new DeviceError.IO_ERROR(this.read_error + ": " + error.message + ": \"" + this.construct_property_path(property) + "\"");
59+
this.connected = false;
60+
throw new DeviceError.IO_ERROR(this.read_error + ": " + error.message);
6061
}
6162

6263
return result;
@@ -76,13 +77,17 @@ namespace ev3dev
7677

7778
try
7879
{
79-
var file = File.new_for_path(this.construct_property_path(property));
80-
var out_stream = new DataOutputStream(new BufferedOutputStream.sized(file.open_readwrite().output_stream, 256));
80+
string property_path = this.construct_property_path(property);
81+
var file = File.new_for_path(property_path);
82+
var read_write_stream = file.open_readwrite();
83+
var out_stream = new DataOutputStream(new BufferedOutputStream.sized(read_write_stream.output_stream, 256));
8184
out_stream.put_string(value);
85+
out_stream.flush();
8286
}
83-
catch (Error e)
87+
catch (Error error)
8488
{
85-
throw new DeviceError.IO_ERROR(this.write_error + ": " + e.message);
89+
this.connected = false;
90+
throw new DeviceError.IO_ERROR(this.write_error + ": " + error.message);
8691
}
8792
}
8893
}

0 commit comments

Comments
 (0)