Commits

arkdro committed de9df56

add round_trip

  • Participants
  • Parent commits e8ef236

Comments (0)

Files changed (2)

File erlang/src/c_server.erl

 
 -export([
          get_timing/0,
+         rr_on/0,
+         rr_off/0,
 
          divide/2,
          subtract/2,
 %%==================================================================
 %% API
 %%==================================================================
+rr_off() ->
+    gen_server:call(?SERVER, rr_off).
+
+rr_on() ->
+    gen_server:call(?SERVER, rr_on).
+
 get_timing() ->
     gen_server:call(?SERVER, get_timing).
 
     {ok, #state{status = init, port = Port, portcmd = PortCommand }}.
 
 %-------------------------------------------------------------------
+handle_call(rr_on, From, #state{status=running, port=Port} = State) ->
+    New = send_to_port(State, Port, term_to_binary({round_trip, true})),
+    {noreply, New#state{from=From}};
+handle_call(rr_off, From, #state{status=running, port=Port} = State) ->
+    New = send_to_port(State, Port, term_to_binary({round_trip, false})),
+    {noreply, New#state{from=From}};
 handle_call(get_timing, _From, #state{count=Cnt, duration=Dur} = State) ->
     Res = {Cnt, Dur},
     {reply, Res, State};

File ocaml/src/odec_port.ml

         | None -> ET_Tuple [ET_Atom "error"; ET_Atom "no_value"]
         | Some term -> ET_Tuple [ET_Atom "ok"; term]
     end
+  | ET_Tuple [ET_Atom "round_trip"; ET_Atom "true"] ->
+    Some (ET_Tuple [ET_Atom "round_trip"; ET_Atom "true"]), ET_Atom "ok"
+  | ET_Tuple [ET_Atom "round_trip"; ET_Atom "false"] ->
+    Some (ET_Tuple [ET_Atom "round_trip"; ET_Atom "false"]), ET_Atom "ok"
+  | _ when old_value = Some (ET_Tuple [ET_Atom "round_trip";
+                                       ET_Atom "true"]) ->
+    let res = ET_Tuple [ET_Atom "ok"; ET_Atom "round_trip"] in
+    old_value, res
   | ET_Tuple [ET_Atom "info"; t] ->
     let res = get_info t in
     Some t, res