Fix calibration params appearing to fail at saving
parent
669f012715
commit
f9d1c5c94c
|
@ -32,6 +32,19 @@ defimpl FarmbotCore.AssetWorker, for: FarmbotCore.Asset.FirmwareConfig do
|
||||||
{:noreply, new_fw_config}
|
{:noreply, new_fw_config}
|
||||||
end
|
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
|
defp do_write_read(param, value) do
|
||||||
with :ok <- FarmbotFirmware.command({:parameter_write, [{param, value}]}),
|
with :ok <- FarmbotFirmware.command({:parameter_write, [{param, value}]}),
|
||||||
{:ok, {_, {:report_parameter_value, [{^param, ^value}]}}} <- FarmbotFirmware.request({:parameter_read, [param]}) do
|
{:ok, {_, {:report_parameter_value, [{^param, ^value}]}}} <- FarmbotFirmware.request({:parameter_read, [param]}) do
|
||||||
|
|
|
@ -387,12 +387,6 @@ defmodule FarmbotFirmware do
|
||||||
@doc false
|
@doc false
|
||||||
@spec handle_command(GCODE.t(), GenServer.from(), state()) :: {:reply, term(), state()}
|
@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
|
# EmergencyLock should be ran immediately
|
||||||
def handle_command({tag, {:command_emergency_lock, []}} = code, {pid, _ref}, state) do
|
def handle_command({tag, {:command_emergency_lock, []}} = code, {pid, _ref}, state) do
|
||||||
{:reply, {:ok, tag}, %{state | command_queue: [{pid, code} | state.command_queue]}, 0}
|
{: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}
|
{:reply, {:ok, tag}, %{state | command_queue: [{pid, code} | state.command_queue]}, 0}
|
||||||
end
|
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
|
def handle_command({tag, {_, _}} = code, {pid, _ref}, state) do
|
||||||
new_state = %{state | command_queue: state.command_queue ++ [{pid, code}]}
|
new_state = %{state | command_queue: state.command_queue ++ [{pid, code}]}
|
||||||
|
|
||||||
|
|
|
@ -37,3 +37,6 @@ config :farmbot, FarmbotOS.FirmwareTTYDetector,
|
||||||
expected_names: [
|
expected_names: [
|
||||||
System.get_env("FARMBOT_TTY")
|
System.get_env("FARMBOT_TTY")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
config :logger,
|
||||||
|
backends: [RingLogger]
|
||||||
|
|
|
@ -6,7 +6,6 @@ CONFIG="logfile log/$PORT.log
|
||||||
logfile flush 1
|
logfile flush 1
|
||||||
log on
|
log on
|
||||||
logtstamp after 1
|
logtstamp after 1
|
||||||
logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\"
|
|
||||||
logtstamp on"
|
logtstamp on"
|
||||||
|
|
||||||
echo "$CONFIG" > log/$PORT.log.conf
|
echo "$CONFIG" > log/$PORT.log.conf
|
||||||
|
|
Loading…
Reference in New Issue