Fix calibration params appearing to fail at saving

pull/974/head
Connor Rigby 2019-07-02 10:08:07 -07:00
parent 669f012715
commit f9d1c5c94c
No known key found for this signature in database
GPG Key ID: 29A88B24B70456E0
4 changed files with 22 additions and 7 deletions

View File

@ -32,6 +32,19 @@ defimpl FarmbotCore.AssetWorker, for: FarmbotCore.Asset.FirmwareConfig do
{:noreply, new_fw_config}
end
defp do_write_read(calib_param, value)
when calib_param in [:movement_axis_nr_steps_z, :movement_axis_nr_steps_y, :movement_axis_nr_steps_z]
do
case FarmbotFirmware.command({:parameter_write, [{calib_param, value}]}) do
{:error, :configuration} ->
FarmbotCore.Logger.warn 3, "Firmware parameter edge case (calibration): #{calib_param}: #{value}"
:ok
:ok ->
FarmbotCore.Logger.success 1, "Firmware parameter updated: #{calib_param} #{value}"
:ok
end
end
defp do_write_read(param, value) do
with :ok <- FarmbotFirmware.command({:parameter_write, [{param, value}]}),
{:ok, {_, {:report_parameter_value, [{^param, ^value}]}}} <- FarmbotFirmware.request({:parameter_read, [param]}) do

View File

@ -387,12 +387,6 @@ defmodule FarmbotFirmware do
@doc false
@spec handle_command(GCODE.t(), GenServer.from(), state()) :: {:reply, term(), state()}
# If not in an acceptable state, return an error immediately.
def handle_command(_, _, %{status: s} = state)
when s in [:transport_boot, :boot, :no_config, :configuration] do
{:reply, {:error, s}, state}
end
# EmergencyLock should be ran immediately
def handle_command({tag, {:command_emergency_lock, []}} = code, {pid, _ref}, state) do
{:reply, {:ok, tag}, %{state | command_queue: [{pid, code} | state.command_queue]}, 0}
@ -403,6 +397,12 @@ defmodule FarmbotFirmware do
{:reply, {:ok, tag}, %{state | command_queue: [{pid, code} | state.command_queue]}, 0}
end
# If not in an acceptable state, return an error immediately.
def handle_command(_, _, %{status: s} = state)
when s in [:transport_boot, :boot, :no_config, :configuration] do
{:reply, {:error, s}, state}
end
def handle_command({tag, {_, _}} = code, {pid, _ref}, state) do
new_state = %{state | command_queue: state.command_queue ++ [{pid, code}]}

View File

@ -37,3 +37,6 @@ config :farmbot, FarmbotOS.FirmwareTTYDetector,
expected_names: [
System.get_env("FARMBOT_TTY")
]
config :logger,
backends: [RingLogger]

View File

@ -6,7 +6,6 @@ CONFIG="logfile log/$PORT.log
logfile flush 1
log on
logtstamp after 1
logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\"
logtstamp on"
echo "$CONFIG" > log/$PORT.log.conf