mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-29 19:17:28 +08:00
[ocaml] print more verbose info on xml loading errors
This commit is contained in:
@@ -116,7 +116,7 @@ let new_fp = fun geomap editor_frame accel_group () ->
|
|||||||
createfp#grab_default ();
|
createfp#grab_default ();
|
||||||
ignore(createfp#connect#clicked ~callback:
|
ignore(createfp#connect#clicked ~callback:
|
||||||
begin fun _ ->
|
begin fun _ ->
|
||||||
let xml = Xml.parse_file fp_example in
|
let xml = ExtXml.parse_file fp_example in
|
||||||
let s = ExtXml.subst_attrib in
|
let s = ExtXml.subst_attrib in
|
||||||
let wgs84 = Latlong.of_string latlong#text in
|
let wgs84 = Latlong.of_string latlong#text in
|
||||||
let xml = s "lat0" (deg_string_of_rad wgs84.posn_lat) xml in
|
let xml = s "lat0" (deg_string_of_rad wgs84.posn_lat) xml in
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ let get_message = fun class_name msg_name ->
|
|||||||
|
|
||||||
(** Get the A/C id from its name in conf/conf.xml *)
|
(** Get the A/C id from its name in conf/conf.xml *)
|
||||||
let ac_id_of_name = fun ac_name ->
|
let ac_id_of_name = fun ac_name ->
|
||||||
let conf_xml = Xml.parse_file (conf_dir // "conf.xml") in
|
let conf_xml = ExtXml.parse_file (conf_dir // "conf.xml") in
|
||||||
try
|
try
|
||||||
let aircraft = ExtXml.child ~select:(fun x -> Xml.attrib x "name" = ac_name) conf_xml "aircraft" in
|
let aircraft = ExtXml.child ~select:(fun x -> Xml.attrib x "name" = ac_name) conf_xml "aircraft" in
|
||||||
ExtXml.int_attrib aircraft "ac_id"
|
ExtXml.int_attrib aircraft "ac_id"
|
||||||
@@ -140,7 +140,7 @@ let ac_id_of_name = fun ac_name ->
|
|||||||
(** Fill the index_of_settings table from var/AC/settings.xml *)
|
(** Fill the index_of_settings table from var/AC/settings.xml *)
|
||||||
let hash_index_of_settings = fun ac_name ->
|
let hash_index_of_settings = fun ac_name ->
|
||||||
let xml_file = Env.paparazzi_home // "var" // "aircrafts" // ac_name // "settings.xml" in
|
let xml_file = Env.paparazzi_home // "var" // "aircrafts" // ac_name // "settings.xml" in
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
let index = ref 0 in
|
let index = ref 0 in
|
||||||
let rec loop = fun xml ->
|
let rec loop = fun xml ->
|
||||||
if Xml.tag xml = "dl_settings" then
|
if Xml.tag xml = "dl_settings" then
|
||||||
@@ -155,7 +155,7 @@ let hash_index_of_settings = fun ac_name ->
|
|||||||
(** Fill the index_of_blocks table from var/aircrafts/AC/flight_plan.xml *)
|
(** Fill the index_of_blocks table from var/aircrafts/AC/flight_plan.xml *)
|
||||||
let hash_index_of_blocks = fun ac_name ->
|
let hash_index_of_blocks = fun ac_name ->
|
||||||
let xml_file = Env.paparazzi_home // "var" // "aircrafts" // ac_name // "flight_plan.xml" in
|
let xml_file = Env.paparazzi_home // "var" // "aircrafts" // ac_name // "flight_plan.xml" in
|
||||||
let dump = Xml.parse_file xml_file in
|
let dump = ExtXml.parse_file xml_file in
|
||||||
let flight_plan = ExtXml.child dump "flight_plan" in
|
let flight_plan = ExtXml.child dump "flight_plan" in
|
||||||
let blocks = ExtXml.child flight_plan "blocks" in
|
let blocks = ExtXml.child flight_plan "blocks" in
|
||||||
List.iter (fun block ->
|
List.iter (fun block ->
|
||||||
@@ -305,7 +305,7 @@ let trim_set = fun inputs value ->
|
|||||||
(** Input the trim file if it exists *)
|
(** Input the trim file if it exists *)
|
||||||
let parse_trim_file = fun trim_file_name inputs ->
|
let parse_trim_file = fun trim_file_name inputs ->
|
||||||
if Sys.file_exists trim_file_name then begin
|
if Sys.file_exists trim_file_name then begin
|
||||||
let trim = Xml.parse_file trim_file_name in
|
let trim = ExtXml.parse_file trim_file_name in
|
||||||
let trim_values = List.map
|
let trim_values = List.map
|
||||||
(fun x ->
|
(fun x ->
|
||||||
let axis = ExtXml.attrib x "axis"
|
let axis = ExtXml.attrib x "axis"
|
||||||
@@ -318,7 +318,7 @@ let parse_trim_file = fun trim_file_name inputs ->
|
|||||||
(** Parse the complete (input and messages) XML desxription
|
(** Parse the complete (input and messages) XML desxription
|
||||||
Also parses the trim xml file if it exists *)
|
Also parses the trim xml file if it exists *)
|
||||||
let parse_descr = fun xml_file trim_file ->
|
let parse_descr = fun xml_file trim_file ->
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
|
|
||||||
let inputs = parse_input (ExtXml.child xml "input")
|
let inputs = parse_input (ExtXml.child xml "input")
|
||||||
and messages_xml = ExtXml.child xml "messages"
|
and messages_xml = ExtXml.child xml "messages"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ let dl_id = "ground_dl" (* Hack, should be [my_id] *)
|
|||||||
|
|
||||||
let (//) = Filename.concat
|
let (//) = Filename.concat
|
||||||
let logs_path = Env.paparazzi_home // "var" // "logs"
|
let logs_path = Env.paparazzi_home // "var" // "logs"
|
||||||
let conf_xml = Xml.parse_file (Env.paparazzi_home // "conf" // "conf.xml")
|
let conf_xml = ExtXml.parse_file (Env.paparazzi_home // "conf" // "conf.xml")
|
||||||
let srtm_path = Env.paparazzi_home // "data" // "srtm"
|
let srtm_path = Env.paparazzi_home // "data" // "srtm"
|
||||||
|
|
||||||
let get_indexed_value = fun t i ->
|
let get_indexed_value = fun t i ->
|
||||||
@@ -451,7 +451,7 @@ let send_aircraft_msg = fun ac ->
|
|||||||
let replayed = fun ac_id ->
|
let replayed = fun ac_id ->
|
||||||
let n = String.length ac_id in
|
let n = String.length ac_id in
|
||||||
if n > 6 && String.sub ac_id 0 6 = "replay" then
|
if n > 6 && String.sub ac_id 0 6 = "replay" then
|
||||||
(true, String.sub ac_id 6 (n - 6), "/var/replay/", Xml.parse_file (Env.paparazzi_home // "var/replay/conf/conf.xml"))
|
(true, String.sub ac_id 6 (n - 6), "/var/replay/", ExtXml.parse_file (Env.paparazzi_home // "var/replay/conf/conf.xml"))
|
||||||
else
|
else
|
||||||
(false, ac_id, "", conf_xml)
|
(false, ac_id, "", conf_xml)
|
||||||
|
|
||||||
@@ -516,11 +516,11 @@ let new_aircraft = fun get_alive_md5sum real_id ->
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
let fp_file = var_aircraft_dir // "flight_plan.xml" in
|
let fp_file = var_aircraft_dir // "flight_plan.xml" in
|
||||||
let xml_fp = ExtXml.child (Xml.parse_file fp_file) "flight_plan" in
|
let xml_fp = ExtXml.child (ExtXml.parse_file fp_file) "flight_plan" in
|
||||||
|
|
||||||
let aircraft_conf_dir = var_aircraft_dir // "conf" in
|
let aircraft_conf_dir = var_aircraft_dir // "conf" in
|
||||||
let airframe_file = aircraft_conf_dir // ExtXml.attrib conf "airframe" in
|
let airframe_file = aircraft_conf_dir // ExtXml.attrib conf "airframe" in
|
||||||
let airframe_xml = Xml.parse_file airframe_file in
|
let airframe_xml = ExtXml.parse_file airframe_file in
|
||||||
|
|
||||||
if not is_replayed then
|
if not is_replayed then
|
||||||
check_md5sum real_id (get_alive_md5sum ()) aircraft_conf_dir;
|
check_md5sum real_id (get_alive_md5sum ()) aircraft_conf_dir;
|
||||||
@@ -533,7 +533,7 @@ let new_aircraft = fun get_alive_md5sum real_id ->
|
|||||||
|
|
||||||
ignore (Glib.Timeout.add 1000 (fun _ -> update (); true));
|
ignore (Glib.Timeout.add 1000 (fun _ -> update (); true));
|
||||||
|
|
||||||
let messages_xml = Xml.parse_file (Env.paparazzi_home // root_dir // "var" // "messages.xml") in
|
let messages_xml = ExtXml.parse_file (Env.paparazzi_home // root_dir // "var" // "messages.xml") in
|
||||||
ac, messages_xml
|
ac, messages_xml
|
||||||
|
|
||||||
let check_alerts = fun a ->
|
let check_alerts = fun a ->
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module Tele_Pprz = PprzLink.Messages(struct let name = "telemetry" end)
|
|||||||
|
|
||||||
let (//) = Filename.concat
|
let (//) = Filename.concat
|
||||||
let conf_dir = Env.paparazzi_home // "conf"
|
let conf_dir = Env.paparazzi_home // "conf"
|
||||||
let conf_xml = Xml.parse_file (conf_dir // "conf.xml")
|
let conf_xml = ExtXml.parse_file (conf_dir // "conf.xml")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ let one_ac = fun (notebook:GPack.notebook) ac_name ->
|
|||||||
Ground_Pprz.message_send "dl" "GET_DL_SETTING" vs in
|
Ground_Pprz.message_send "dl" "GET_DL_SETTING" vs in
|
||||||
|
|
||||||
(* Build the buttons and sliders *)
|
(* Build the buttons and sliders *)
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
let xmls = Xml.children (ExtXml.child xml "dl_settings") in
|
let xmls = Xml.children (ExtXml.child xml "dl_settings") in
|
||||||
let settings = new Page_settings.settings xmls callback ac_id Env.gcs_default_icons_theme (fun _ _ -> ()) in
|
let settings = new Page_settings.settings xmls callback ac_id Env.gcs_default_icons_theme (fun _ _ -> ()) in
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
type id = string
|
type id = string
|
||||||
|
|
||||||
let (//) = Filename.concat
|
let (//) = Filename.concat
|
||||||
let conf_xml = Xml.parse_file (Env.paparazzi_home // "conf" // "conf.xml")
|
let conf_xml = ExtXml.parse_file (Env.paparazzi_home // "conf" // "conf.xml")
|
||||||
|
|
||||||
open Geometry_2d
|
open Geometry_2d
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,7 @@ let filter_modules_target = fun module_file ->
|
|||||||
| [f; n] -> f, n
|
| [f; n] -> f, n
|
||||||
| _ -> module_file, ""
|
| _ -> module_file, ""
|
||||||
in
|
in
|
||||||
let module_xml = Xml.parse_file xml_file in
|
let module_xml = ExtXml.parse_file xml_file in
|
||||||
if Xml.tag module_xml = "module"
|
if Xml.tag module_xml = "module"
|
||||||
then
|
then
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -237,11 +237,11 @@ let my_xml_parse_file =
|
|||||||
let parse_file = fun ?(noprovedtd = false) file ->
|
let parse_file = fun ?(noprovedtd = false) file ->
|
||||||
try (if noprovedtd then my_xml_parse_file else Xml.parse_file) file
|
try (if noprovedtd then my_xml_parse_file else Xml.parse_file) file
|
||||||
with
|
with
|
||||||
| Xml.Error e -> failwith (sprintf "%s: %s" file (Xml.error e))
|
| Xml.Error e -> failwith (sprintf "XML error in %s: %s" file (Xml.error e))
|
||||||
| Xml.File_not_found f -> failwith (sprintf "File not found: %s" f)
|
| Xml.File_not_found f -> failwith (sprintf "File not found: %s" f)
|
||||||
| Dtd.Prove_error e -> failwith (sprintf "%s: %s" file (Dtd.prove_error e))
|
| Dtd.Prove_error e -> failwith (sprintf "DTD prove error in %s: %s" file (Dtd.prove_error e))
|
||||||
| Dtd.Check_error e -> failwith (sprintf "%s: %s" file (Dtd.check_error e))
|
| Dtd.Check_error e -> failwith (sprintf "DTD check error in %s: %s" file (Dtd.check_error e))
|
||||||
| Dtd.Parse_error e -> failwith (sprintf "%s: %s" file (Dtd.parse_error e))
|
| Dtd.Parse_error e -> failwith (sprintf "DTD parse error in %s: %s" file (Dtd.parse_error e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ let get_modules_dir = fun modules ->
|
|||||||
let is_element_unselected = fun ?(verbose=false) target modules name ->
|
let is_element_unselected = fun ?(verbose=false) target modules name ->
|
||||||
try
|
try
|
||||||
let name = (Env.paparazzi_home // "conf" // name) in
|
let name = (Env.paparazzi_home // "conf" // name) in
|
||||||
let xml = Xml.parse_file name in
|
let xml = ExtXml.parse_file name in
|
||||||
match Xml.tag xml with
|
match Xml.tag xml with
|
||||||
| "settings" ->
|
| "settings" ->
|
||||||
let targets = Xml.attrib xml "target" in
|
let targets = Xml.attrib xml "target" in
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ type msg_id = int
|
|||||||
let (//) = Filename.concat
|
let (//) = Filename.concat
|
||||||
|
|
||||||
let ubx_xml =
|
let ubx_xml =
|
||||||
lazy (Xml.parse_file (Env.paparazzi_src // "conf" // "ubx.xml"))
|
lazy (ExtXml.parse_file (Env.paparazzi_src // "conf" // "ubx.xml"))
|
||||||
|
|
||||||
let ubx_get_class = fun name ->
|
let ubx_get_class = fun name ->
|
||||||
let ubx_xml = Lazy.force ubx_xml in
|
let ubx_xml = Lazy.force ubx_xml in
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ let begin_out = fun xml_file h_name out ->
|
|||||||
fprintf out "#define %s\n\n" h_name
|
fprintf out "#define %s\n\n" h_name
|
||||||
|
|
||||||
let start_and_begin_out = fun xml_file h_name out ->
|
let start_and_begin_out = fun xml_file h_name out ->
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
begin_out xml_file h_name out;
|
begin_out xml_file h_name out;
|
||||||
xml
|
xml
|
||||||
|
|
||||||
let start_and_begin = fun xml_file h_name ->
|
let start_and_begin = fun xml_file h_name ->
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
begin_out xml_file h_name stdout;
|
begin_out xml_file h_name stdout;
|
||||||
xml
|
xml
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ let begin_c_out = fun xml_file name out ->
|
|||||||
fprintf out "#include \"%s.h\"\n\n" name
|
fprintf out "#include \"%s.h\"\n\n" name
|
||||||
|
|
||||||
let start_and_begin_c = fun xml_file name ->
|
let start_and_begin_c = fun xml_file name ->
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
begin_c_out xml_file name stdout;
|
begin_c_out xml_file name stdout;
|
||||||
xml
|
xml
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Nethtml.Element (_tag, _params, children) -> children
|
|||||||
|
|
||||||
(** Translate <tag .../> to <tag ...></tag> and parse *)
|
(** Translate <tag .../> to <tag ...></tag> and parse *)
|
||||||
let parse_file = fun file ->
|
let parse_file = fun file ->
|
||||||
ignore (Xml.parse_file file);
|
ignore (ExtXml.parse_file file);
|
||||||
let buff = Buffer.create 5
|
let buff = Buffer.create 5
|
||||||
and lookup = Buffer.create 5
|
and lookup = Buffer.create 5
|
||||||
and name = Buffer.create 5
|
and name = Buffer.create 5
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ let export_values = fun ?(sep="tab") ?(export_geo_pos=true) (model:GTree.tree_st
|
|||||||
|
|
||||||
(* Save preferences *)
|
(* Save preferences *)
|
||||||
let value = String.concat ";" (List.map (fun (msg, field) -> sprintf "%s:%s" msg field) !fields_to_export) in
|
let value = String.concat ";" (List.map (fun (msg, field) -> sprintf "%s:%s" msg field) !fields_to_export) in
|
||||||
let xml = if Sys.file_exists Env.gconf_file then Xml.parse_file Env.gconf_file else Xml.Element ("gconf", [], []) in
|
let xml = if Sys.file_exists Env.gconf_file then ExtXml.parse_file Env.gconf_file else Xml.Element ("gconf", [], []) in
|
||||||
let xml = ExtXml.Gconf.add_entry xml "log plotter" "to_export" value in
|
let xml = ExtXml.Gconf.add_entry xml "log plotter" "to_export" value in
|
||||||
let f = open_out Env.gconf_file in
|
let f = open_out Env.gconf_file in
|
||||||
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt xml);
|
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt xml);
|
||||||
@@ -232,7 +232,7 @@ let export_values = fun ?(sep="tab") ?(export_geo_pos=true) (model:GTree.tree_st
|
|||||||
let read_preferences = fun () ->
|
let read_preferences = fun () ->
|
||||||
if Sys.file_exists Env.gconf_file then
|
if Sys.file_exists Env.gconf_file then
|
||||||
try
|
try
|
||||||
let xml = Xml.parse_file Env.gconf_file in
|
let xml = ExtXml.parse_file Env.gconf_file in
|
||||||
let to_export = ExtXml.Gconf.get_value xml "to_export" in
|
let to_export = ExtXml.Gconf.get_value xml "to_export" in
|
||||||
let pairs = Str.split (Str.regexp ";") to_export in
|
let pairs = Str.split (Str.regexp ";") to_export in
|
||||||
List.map
|
List.map
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ let write_kml = fun plot log_name values ->
|
|||||||
|
|
||||||
let l = List.filter (fun (t,_,_) -> t_min <= t && t < t_max) values in
|
let l = List.filter (fun (t,_,_) -> t_min <= t && t < t_max) values in
|
||||||
|
|
||||||
let xml = Xml.parse_file sample_kml in
|
let xml = ExtXml.parse_file sample_kml in
|
||||||
let doc = ExtXml.child xml "Document" in
|
let doc = ExtXml.child xml "Document" in
|
||||||
let place = ExtXml.child doc "Placemark" in
|
let place = ExtXml.child doc "Placemark" in
|
||||||
let line = ExtXml.child place "LineString" in
|
let line = ExtXml.child place "LineString" in
|
||||||
@@ -657,7 +657,7 @@ let add_ac_submenu = fun ?(export=false) protocol ?(factor=object method text="1
|
|||||||
|
|
||||||
let load_log = fun ?export ?factor (plot:plot) (menubar:GMenu.menu_shell GMenu.factory) curves_fact xml_file ->
|
let load_log = fun ?export ?factor (plot:plot) (menubar:GMenu.menu_shell GMenu.factory) curves_fact xml_file ->
|
||||||
Debug.call 'p' (fun f -> fprintf f "load_log: %s\n" xml_file);
|
Debug.call 'p' (fun f -> fprintf f "load_log: %s\n" xml_file);
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
let data_file = ExtXml.attrib xml "data_file" in
|
let data_file = ExtXml.attrib xml "data_file" in
|
||||||
|
|
||||||
Debug.call 'p' (fun f -> fprintf f "data_file: %s\n" data_file);
|
Debug.call 'p' (fun f -> fprintf f "data_file: %s\n" data_file);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ let get_log_bounds = fun () ->
|
|||||||
|
|
||||||
|
|
||||||
let load_log = fun xml_file ->
|
let load_log = fun xml_file ->
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
let data_file = ExtXml.attrib xml "data_file" in
|
let data_file = ExtXml.attrib xml "data_file" in
|
||||||
|
|
||||||
let f = Ocaml_tools.find_file [Filename.dirname xml_file] data_file in
|
let f = Ocaml_tools.find_file [Filename.dirname xml_file] data_file in
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module U = Unix
|
|||||||
let (//) = Filename.concat
|
let (//) = Filename.concat
|
||||||
let var_path = Env.paparazzi_home // "var"
|
let var_path = Env.paparazzi_home // "var"
|
||||||
let default_logs_path = var_path // "logs"
|
let default_logs_path = var_path // "logs"
|
||||||
let conf_xml = Xml.parse_file (Env.paparazzi_home // "conf" // "conf.xml")
|
let conf_xml = ExtXml.parse_file (Env.paparazzi_home // "conf" // "conf.xml")
|
||||||
|
|
||||||
|
|
||||||
module Tm_Pprz = PprzLink.Messages (struct let name = "telemetry" end)
|
module Tm_Pprz = PprzLink.Messages (struct let name = "telemetry" end)
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ let (//) = Filename.concat
|
|||||||
let user_conf_path = Env.paparazzi_home // "conf"
|
let user_conf_path = Env.paparazzi_home // "conf"
|
||||||
let user_var_path = Env.paparazzi_home // "var"
|
let user_var_path = Env.paparazzi_home // "var"
|
||||||
|
|
||||||
let conf_xml = Xml.parse_file (user_conf_path // "conf.xml")
|
let conf_xml = ExtXml.parse_file (user_conf_path // "conf.xml")
|
||||||
|
|
||||||
let messages_ap =
|
let messages_ap =
|
||||||
let xml = Xml.parse_file (user_var_path // "messages.xml") in
|
let xml = ExtXml.parse_file (user_var_path // "messages.xml") in
|
||||||
try
|
try
|
||||||
ExtXml.child xml ~select:(fun x -> Xml.attrib x "name" = "telemetry") "msg_class"
|
ExtXml.child xml ~select:(fun x -> Xml.attrib x "name" = "telemetry") "msg_class"
|
||||||
with
|
with
|
||||||
@@ -65,9 +65,9 @@ let aircraft = fun name ->
|
|||||||
let airframe_file = user_conf_path // ExtXml.attrib aircraft_xml "airframe" in
|
let airframe_file = user_conf_path // ExtXml.attrib aircraft_xml "airframe" in
|
||||||
|
|
||||||
{ id = id; name = name;
|
{ id = id; name = name;
|
||||||
airframe = Xml.parse_file airframe_file;
|
airframe = ExtXml.parse_file airframe_file;
|
||||||
flight_plan = Xml.parse_file (user_conf_path // ExtXml.attrib aircraft_xml "flight_plan");
|
flight_plan = ExtXml.parse_file (user_conf_path // ExtXml.attrib aircraft_xml "flight_plan");
|
||||||
radio = Xml.parse_file (user_conf_path // ExtXml.attrib aircraft_xml "radio")
|
radio = ExtXml.parse_file (user_conf_path // ExtXml.attrib aircraft_xml "radio")
|
||||||
}
|
}
|
||||||
|
|
||||||
module type MISSION = sig val ac : aircraft end
|
module type MISSION = sig val ac : aircraft end
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ let get_entry_value = fun xml name ->
|
|||||||
Xml.attrib e "value"
|
Xml.attrib e "value"
|
||||||
|
|
||||||
let read_preferences = fun (gui:Gtk_pc.window) file (ac_combo:Gtk_tools.combo) (session_combo:Gtk_tools.combo) (target_combo:Gtk_tools.combo) ->
|
let read_preferences = fun (gui:Gtk_pc.window) file (ac_combo:Gtk_tools.combo) (session_combo:Gtk_tools.combo) (target_combo:Gtk_tools.combo) ->
|
||||||
let xml = Xml.parse_file file in
|
let xml = ExtXml.parse_file file in
|
||||||
|
|
||||||
let read_one = fun name use ->
|
let read_one = fun name use ->
|
||||||
try
|
try
|
||||||
@@ -81,7 +81,7 @@ let add_entry = fun xml name value ->
|
|||||||
|
|
||||||
|
|
||||||
let write_preferences = fun (gui:Gtk_pc.window) file (ac_combo:Gtk_tools.combo) (session_combo:Gtk_tools.combo) (target_combo:Gtk_tools.combo) ->
|
let write_preferences = fun (gui:Gtk_pc.window) file (ac_combo:Gtk_tools.combo) (session_combo:Gtk_tools.combo) (target_combo:Gtk_tools.combo) ->
|
||||||
let xml = if Sys.file_exists file then Xml.parse_file file else Xml.Element ("gconf", [], []) in
|
let xml = if Sys.file_exists file then ExtXml.parse_file file else Xml.Element ("gconf", [], []) in
|
||||||
|
|
||||||
(* Save A/C name *)
|
(* Save A/C name *)
|
||||||
let xml =
|
let xml =
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ let write_conf_xml = fun ?(user_save = false) () ->
|
|||||||
let l = Hashtbl.fold (fun _ a r -> a::r) Utils.aircrafts [] in
|
let l = Hashtbl.fold (fun _ a r -> a::r) Utils.aircrafts [] in
|
||||||
let l = List.sort (fun ac1 ac2 -> compare (Xml.attrib ac1 "name") (Xml.attrib ac2 "name")) l in
|
let l = List.sort (fun ac1 ac2 -> compare (Xml.attrib ac1 "name") (Xml.attrib ac2 "name")) l in
|
||||||
let c = Xml.Element ("conf", [], l) in
|
let c = Xml.Element ("conf", [], l) in
|
||||||
if c <> Xml.parse_file Utils.conf_xml_file then begin
|
if c <> ExtXml.parse_file Utils.conf_xml_file then begin
|
||||||
if not (Sys.file_exists Utils.backup_xml_file) then
|
if not (Sys.file_exists Utils.backup_xml_file) then
|
||||||
ignore (Sys.command (sprintf "cp %s %s" Utils.conf_xml_file Utils.backup_xml_file));
|
ignore (Sys.command (sprintf "cp %s %s" Utils.conf_xml_file Utils.backup_xml_file));
|
||||||
let f = open_out Utils.conf_xml_file in
|
let f = open_out Utils.conf_xml_file in
|
||||||
@@ -234,7 +234,7 @@ let parse_ac_targets = fun target_combo ac_file (log:string->unit) ->
|
|||||||
store#clear ();
|
store#clear ();
|
||||||
(* add targets *)
|
(* add targets *)
|
||||||
try
|
try
|
||||||
let af_xml = Xml.parse_file (Env.paparazzi_home // "conf" // ac_file) in
|
let af_xml = ExtXml.parse_file (Env.paparazzi_home // "conf" // ac_file) in
|
||||||
let targets = get_targets_list af_xml in
|
let targets = get_targets_list af_xml in
|
||||||
if List.length targets > 0 then
|
if List.length targets > 0 then
|
||||||
List.iter (fun t -> Gtk_tools.add_to_combo target_combo (Xml.attrib t "name")) targets
|
List.iter (fun t -> Gtk_tools.add_to_combo target_combo (Xml.attrib t "name")) targets
|
||||||
@@ -256,7 +256,7 @@ let parse_ac_flash = fun target flash_combo ac_file ->
|
|||||||
store#clear ();
|
store#clear ();
|
||||||
Gtk_tools.add_to_combo flash_combo "Default";
|
Gtk_tools.add_to_combo flash_combo "Default";
|
||||||
try
|
try
|
||||||
let af_xml = Xml.parse_file (Env.paparazzi_home // "conf" // ac_file) in
|
let af_xml = ExtXml.parse_file (Env.paparazzi_home // "conf" // ac_file) in
|
||||||
let targets = get_targets_list af_xml in
|
let targets = get_targets_list af_xml in
|
||||||
let board = Xml.attrib (List.find (fun t -> Xml.attrib t "name" = target) targets) "board" in
|
let board = Xml.attrib (List.find (fun t -> Xml.attrib t "name" = target) targets) "board" in
|
||||||
(* board names as regexp *)
|
(* board names as regexp *)
|
||||||
@@ -317,7 +317,7 @@ let ac_combo_handler = fun gui (ac_combo:Gtk_tools.combo) target_combo flash_com
|
|||||||
Xml.Element ("airframe", [], []);
|
Xml.Element ("airframe", [], []);
|
||||||
in
|
in
|
||||||
let fp_file = (Env.paparazzi_home // "conf" // (Xml.attrib aircraft "flight_plan")) in
|
let fp_file = (Env.paparazzi_home // "conf" // (Xml.attrib aircraft "flight_plan")) in
|
||||||
let fp_xml = Xml.parse_file fp_file in
|
let fp_xml = ExtXml.parse_file fp_file in
|
||||||
let settings_modules = try
|
let settings_modules = try
|
||||||
get_settings_modules af_xml fp_xml (ExtXml.attrib_or_default aircraft "settings_modules" "")
|
get_settings_modules af_xml fp_xml (ExtXml.attrib_or_default aircraft "settings_modules" "")
|
||||||
with
|
with
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ let group = fun l ->
|
|||||||
(* MAIN *)
|
(* MAIN *)
|
||||||
let () =
|
let () =
|
||||||
(* reading files *)
|
(* reading files *)
|
||||||
let xml = Xml.parse_file messages_xml in
|
let xml = ExtXml.parse_file messages_xml in
|
||||||
let messages =
|
let messages =
|
||||||
List.map (fun c -> ((Xml.attrib c "name"), Xml.children c)) (Xml.children xml)
|
List.map (fun c -> ((Xml.attrib c "name"), Xml.children c)) (Xml.children xml)
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ module Syntax = struct
|
|||||||
|
|
||||||
(** Translates one class of a XML message file into a list of messages *)
|
(** Translates one class of a XML message file into a list of messages *)
|
||||||
let read = fun filename class_ ->
|
let read = fun filename class_ ->
|
||||||
let xml = Xml.parse_file filename in
|
let xml = ExtXml.parse_file filename in
|
||||||
try
|
try
|
||||||
let xml_class = ExtXml.child ~select:(fun x -> Xml.attrib x "name" = class_) xml "msg_class" in
|
let xml_class = ExtXml.child ~select:(fun x -> Xml.attrib x "name" = class_) xml "msg_class" in
|
||||||
let msgs = List.map struct_of_xml (Xml.children xml_class) in
|
let msgs = List.map struct_of_xml (Xml.children xml_class) in
|
||||||
|
|||||||
@@ -266,8 +266,8 @@ let dump_firmware_sections = fun makefile_ac fp xml ->
|
|||||||
|
|
||||||
(** Extracts the makefile sections of an airframe file *)
|
(** Extracts the makefile sections of an airframe file *)
|
||||||
let extract_makefile = fun ac_id airframe_file flight_plan_file makefile_ac ->
|
let extract_makefile = fun ac_id airframe_file flight_plan_file makefile_ac ->
|
||||||
let xml = Xml.parse_file airframe_file in
|
let xml = ExtXml.parse_file airframe_file in
|
||||||
let fp = Xml.parse_file flight_plan_file in
|
let fp = ExtXml.parse_file flight_plan_file in
|
||||||
let f = open_out makefile_ac in
|
let f = open_out makefile_ac in
|
||||||
fprintf f "# This file has been generated by gen_aircraft from %s by %s\n"
|
fprintf f "# This file has been generated by gen_aircraft from %s by %s\n"
|
||||||
airframe_file Sys.executable_name;
|
airframe_file Sys.executable_name;
|
||||||
@@ -302,7 +302,7 @@ let () =
|
|||||||
failwith (sprintf "Usage: %s <Aircraft name> [conf.xml]" Sys.executable_name);
|
failwith (sprintf "Usage: %s <Aircraft name> [conf.xml]" Sys.executable_name);
|
||||||
let aircraft = Sys.argv.(1) in
|
let aircraft = Sys.argv.(1) in
|
||||||
let conf_xml = if Array.length Sys.argv = 3 then Sys.argv.(2) else default_conf_xml in
|
let conf_xml = if Array.length Sys.argv = 3 then Sys.argv.(2) else default_conf_xml in
|
||||||
let conf = Xml.parse_file conf_xml in
|
let conf = ExtXml.parse_file conf_xml in
|
||||||
check_unique_id_and_name conf conf_xml;
|
check_unique_id_and_name conf conf_xml;
|
||||||
let aircraft_xml =
|
let aircraft_xml =
|
||||||
try
|
try
|
||||||
@@ -336,7 +336,7 @@ let () =
|
|||||||
mkdir (aircraft_conf_dir // "telemetry");
|
mkdir (aircraft_conf_dir // "telemetry");
|
||||||
|
|
||||||
let target = try Sys.getenv "TARGET" with _ -> "" in
|
let target = try Sys.getenv "TARGET" with _ -> "" in
|
||||||
let modules = Gen_common.get_modules_of_config ~target (Xml.parse_file abs_airframe_file) (Xml.parse_file abs_flight_plan_file) in
|
let modules = Gen_common.get_modules_of_config ~target (ExtXml.parse_file abs_airframe_file) (Xml.parse_file abs_flight_plan_file) in
|
||||||
(* normal settings *)
|
(* normal settings *)
|
||||||
let settings = try Env.filter_settings (value "settings") with _ -> "" in
|
let settings = try Env.filter_settings (value "settings") with _ -> "" in
|
||||||
(* remove settings if not supported for the current target *)
|
(* remove settings if not supported for the current target *)
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ let rec parse_section = fun ac_id s ->
|
|||||||
printf "}\n\n";
|
printf "}\n\n";
|
||||||
| "include" ->
|
| "include" ->
|
||||||
let filename = Str.global_replace (Str.regexp "\\$AC_ID") ac_id (ExtXml.attrib s "href") in
|
let filename = Str.global_replace (Str.regexp "\\$AC_ID") ac_id (ExtXml.attrib s "href") in
|
||||||
let subxml = Xml.parse_file filename in
|
let subxml = ExtXml.parse_file filename in
|
||||||
printf "/* XML %s */" filename;
|
printf "/* XML %s */" filename;
|
||||||
nl ();
|
nl ();
|
||||||
List.iter (parse_section ac_id) (Xml.children subxml)
|
List.iter (parse_section ac_id) (Xml.children subxml)
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ let () =
|
|||||||
let modules =
|
let modules =
|
||||||
try
|
try
|
||||||
let target = Sys.getenv "TARGET" in
|
let target = Sys.getenv "TARGET" in
|
||||||
GC.get_modules_of_config ~target xml (Xml.parse_file fp_file)
|
GC.get_modules_of_config ~target xml (ExtXml.parse_file fp_file)
|
||||||
with
|
with
|
||||||
| Not_found -> failwith "TARTGET env needs to be specified to generate modules files"
|
| Not_found -> failwith "TARTGET env needs to be specified to generate modules files"
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ let _ =
|
|||||||
if Array.length Sys.argv < 2 then
|
if Array.length Sys.argv < 2 then
|
||||||
failwith "Usage: gen_radio xml_file";
|
failwith "Usage: gen_radio xml_file";
|
||||||
let xml_file = Sys.argv.(1) in
|
let xml_file = Sys.argv.(1) in
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
|
|
||||||
printf "/* This file has been generated by gen_radio from %s */\n" xml_file;
|
printf "/* This file has been generated by gen_radio from %s */\n" xml_file;
|
||||||
printf "/* Version %s */\n" (Env.get_paparazzi_version ());
|
printf "/* Version %s */\n" (Env.get_paparazzi_version ());
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ let join_xml_files = fun xml_files ->
|
|||||||
| [f; n] -> f, n
|
| [f; n] -> f, n
|
||||||
| _ -> xml_file, ""
|
| _ -> xml_file, ""
|
||||||
in
|
in
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = ExtXml.parse_file xml_file in
|
||||||
let these_rc_settings =
|
let these_rc_settings =
|
||||||
try Xml.children (ExtXml.child xml "rc_settings") with
|
try Xml.children (ExtXml.child xml "rc_settings") with
|
||||||
Not_found -> [] in
|
Not_found -> [] in
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ let () =
|
|||||||
(* reading file function *)
|
(* reading file function *)
|
||||||
let read_file_and_print = fun out area ->
|
let read_file_and_print = fun out area ->
|
||||||
try
|
try
|
||||||
let xml = Xml.parse_file (srtm_tmp_dir // area) in
|
let xml = ExtXml.parse_file (srtm_tmp_dir // area) in
|
||||||
prerr_endline (Printf.sprintf "parsing file %s" area);
|
prerr_endline (Printf.sprintf "parsing file %s" area);
|
||||||
let body = ExtXml.child xml "body" in
|
let body = ExtXml.child xml "body" in
|
||||||
let ul = ExtXml.child body "ul" in
|
let ul = ExtXml.child body "ul" in
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ let print_targets = fun outfile xml ->
|
|||||||
|
|
||||||
|
|
||||||
let parse_firmware_xml = fun firmware_xml firmware_wiki ->
|
let parse_firmware_xml = fun firmware_xml firmware_wiki ->
|
||||||
let xml = Xml.parse_file firmware_xml in
|
let xml = ExtXml.parse_file firmware_xml in
|
||||||
let f = open_out firmware_wiki in
|
let f = open_out firmware_wiki in
|
||||||
fprintf f " This file has been generated from %s\n" firmware_xml;
|
fprintf f " This file has been generated from %s\n" firmware_xml;
|
||||||
if ExtXml.tag_is xml "firmware" then begin
|
if ExtXml.tag_is xml "firmware" then begin
|
||||||
|
|||||||
Reference in New Issue
Block a user