From: Jérémie D. <Ba...@us...> - 2011-03-11 21:38:03
|
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 3846984ca2ae71b7c36fed298726cdef90f60080 (commit) from 027ff5fb5214579002885946f570f0993057a35c (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 3846984ca2ae71b7c36fed298726cdef90f60080 Author: Jérémie Dimino <je...@di...> Date: Fri Mar 11 22:37:19 2011 +0100 Add an example which dumps can frames. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index 3a26ca3..91ee771 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -38,6 +38,17 @@ Library can CSources: can_stubs.c # +-------------------------------------------------------------------+ +# | Examples | +# +-------------------------------------------------------------------+ + +Executable "dump-can" + Path: examples + Install: false + CompiledObject: best + MainIs: dump_can.ml + BuildDepends: krobot.can + +# +-------------------------------------------------------------------+ # | Doc | # +-------------------------------------------------------------------+ diff --git a/info/control2011/_tags b/info/control2011/_tags index ce45b27..2e33d60 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -1,7 +1,7 @@ <**/*.ml>: syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: d603b4bf64803246215300604de4811c) +# DO NOT EDIT (digest: 113a86794ede4d5625a352637c66e020) # Library can "src/can": include <src/can/can.{cma,cmxa}>: use_libcan @@ -13,4 +13,11 @@ "src/lib": include <src/lib/*.ml{,i}>: pkg_lwt.unix <src/lib/*.ml{,i}>: pkg_lwt.syntax +# Executable dump-can +<examples/dump_can.{native,byte}>: use_can +<examples/dump_can.{native,byte}>: pkg_lwt.unix +<examples/dump_can.{native,byte}>: pkg_lwt.syntax +<examples/*.ml{,i}>: use_can +<examples/*.ml{,i}>: pkg_lwt.unix +<examples/*.ml{,i}>: pkg_lwt.syntax # OASIS_STOP diff --git a/info/control2011/examples/dump_can.ml b/info/control2011/examples/dump_can.ml new file mode 100644 index 0000000..b54c248 --- /dev/null +++ b/info/control2011/examples/dump_can.ml @@ -0,0 +1,54 @@ +(* + * dump_can.ml + * ----------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Dump all frames received from the CAN. *) + +open Lwt +open CAN + +let rec loop bus = + lwt frame = CAN.recv bus in + let data = String.create 8 in + String.blit frame.frame_data 0 data 0 (String.length frame.frame_data); + lwt () = + Lwt_io.printf "can frame received: + id = %d; + type = %s; + remote = %B; + format = %d bits; + data = %02x %02x %02x %02x %02x %02x %02x %02x; +" + frame.frame_identifier + (match frame.frame_type with + | Type_data -> "data" + | Type_error -> "error") + frame.frame_remote + (match frame.frame_format with + | Format_11bits -> 11 + | Format_29bits -> 29) + (Char.code data.[0]) + (Char.code data.[1]) + (Char.code data.[2]) + (Char.code data.[3]) + (Char.code data.[4]) + (Char.code data.[5]) + (Char.code data.[6]) + (Char.code data.[7]) + in + loop bus + +lwt () = + if Array.length Sys.argv <> 2 then begin + print_endline "usage: dump-can <interface>"; + exit 2; + end; + try_lwt + CAN.open_can Sys.argv.(1) >>= loop + with Unix.Unix_error(error, func, arg) -> + Lwt_log.error_f "'%s' failed with: %s" func (Unix.error_message error) diff --git a/info/control2011/myocamlbuild.ml b/info/control2011/myocamlbuild.ml index 2725ff4..5084bdd 100644 --- a/info/control2011/myocamlbuild.ml +++ b/info/control2011/myocamlbuild.ml @@ -461,4 +461,16 @@ let package_default = let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; (* OASIS_STOP *) -Ocamlbuild_plugin.dispatch dispatch_default;; + +open Ocamlbuild_plugin + +let () = + dispatch + (fun hook -> + dispatch_default hook; + match hook with + | Before_options -> + Options.make_links := false + | _ -> + ()) + diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 36bdba2..022aea8 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: d2406eee56464ad95caf1d4a61ce5222) *) +(* DO NOT EDIT (digest: 1304b079e30d590a78f62965c8e260ab) *) (* Regenerated by OASIS v0.2.0~alpha1 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5042,6 +5042,39 @@ let setup_t = files_ab = []; sections = [ + Library + ({ + cs_name = "can"; + cs_data = PropList.Data.create (); + cs_plugin_data = []; + }, + { + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, true)]; + bs_path = "src/can"; + bs_compiled_object = Best; + bs_build_depends = + [ + FindlibPackage ("lwt.unix", None); + FindlibPackage ("lwt.syntax", None) + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = ["can_stubs.c"]; + 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, [])]; + }, + { + lib_modules = ["CAN"]; + lib_internal_modules = []; + lib_findlib_parent = Some "krobot"; + lib_findlib_name = Some "can"; + lib_findlib_containers = []; + }); SrcRepo ({ cs_name = "head"; @@ -5086,14 +5119,14 @@ let setup_t = }); Library ({ - cs_name = "can"; + cs_name = "krobot"; cs_data = PropList.Data.create (); cs_plugin_data = []; }, { bs_build = [(OASISExpr.EBool true, true)]; bs_install = [(OASISExpr.EBool true, true)]; - bs_path = "src/can"; + bs_path = "src/lib"; bs_compiled_object = Best; bs_build_depends = [ @@ -5101,7 +5134,7 @@ let setup_t = FindlibPackage ("lwt.syntax", None) ]; bs_build_tools = [ExternalTool "ocamlbuild"]; - bs_c_sources = ["can_stubs.c"]; + bs_c_sources = []; bs_data_files = []; bs_ccopt = [(OASISExpr.EBool true, [])]; bs_cclib = [(OASISExpr.EBool true, [])]; @@ -5111,28 +5144,24 @@ let setup_t = bs_nativeopt = [(OASISExpr.EBool true, [])]; }, { - lib_modules = ["CAN"]; + lib_modules = []; lib_internal_modules = []; - lib_findlib_parent = Some "krobot"; - lib_findlib_name = Some "can"; + lib_findlib_parent = None; + lib_findlib_name = Some "krobot"; lib_findlib_containers = []; }); - Library + Executable ({ - cs_name = "krobot"; + cs_name = "dump-can"; cs_data = PropList.Data.create (); cs_plugin_data = []; }, { bs_build = [(OASISExpr.EBool true, true)]; - bs_install = [(OASISExpr.EBool true, true)]; - bs_path = "src/lib"; + bs_install = [(OASISExpr.EBool true, false)]; + bs_path = "examples"; bs_compiled_object = Best; - bs_build_depends = - [ - FindlibPackage ("lwt.unix", None); - FindlibPackage ("lwt.syntax", None) - ]; + bs_build_depends = [InternalLibrary "can"]; bs_build_tools = [ExternalTool "ocamlbuild"]; bs_c_sources = []; bs_data_files = []; @@ -5143,13 +5172,7 @@ let setup_t = bs_byteopt = [(OASISExpr.EBool true, [])]; bs_nativeopt = [(OASISExpr.EBool true, [])]; }, - { - lib_modules = []; - lib_internal_modules = []; - lib_findlib_parent = None; - lib_findlib_name = Some "krobot"; - lib_findlib_containers = []; - }) + {exec_custom = false; exec_main_is = "dump_can.ml"; }) ]; plugins = [(`Extra, "DevFiles", Some "0.2"); (`Extra, "META", Some "0.2")]; diff --git a/info/control2011/src/can/CAN.ml b/info/control2011/src/can/CAN.ml index 00952bb..c2c34ee 100644 --- a/info/control2011/src/can/CAN.ml +++ b/info/control2011/src/can/CAN.ml @@ -40,7 +40,7 @@ end | Openning/closing | +-----------------------------------------------------------------+ *) -external open_can_file_descr : string -> Unix.file_descr = "ocaml_can_open_file_descr" +external open_can_file_descr : string -> Unix.file_descr = "ocaml_can_open_can_file_descr" let open_can iface = let fd = open_can_file_descr iface in hooks/post-receive -- krobot |