Erlang serial IO

半腔热情 提交于 2019-12-03 03:50:59

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.
Arunmu

If you are asking about writing to device files , then you cannot do it using the available file modules in erlang.

You will have to open a port and execute your c/C++ code.

Check if this helps.

So there is apparently no serial communication library for erlang. I now had to dig up python again, use pyserial, spawn the python threads from erlang and communicate via stdin.

If anyone knows better, please proof me wrong. I would love to have erlang native serial I/O.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!