From: Jérémie D. <Ba...@us...> - 2011-03-19 17:11:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 2c65274daf59dc657959b6cc7b3bc400e3779c7c (commit) from cb716f5381d356396981452c97ed398603a58265 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2c65274daf59dc657959b6cc7b3bc400e3779c7c Author: Jérémie Dimino <je...@di...> Date: Sat Mar 19 17:52:29 2011 +0100 [info] add two tools to forward the D-Bus connection ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index b85b498..93f2fed 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -90,6 +90,20 @@ Executable "krobot-replay" MainIs: krobot_replay.ml BuildDepends: krobot, lwt.syntax +Executable "krobot-remote" + Path: src/tools + Install: true + CompiledObject: best + MainIs: krobot_remote.ml + BuildDepends: krobot, lwt.syntax + +Executable "krobot-local" + Path: src/tools + Install: true + CompiledObject: best + MainIs: krobot_local.ml + BuildDepends: krobot, lwt.syntax + Executable "krobot-plot" Path: src/tools Install: true diff --git a/info/control2011/_tags b/info/control2011/_tags index 9c6da6c..c48d120 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: 404e613a369861087dfd1cb3215a1db4) +# DO NOT EDIT (digest: 3f2673f16efc8fd23f421702ae380100) # Library krobot-interfaces "src/interfaces": include <src/interfaces/*.ml{,i}>: pkg_obus @@ -44,6 +44,12 @@ <src/driver/*.ml{,i}>: pkg_obus <src/driver/*.ml{,i}>: pkg_lwt.unix <src/driver/*.ml{,i}>: pkg_lwt.syntax +# Executable krobot-remote +<src/tools/krobot_remote.{native,byte}>: use_krobot +<src/tools/krobot_remote.{native,byte}>: use_krobot-interfaces +<src/tools/krobot_remote.{native,byte}>: pkg_obus +<src/tools/krobot_remote.{native,byte}>: pkg_lwt.unix +<src/tools/krobot_remote.{native,byte}>: pkg_lwt.syntax # Executable krobot-replay <src/tools/krobot_replay.{native,byte}>: use_krobot <src/tools/krobot_replay.{native,byte}>: use_krobot-interfaces @@ -63,6 +69,12 @@ <examples/*.ml{,i}>: pkg_obus <examples/*.ml{,i}>: pkg_lwt.unix <examples/*.ml{,i}>: pkg_lwt.syntax +# Executable krobot-local +<src/tools/krobot_local.{native,byte}>: use_krobot +<src/tools/krobot_local.{native,byte}>: use_krobot-interfaces +<src/tools/krobot_local.{native,byte}>: pkg_obus +<src/tools/krobot_local.{native,byte}>: pkg_lwt.unix +<src/tools/krobot_local.{native,byte}>: pkg_lwt.syntax # Executable krobot-record <src/tools/krobot_record.{native,byte}>: use_krobot <src/tools/krobot_record.{native,byte}>: use_krobot-interfaces diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 3e81a39..523013d 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: c0061e3e8da638912d5008f7a294c616) *) +(* DO NOT EDIT (digest: c9d539f09d0003ab7eefa01ee368b5d6) *) (* Regenerated by OASIS v0.2.0 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5244,6 +5244,33 @@ let setup_t = {exec_custom = false; exec_main_is = "krobot_driver.ml"; }); Executable ({ + cs_name = "krobot-remote"; + cs_data = PropList.Data.create (); + cs_plugin_data = []; + }, + { + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, true)]; + bs_path = "src/tools"; + bs_compiled_object = Best; + bs_build_depends = + [ + InternalLibrary "krobot"; + FindlibPackage ("lwt.syntax", None) + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = []; + bs_data_files = []; + bs_ccopt = [(OASISExpr.EBool true, [])]; + bs_cclib = [(OASISExpr.EBool true, [])]; + bs_dlllib = [(OASISExpr.EBool true, [])]; + bs_dllpath = [(OASISExpr.EBool true, [])]; + bs_byteopt = [(OASISExpr.EBool true, [])]; + bs_nativeopt = [(OASISExpr.EBool true, [])]; + }, + {exec_custom = false; exec_main_is = "krobot_remote.ml"; }); + Executable + ({ cs_name = "krobot-replay"; cs_data = PropList.Data.create (); cs_plugin_data = []; @@ -5298,6 +5325,33 @@ let setup_t = {exec_custom = false; exec_main_is = "dump_can.ml"; }); Executable ({ + cs_name = "krobot-local"; + cs_data = PropList.Data.create (); + cs_plugin_data = []; + }, + { + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, true)]; + bs_path = "src/tools"; + bs_compiled_object = Best; + bs_build_depends = + [ + InternalLibrary "krobot"; + FindlibPackage ("lwt.syntax", None) + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = []; + bs_data_files = []; + bs_ccopt = [(OASISExpr.EBool true, [])]; + bs_cclib = [(OASISExpr.EBool true, [])]; + bs_dlllib = [(OASISExpr.EBool true, [])]; + bs_dllpath = [(OASISExpr.EBool true, [])]; + bs_byteopt = [(OASISExpr.EBool true, [])]; + bs_nativeopt = [(OASISExpr.EBool true, [])]; + }, + {exec_custom = false; exec_main_is = "krobot_local.ml"; }); + Executable + ({ cs_name = "krobot-record"; cs_data = PropList.Data.create (); cs_plugin_data = []; diff --git a/info/control2011/src/tools/krobot_local.ml b/info/control2011/src/tools/krobot_local.ml new file mode 100644 index 0000000..0983e32 --- /dev/null +++ b/info/control2011/src/tools/krobot_local.ml @@ -0,0 +1,30 @@ +(* + * krobot_local.ml + * --------------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +open Lwt + +let rec copy ta tb = + lwt msg = OBus_transport.recv ta in + lwt () = OBus_transport.send tb msg in + copy ta tb + +lwt () = + lwt (_, ta) = OBus_transport.of_addresses [OBus_address.make "unix" [("abstract", "krobot")]] in + lwt () = Lwt_io.write_char Lwt_io.stdout ' ' in + let tb = + OBus_transport.make + ~send:(fun msg -> OBus_wire.write_message Lwt_io.stdout msg) + ~recv:(fun () -> OBus_wire.read_message Lwt_io.stdin) + ~shutdown:return + () + in + try_lwt + copy ta tb <&> copy tb ta + with End_of_file -> + return () diff --git a/info/control2011/src/tools/krobot_remote.ml b/info/control2011/src/tools/krobot_remote.ml new file mode 100644 index 0000000..c66de43 --- /dev/null +++ b/info/control2011/src/tools/krobot_remote.ml @@ -0,0 +1,48 @@ +(* + * krobot_remote.ml + * ---------------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +open Lwt + +let rec copy ta tb = + lwt msg = OBus_transport.recv ta in + lwt () = OBus_transport.send tb msg in + copy ta tb + +let handle_connection server ta = + ignore ( + let process = Lwt_process.open_process ("ssh", [|"ssh"; "krobot"; "krobot-local"|]) in + try_lwt + lwt _ = Lwt_io.read_char process#stdout in + let tb = + OBus_transport.make + ~send:(fun msg -> OBus_wire.write_message process#stdin msg) + ~recv:(fun () -> OBus_wire.read_message process#stdout) + ~shutdown:(fun () -> process#close >> return ()) + () + in + ignore ( + try_lwt + copy ta tb <&> copy tb ta + with exn -> + OBus_transport.shutdown ta <&> OBus_transport.shutdown tb + ); + return () + with exn -> + lwt _ = process#close and () = OBus_transport.shutdown ta in + lwt () = Lwt_log.error_f ~exn "failed to open connection" in + return () + ) + +lwt () = + lwt server = + OBus_server.make_lowlevel + ~addresses:[OBus_address.make "unix" [("abstract", "krobot")]] + handle_connection + in + fst (wait ()) hooks/post-receive -- krobot |