Merge pull request #1191 from FarmBot/beta_rc

Beta RC
beta_rc
Rick Carlino 2020-04-09 11:39:41 -05:00 committed by GitHub
commit b3a2b49f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 105 additions and 25 deletions

View File

@ -1 +1 @@
9.2.1
9.2.2-rc7

View File

@ -541,7 +541,7 @@ defmodule FarmbotFirmware do
# 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
when s in [:boot, :no_config] do
{:reply, {:error, "Can't send command when in #{inspect(s)} state"}, state}
end

View File

@ -1,6 +1,6 @@
defmodule FarmbotOS.Lua.Ext.Firmware do
@moduledoc """
Lua extensions for interacting with the Firmware
Lua extensions for interacting with the Firmware
"""
alias FarmbotCeleryScript.SysCalls

View File

@ -23,7 +23,7 @@ defmodule FarmbotOS.Platform.Target.PinBindingWorker.CircuitsGPIOHandler do
{:ok, pin} = GPIO.open(pin_number, :input)
:ok = GPIO.set_interrupts(pin, :rising)
# this has been checked on v1.3 and v1.5 hardware
# and it seems to be fine.
# and it seems to be fine.
:ok = GPIO.set_pull_mode(pin, :pulldown)
{:ok, %{pin_number: pin_number, pin: pin, fun: fun, debounce: nil}}
end

View File

@ -0,0 +1,75 @@
defmodule FarmbotOS.Lua.Ext.FirmwareTest do
alias FarmbotOS.Lua.Ext.Firmware
use ExUnit.Case
use Mimic
setup :verify_on_exit!
test "calibrate/2" do
msg = "expected stub error"
lua = "return"
expect(FarmbotCeleryScript.SysCalls, :calibrate, 2, fn
"x" -> :ok
_ -> {:error, msg}
end)
assert {[true], ^lua} = Firmware.calibrate(["x"], lua)
assert {[nil, ^msg], ^lua} = Firmware.calibrate(["y"], lua)
end
test "move_absolute/2" do
msg = "expected stub error"
lua = "return"
expect(FarmbotCeleryScript.SysCalls, :move_absolute, 4, fn
(1, _, _, _) -> :ok
(_, _, _, _) -> {:error, msg}
end)
assert {[true], ^lua} = Firmware.move_absolute([1,2,3,4], lua)
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5,6,7,8], lua)
assert {[true], ^lua} = Firmware.move_absolute([1,2,3], lua)
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5,6,7], lua)
end
test "find_home/2" do
msg = "expected stub error"
lua = "return"
expect(FarmbotCeleryScript.SysCalls, :find_home, 2, fn
"x" -> :ok
_ -> {:error, msg}
end)
assert {[true], ^lua} = Firmware.find_home(["x"], lua)
assert {[nil, ^msg], ^lua} = Firmware.find_home(["y"], lua)
end
test "emergency_lock/2" do
msg = "expected stub error"
lua = "return"
expect(FarmbotCeleryScript.SysCalls, :emergency_lock, 1, fn -> :ok end)
assert {[true], ^lua} = Firmware.emergency_lock(:ok, lua)
expect(FarmbotCeleryScript.SysCalls, :emergency_lock, 1, fn ->
{:error, msg}
end)
assert {[nil, ^msg], ^lua} = Firmware.emergency_lock(nil, lua)
end
test "emergency_unlock/2" do
msg = "expected stub error"
lua = "return"
expect(FarmbotCeleryScript.SysCalls, :emergency_unlock, 1, fn -> :ok end)
assert {[true], ^lua} = Firmware.emergency_unlock(:ok, lua)
expect(FarmbotCeleryScript.SysCalls, :emergency_unlock, 1, fn ->
{:error, msg}
end)
assert {[nil, ^msg], ^lua} = Firmware.emergency_unlock(nil, lua)
end
end

View File

@ -75,15 +75,14 @@ defmodule FarmbotOS.SysCalls.PinControlTest do
end
test "set_servo_angle" do
expect(FarmbotFirmware, :command, 1, fn
expect(FarmbotFirmware, :command, 2, fn
{:servo_write, [p: 20, v: 90]} -> {:error, "opps"}
{:servo_write, [p: 40, v: 180]} -> :ok
end)
assert :ok = PinControl.set_servo_angle(40, 180)
message =
"Firmware error @ \"set_servo_angle\": \"Can't send command when in :transport_boot state\""
message = "Firmware error @ \"set_servo_angle\": \"opps\""
assert {:error, ^message} = PinControl.set_servo_angle(20, 90)
end

View File

@ -1,20 +1,26 @@
Application.ensure_all_started(:mimic)
Mimic.copy(FarmbotCore.Asset.Device)
Mimic.copy(FarmbotCore.Asset.FbosConfig)
Mimic.copy(FarmbotCore.Asset.FirmwareConfig)
Mimic.copy(FarmbotCore.Asset)
Mimic.copy(FarmbotCore.BotState)
Mimic.copy(FarmbotCore.Config)
Mimic.copy(FarmbotCore.FarmwareRuntime)
Mimic.copy(FarmbotCore.LogExecutor)
Mimic.copy(FarmbotExt.API.Reconciler)
Mimic.copy(FarmbotExt.API)
Mimic.copy(FarmbotFirmware)
Mimic.copy(FarmbotOS.Configurator.ConfigDataLayer)
Mimic.copy(FarmbotOS.Configurator.DetsTelemetryLayer)
Mimic.copy(FarmbotOS.Configurator.FakeNetworkLayer)
Mimic.copy(FarmbotOS.SysCalls.Movement)
Mimic.copy(FarmbotOS.SysCalls)
Mimic.copy(File)
Mimic.copy(MuonTrap)
[
FarmbotCore.Asset.Device,
FarmbotCore.Asset.FbosConfig,
FarmbotCore.Asset.FirmwareConfig,
FarmbotCore.Asset,
FarmbotCore.BotState,
FarmbotCore.Config,
FarmbotCore.FarmwareRuntime,
FarmbotCore.LogExecutor,
FarmbotExt.API.Reconciler,
FarmbotExt.API,
FarmbotFirmware,
FarmbotOS.Configurator.ConfigDataLayer,
FarmbotOS.Configurator.DetsTelemetryLayer,
FarmbotOS.Configurator.FakeNetworkLayer,
FarmbotOS.SysCalls.Movement,
FarmbotOS.SysCalls,
File,
MuonTrap,
FarmbotCeleryScript.SysCalls
]
|> Enum.map(&Mimic.copy/1)
ExUnit.start()