blocking console logging problem fixed

This commit is contained in:
Pascal Brisset
2007-07-13 20:20:20 +00:00
parent 738230acf3
commit 79cb28d9bc
4 changed files with 20 additions and 5 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ TOOLS=$(PAPARAZZI_SRC)/sw/tools
ARMGCC=/usr/bin/arm-elf-gcc ARMGCC=/usr/bin/arm-elf-gcc
all: static all: static conf
static : lib center tools cockpit visu3d multimon tmtc logalizer lpc21iap sim_static static_h usb_lib static : lib center tools cockpit visu3d multimon tmtc logalizer lpc21iap sim_static static_h usb_lib
-2
View File
@@ -91,8 +91,6 @@ let () =
let iter = gui#console#buffer#end_iter in let iter = gui#console#buffer#end_iter in
let tags = compute_tags s in let tags = compute_tags s in
gui#console#buffer#insert ~iter ~tags s; gui#console#buffer#insert ~iter ~tags s;
let iter = gui#console#buffer#end_iter in
gui#console#buffer#insert ~iter "\n";
(* Scroll to the bottom line *) (* Scroll to the bottom line *)
let end_iter = gui#console#buffer#end_iter in let end_iter = gui#console#buffer#end_iter in
let end_mark = gui#console#buffer#create_mark end_iter in let end_mark = gui#console#buffer#create_mark end_iter in
+18 -1
View File
@@ -37,12 +37,29 @@ let my_open_process_in = fun cmd ->
Unix.close in_write; Unix.close in_write;
pid, inchan pid, inchan
let buf_size = 128
let run_and_log = fun log com -> let run_and_log = fun log com ->
let com = com ^ " 2>&1" in let com = com ^ " 2>&1" in
let pid, com_stdout = my_open_process_in com in let pid, com_stdout = my_open_process_in com in
let channel_out = GMain.Io.channel_of_descr (Unix.descr_of_in_channel com_stdout) in let channel_out = GMain.Io.channel_of_descr (Unix.descr_of_in_channel com_stdout) in
let cb = fun ev -> if List.mem `IN ev then begin log (input_line com_stdout); true end else begin log (sprintf "\nDONE (%s)\n" com); false end in let cb = fun ev ->
if List.mem `IN ev then begin
let buf = String.create buf_size in
let rec loop = fun () ->
let n = input com_stdout buf 0 buf_size in
if n < buf_size then
log (String.sub buf 0 n)
else begin
log buf;
loop ()
end in
loop ();
true
end else begin
log (sprintf "\nDONE (%s)\n\n" com);
false
end in
let _io_watch_out = Glib.Io.add_watch [`IN; `HUP] cb channel_out in let _io_watch_out = Glib.Io.add_watch [`IN; `HUP] cb channel_out in
pid, channel_out pid, channel_out
+1 -1
View File
@@ -77,7 +77,7 @@ let run_and_monitor = fun ?file ?(plugged=false) gui log com_name args ->
let c = if plugged then sprintf "%s -wid 0x%lx" c !socket_GCS_id else c in let c = if plugged then sprintf "%s -wid 0x%lx" c !socket_GCS_id else c in
if plugged then if plugged then
gui#notebook#goto_page 2; (* FIXME *) gui#notebook#goto_page 2; (* FIXME *)
log (sprintf "Run '%s'" c); log (sprintf "Run '%s'\n" c);
let (pi, out) = run_and_log log ("exec "^c) in let (pi, out) = run_and_log log ("exec "^c) in
pid := pi; pid := pi;
ignore (Glib.Io.add_watch [`HUP] (fun _ -> callback true; false) out) in ignore (Glib.Io.add_watch [`HUP] (fun _ -> callback true; false) out) in