construct binary

Vance Shipley <>
Thu Jul 7 03:26:12 CEST 2005


Stephen,

I think this does it.

	-Vance


1> prl:decode(<<2:5, 1:11, 2:11, 0:5>>).
[1,2]


-module(prl).
-export([decode/1]).

decode(<<NumChans:5, _Pad:3, _Rest/binary>> = Bin) ->
   decode(Bin, NumChans, NumChans, []).
decode(_, _, 0, Acc) ->
   Acc;
decode(Bin, NumChans, N, Acc) ->
   SkipBefore = (N - 1) * 11,
   SkipAfter = (NumChans - N) * 11,
   Pad = 8 - ((NumChans * 11 + 5) rem 8),
   <<_:5, _:SkipBefore, Chan:11, _:SkipAfter, _:Pad>> = Bin,
   decode(Bin, NumChans, N - 1, [Chan | Acc]).


On Wed, Jul 06, 2005 at 04:59:47PM -0700, Stephen Han wrote:
}  
}  I am trying to write a IS-683 PRL encode/decode tool for our testing.



More information about the erlang-questions mailing list