In the second to last line you are declaring Frame as an integer and in the last line you are using it as a binary. I don't see anything obviously wrong other than that, but harder to read if on a phone :)<span></span><div>
<br>On Tuesday, May 8, 2012, Farruco Sanjurjo wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<div><br></div><div>I'm getting a badarg error in this code</div>
<div><br></div><div><div>from_binary(Data = <<Head:8, 0:1, PayloadLen:7, Trailing/bits>>, Acc) -></div><div> PayloadBytes= case PayloadLen of</div>
<div> 126 -></div><div> <<ExtPayloadLen:16, _/binary>> = Trailing,</div><div> 2 + ExtPayloadLen;</div><div> 127 -></div><div> <<ExtPayloadLen:64, _/binary>> = Trailing,</div>
<div> 8 + ExtPayloadLen;</div><div> _ -></div><div> %<<Payload:ExtPayloadLen/binary, Rest/binary>></div><div> PayloadLen</div><div> end,</div><div> FrameSize = 16 + (PayloadBytes * 8),</div>
<div> <<Frame:FrameSize, Rest/binary>> = Data,</div><div> from_binary(Rest, [decode_frame(<<Frame/binary>>) | Acc]);</div></div><div><br></div><div>The error points to the line " FrameSize = 16 + (PayloadBytes * 8)".</div>
<div><br></div><div>I've been struggling for a while but I can't figure out what's wrong. Any suggestion?</div><div><br></div><div><br></div>
</blockquote></div>