[erlang-questions] Binaries

Bob Cowdery bob@REDACTED
Tue Jun 19 18:22:42 CEST 2018

```Thanks for all the suggestions. Still a little confused. The number is
an integer, actually a frequency in Hz plus a command byte at the end
which is being sent over a serial connection in hex format using
gen_serial.

This command works: gen_serial:bsend(P,
<<16#14,16#50,16#00,16#00,16#01>>). where P is the open Port.

However, when I use any of the methods to create a hex version they all
end up with <<20,80,0,0,1>> which to my mind is the decimal equiv of above.

If I fire that I get:

5> gen_serial:bsend(P,<<20,80,0,0,1>>).
in function  port_command/2
called as port_command(#Port<0.470>,[<<"d">>|<<20,80,0,0,1>>])
in call from gen_serial:send/2 (gen_serial.erl, line 624)
in call from gen_serial:bsend/3 (gen_serial.erl, line 706)

What is <<"d">> doing in there?

On 6/19/2018 4:32 PM, Bob Cowdery wrote:
> If I have a number, say 1450000001 and I want to represent that as a
> binary in the form
>
>  <<16#14,16#50,16#00,16#00,16#01>> what's the best way.
>
> I'm not sure what list_to_binary(integer_to_list(1450000001)) which
> prints as <<"1450000001">> produces but I guess its 10 bytes not 5.
>
> BobC
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

```