From 6d2e831da9be76e30d3b67d244304fea0681dcfb Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Fri, 8 Dec 2017 11:39:10 -0800 Subject: [PATCH] Add rescue block to firmware input parser --- .gitignore | 1 + lib/farmbot/firmware/uart_handler/framing.ex | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 108cf91b..f478ffeb 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ node_modules # Various env vars. .env travis_env +scripts/mqtt.py # Fwup keys aren't stored here, but just in case. *.priv diff --git a/lib/farmbot/firmware/uart_handler/framing.ex b/lib/farmbot/firmware/uart_handler/framing.ex index b1afb2a1..50468bd5 100644 --- a/lib/farmbot/firmware/uart_handler/framing.ex +++ b/lib/farmbot/firmware/uart_handler/framing.ex @@ -91,7 +91,7 @@ defmodule Farmbot.Firmware.UartHandler.Framing do case to_process do # Handle separater <<^separator::binary-size(sep_length), rest::binary>> -> - new_lines = lines ++ [parse_code(processed)] + new_lines = lines ++ [do_parse_code(processed)] process_data(separator, sep_length, max_length, <<>>, rest, new_lines) # Handle line too long case @@ -104,4 +104,10 @@ defmodule Farmbot.Firmware.UartHandler.Framing do process_data(separator, sep_length, max_length, processed <> next_char, rest, lines) end end + + defp do_parse_code(processed) do + parse_code(processed) + rescue + _ -> {nil, :noop} + end end