Fix firmware logging
This commit is contained in:
parent
2cbd62b554
commit
a8d1a885d9
|
@ -49,7 +49,7 @@ config :farmbot, Farmbot.System.ConfigStorage,
|
||||||
config :farmbot, :behaviour,
|
config :farmbot, :behaviour,
|
||||||
authorization: Farmbot.Bootstrap.Authorization,
|
authorization: Farmbot.Bootstrap.Authorization,
|
||||||
system_tasks: Farmbot.Host.SystemTasks,
|
system_tasks: Farmbot.Host.SystemTasks,
|
||||||
update_handler: Farmbot.Host.UpdateHandler
|
update_handler: Farmbot.Host.UpdateHandler,
|
||||||
# firmware_handler: Farmbot.Firmware.UartHandler
|
firmware_handler: Farmbot.Firmware.UartHandler
|
||||||
|
|
||||||
config :farmbot, :uart_handler, tty: "/dev/ttyACM0"
|
config :farmbot, :uart_handler, tty: "/dev/ttyACM0"
|
||||||
|
|
|
@ -115,12 +115,14 @@ defmodule Farmbot.Firmware.UartHandler.Framing do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp do_parse_code(processed, log_input) do
|
defp do_parse_code(processed, log_input) do
|
||||||
# maybe log input here
|
|
||||||
if log_input do
|
if log_input do
|
||||||
Logger.debug 3, log_input
|
Logger.debug 3, processed
|
||||||
end
|
end
|
||||||
|
|
||||||
parse_code(processed)
|
parse_code(processed)
|
||||||
rescue
|
rescue
|
||||||
_ -> {nil, :noop}
|
er ->
|
||||||
|
Logger.error 1, "Firmware parser error: #{Exception.message(er)}"
|
||||||
|
{nil, :noop}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,8 +85,7 @@ defmodule Farmbot.Firmware.UartHandler do
|
||||||
def init([]) do
|
def init([]) do
|
||||||
# If in dev environment, it is expected that this be done at compile time.
|
# If in dev environment, it is expected that this be done at compile time.
|
||||||
# If in target environment, this should be done by `Farmbot.Firmware.AutoDetector`.
|
# If in target environment, this should be done by `Farmbot.Firmware.AutoDetector`.
|
||||||
tty =
|
tty = Application.get_env(:farmbot, :uart_handler)[:tty] || raise "Please configure uart handler!"
|
||||||
Application.get_env(:farmbot, :uart_handler)[:tty] || raise "Please configure uart handler!"
|
|
||||||
storage_dispatch = Farmbot.System.ConfigStorage.Dispatcher
|
storage_dispatch = Farmbot.System.ConfigStorage.Dispatcher
|
||||||
case open_tty(tty) do
|
case open_tty(tty) do
|
||||||
{:ok, nerves} ->
|
{:ok, nerves} ->
|
||||||
|
|
Loading…
Reference in a new issue