【发布时间】:2015-10-27 02:06:50
【问题描述】:
我正在使用从我的设备切碎的比特流返回的elixir_serial,我怎样才能将它连接到长生不老药中,直到在"\n" 分隔符中?我在 node.js node-serialport 中找到了示例,但在我的 handle_info() 中找不到构建它的好示例?
def init([]) do
{:ok, serial} = Serial.start_link
Serial.open(serial, "/dev/cu.usbserial-A5026NYN")
Serial.set_speed(serial, 9600)
Serial.connect(serial)
Logger.debug "pid #{inspect serial}"
# @key_parts = []
{:ok, []}
end
def handle_info({:elixir_serial, serial, data}, state) do
Logger.debug "received :data #{data}"
{:noreply, state}
end
【问题讨论】: