anchor.diff:  -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
   -export([start_link/0]).
   % api
  --export([register_receiver/2, get_synnum/0, send_to_amber/2]).
  +-export([register_receiver/2, deregister_receiver/1, get_synnum/0, send_to_amber/2]).
   
   % ROBOCLAW
   -define(ROBOCLAW_TI, {2,0}).
  --export([motors_command/1, motors_command/2, motors_command/4, motors_demo1/0]).
  +-export([motors_command/2, motors_command/4, motors_demo1/0]).
   % STARGAZER
   -define(STARGAZER_TI, {3,0}).
   -export([stargazer_order_position/0, stargazer_order_position/1,
  
positive.code: 
  code_change(_OldV, State, _Extra) -> {ok, State}.
  
  
  %% API -------------------------------------------------------------------------
  
  -spec register_receiver(#dispd_key{}, pid())
  			-> 'ok'.
  register_receiver(Key = #dispd_key{}, Pid) -> gen_server:call(?MODULE, {register_receiver, Key, Pid}).
  
  % deregister_receiver({_DevT, _DevI, _SynNum}) -> 'ok'.
  
  -spec get_synnum()
  			-> non_neg_integer().
  
negative.code: 	DevT = proplists:get_value(device_type, Os, DefDevT),
  	DevI = proplists:get_value(device_id, Os, DefDevI), 
  	Hdr = #driverhdr{devicetype = DevT, deviceid = DevI},
  	Key = #dispd_key{dev_t=DevT, dev_i=DevI, synnum=SynNum},
  	Val = #dispd_val{recpid = proplists:get_value(pid, Os, self()),
  									 post = {fun deregister_receiver/1, Key}},
  	register_receiver(Key, Val),
  	send_to_amber(Hdr, MsgBinary),
  	SynNum.
  
  stargazer_subscribe_position() -> stargazer_subscribe_position([]).
  
  stargazer_subscribe_position(Os) ->
  	SynNum = 0, % tego wymaga sterownik stargazera
   	MsgBase = #drivermsg{type = 'DATA', synnum = SynNum},
  	{ok, Msg} = stargazer_pb:set_extension(MsgBase, subscribeaction,
  	                                       #subscribeaction{action = 'SUBSCRIBE',
  	                                       									freq   = proplists:get_value(freq, Os, 100) }),
  	MsgBinary = stargazer_pb:encode_drivermsg(Msg),
  	{DefDevT,DefDevI} = ?STARGAZER_TI,
  	DevT = proplists:get_value(device_type, Os, DefDevT),
  	DevI = proplists:get_value(device_id, Os, DefDevI), 
  	Hdr = #driverhdr{devicetype = DevT, deviceid = DevI},
  	Key = #dispd_key{dev_t=DevT, dev_i=DevI, synnum=SynNum},
  	Val = #dispd_val{recpid = proplists:get_value(pid, Os, self())},
  	register_receiver(Key, Val),
  	send_to_amber(Hdr, MsgBinary),
  	SynNum.
  
  stargazer_get_position(SynNum) -> stargazer_get_position(SynNum, 5000).
  
  