Skip to content

Commit

Permalink
fertig
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Iserlohn authored and Christoph Iserlohn committed Feb 16, 2012
1 parent 5ebce6c commit 1432527
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/saw_taktgeber.erl
Expand Up @@ -96,10 +96,25 @@ handle_info(timeout, State) ->
{ok, Socket} = gen_udp:open(?PORT, []),
{noreply, State#state{socket = Socket}};

handle_info({udp, _Socket, IPtuple, InPortNo, Packet}, State) ->
error_logger:info_msg("~n~nFrom IP: ~p~nPort: ~p~nData: ~p~n", [IPtuple, InPortNo, Packet]),
{noreply, State}.
handle_info({udp, _Socket, IPtuple, InPortNo, [0]}, State) ->
%% error_logger:info_msg("~n~nFrom IP: ~p~nPort: ~p~nData: ~p~n", [IPtuple, InPortNo, Packet]),
T_now = erlang:now(),
case State of
{MegaSec, Sec, MircoSec} ->
T_delta = timer:now_diff(T_now, State),
saw_position:nulldurchlauf(T_delta),
error_logger:info_msg("Durchlaufzeit: ~p ms~n", [T_delta div 1000]);
_ ->
error_logger:info_msg("waiting for second run", [])
end,



{noreply, T_now};

handle_info(Msg, State) ->
error_logger:info_msg("Unknown msg ~p~n", [Msg]),
{noreply, State}.

%% --------------------------------------------------------------------
%% Function: terminate/2
Expand Down Expand Up @@ -130,4 +145,4 @@ send_message() ->
%% --------------------------------------------------------------------
-include_lib("eunit/include/eunit.hrl").
-ifdef(TEST).
-endif.
-endif.

0 comments on commit 1432527

Please sign in to comment.