@@ -10,12 +10,12 @@ namespace ev3dev
10
10
11
11
public class Device : GLib .Object
12
12
{
13
- string device_root { get ; protected set ; }
13
+ public string device_root { get ; protected set ; }
14
14
public bool connected { get ; protected set ; }
15
15
16
16
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" ;
19
19
20
20
public Device ()
21
21
{
@@ -54,9 +54,10 @@ namespace ev3dev
54
54
var input_stream = new DataInputStream (file. read());
55
55
result = input_stream. read_line();
56
56
}
57
- catch (GLib . Error error)
57
+ catch (Error error)
58
58
{
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);
60
61
}
61
62
62
63
return result;
@@ -76,13 +77,17 @@ namespace ev3dev
76
77
77
78
try
78
79
{
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 ));
81
84
out_stream. put_string(value );
85
+ out_stream. flush();
82
86
}
83
- catch (Error e )
87
+ catch (Error error )
84
88
{
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);
86
91
}
87
92
}
88
93
}
0 commit comments