Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang serial IO

I want to talk to my modem with erlang. It is mounted as /dev/ttyUSB and perfectly understands AT-commands.

  • Can I read and write from the device with the standard file module?

  • How about baudrate, bytesize, parity, RTS/CTS, DSR/DTR and the like?

  • Have you any experiences with tonyg-erlang-serial-1.0? (I am not too convinced of this package as it says in the readme: "This is a port program with erlang driver for serial communication, originally written by Johan Bevemyr in 1996 and sporadically maintained by Tony Garnock-Jones from 2007 onwards."

  • What is the common practice for serial I/O in erlang?

like image 504
Hyperboreus Avatar asked Aug 07 '11 22:08

Hyperboreus


1 Answers

Get erlang-serial with rebar support from github.com/systra/erlang-serial. Here is a simple usage example:

Serial = serial:start([{speed,38400},{open,"/dev/ttya"}]),
Serial ! {send, <<"test">>},
receive
    {data,FromOtherSide} ->
        doStuff(FromOtherSide);
    Other ->
        Other
end.
like image 118
Eric des Courtis Avatar answered Oct 28 '22 19:10

Eric des Courtis