diff --git a/cpp/Makefile b/cpp/Makefile index 531ced03..960bb711 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -45,7 +45,7 @@ endif PISCSI = piscsi SCSICTL = scsictl SCSIDUMP = scsidump -SCSISEND = scsisend +SCSIEXEC = scsiexec SCSIMON = scsimon PISCSI_TEST = piscsi_test SCSILOOP = scsiloop @@ -73,7 +73,7 @@ BIN_ALL = \ # Some tools require initiator support ifeq ($(CONNECT_TYPE), FULLSPEC) BIN_ALL += $(BINDIR)/$(SCSIDUMP) - BIN_ALL += $(BINDIR)/$(SCSISEND) + BIN_ALL += $(BINDIR)/$(SCSIEXEC) endif SRC_PROTOC = piscsi_interface.proto @@ -107,9 +107,9 @@ SRC_SCSIDUMP = scsidump/scsidump.cpp SRC_SCSIDUMP += $(shell find ./scsidump -name '*.cpp' | grep -v scsidump.cpp) SRC_SCSIDUMP += $(shell find ./hal -name '*.cpp') -SRC_SCSISEND = scsisend/scsisend.cpp -SRC_SCSISEND += $(shell find ./scsisend -name '*.cpp' | grep -v scsisend.cpp) -SRC_SCSISEND += $(shell find ./hal -name '*.cpp') +SRC_SCSIEXEC = scsiexec/scsiexec.cpp +SRC_SCSIEXEC += $(shell find ./scsiexec -name '*.cpp' | grep -v scsiexec.cpp) +SRC_SCSIEXEC += $(shell find ./hal -name '*.cpp') SRC_PISCSI_TEST = $(shell find ./test -name '*.cpp') SRC_PISCSI_TEST += $(shell find ./scsidump -name '*.cpp' | grep -v scsidump.cpp) @@ -119,9 +119,9 @@ SRC_SCSILOOP += $(shell find ./scsiloop -name '*.cpp' | grep -v scsiloop.cpp) SRC_SCSILOOP += $(shell find ./hal -name '*.cpp') vpath %.h ./shared ./controllers ./devices ./scsimon ./hal \ - ./hal/pi_defs ./piscsi ./scsictl ./scsidump ./scsisend ./scsiloop + ./hal/pi_defs ./piscsi ./scsictl ./scsidump ./scsiexec ./scsiloop vpath %.cpp ./shared ./controllers ./devices ./scsimon ./hal \ - ./hal/pi_defs ./piscsi ./scsictl ./scsidump ./scsisend ./scsiloop ./test + ./hal/pi_defs ./piscsi ./scsictl ./scsidump ./scsiexec ./scsiloop ./test vpath %.o ./$(OBJDIR) vpath ./$(BINDIR) @@ -131,7 +131,7 @@ OBJ_PISCSI := $(addprefix $(OBJDIR)/,$(notdir $(SRC_PISCSI:%.cpp=%.o))) OBJ_SCSICTL_CORE := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSICTL_CORE:%.cpp=%.o))) OBJ_SCSICTL := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSICTL:%.cpp=%.o))) OBJ_SCSIDUMP := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSIDUMP:%.cpp=%.o))) -OBJ_SCSISEND := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSISEND:%.cpp=%.o))) +OBJ_SCSIEXEC := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSIEXEC:%.cpp=%.o))) OBJ_SCSIMON := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSIMON:%.cpp=%.o))) OBJ_PISCSI_TEST := $(addprefix $(OBJDIR)/,$(notdir $(SRC_PISCSI_TEST:%.cpp=%.o))) OBJ_SCSILOOP := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSILOOP:%.cpp=%.o))) @@ -145,7 +145,7 @@ BINARIES = $(USR_LOCAL_BIN)/$(SCSICTL) \ $(USR_LOCAL_BIN)/$(SCSILOOP) ifeq ($(CONNECT_TYPE), FULLSPEC) BINARIES += $(USR_LOCAL_BIN)/$(SCSIDUMP) - BINARIES += $(USR_LOCAL_BIN)/$(SCSISEND) + BINARIES += $(USR_LOCAL_BIN)/$(SCSIEXEC) endif MAN_PAGES = $(MAN_PAGE_DIR)/piscsi.1 \ @@ -154,7 +154,7 @@ MAN_PAGES = $(MAN_PAGE_DIR)/piscsi.1 \ $(MAN_PAGE_DIR)/scsiloop.1 ifeq ($(CONNECT_TYPE), FULLSPEC) MAN_PAGES += $(MAN_PAGE_DIR)/scsidump.1 - MAN_PAGES += $(MAN_PAGE_DIR)/scsisend.1 + MAN_PAGES += $(MAN_PAGE_DIR)/scsiexec.1 endif GENERATED_DIR := generated @@ -166,7 +166,7 @@ TEST_WRAPS = -Wl,--wrap=fopen64 # The following will include all of the auto-generated dependency files (*.d) # if they exist. This will trigger a rebuild of a source file if a header changes -ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_PISCSI_CORE) $(OBJ_SCSICTL_CORE) $(OBJ_PISCSI) $(OBJ_SCSICTL) $(OBJ_SCSIDUMP) $(OBJ_SCSISEND) $(OBJ_SCSIMON) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_PISCSI_TEST) $(OBJ_SCSILOOP)) +ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_PISCSI_CORE) $(OBJ_SCSICTL_CORE) $(OBJ_PISCSI) $(OBJ_SCSICTL) $(OBJ_SCSIDUMP) $(OBJ_SCSIEXEC) $(OBJ_SCSIMON) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_PISCSI_TEST) $(OBJ_SCSILOOP)) -include $(ALL_DEPS) $(OBJDIR) $(BINDIR): @@ -223,8 +223,8 @@ $(BINDIR)/$(SCSICTL): $(OBJ_GENERATED) $(OBJ_SCSICTL_CORE) $(OBJ_SCSICTL) $(OBJ_ $(BINDIR)/$(SCSIDUMP): $(OBJ_SCSIDUMP) $(OBJ_SHARED) | $(BINDIR) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_SCSIDUMP) $(OBJ_SHARED) -$(BINDIR)/$(SCSISEND): $(OBJ_SCSISEND) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_GENERATED) | $(BINDIR) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_SCSISEND) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_GENERATED) -lprotobuf +$(BINDIR)/$(SCSIEXEC): $(OBJ_SCSIEXEC) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_GENERATED) | $(BINDIR) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_SCSIEXEC) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_GENERATED) -lprotobuf $(BINDIR)/$(SCSIMON): $(OBJ_SCSIMON) $(OBJ_SHARED) | $(BINDIR) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ_SCSIMON) $(OBJ_SHARED) @@ -236,11 +236,11 @@ $(BINDIR)/$(PISCSI_TEST): $(OBJ_GENERATED) $(OBJ_PISCSI_CORE) $(OBJ_SCSICTL_CORE $(CXX) $(CXXFLAGS) $(LDFLAGS) $(TEST_WRAPS) -o $@ $(OBJ_PISCSI_CORE) $(OBJ_SCSICTL_CORE) $(OBJ_PISCSI_TEST) $(OBJ_SHARED) $(OBJ_PROTOBUF) $(OBJ_GENERATED) -lpthread -lpcap -lprotobuf -lgmock -lgtest # Phony rules for building individual utilities -.PHONY: $(PISCSI) $(SCSICTL) $(SCSIDUMP) $(SCSISEND) $(SCSIMON) $(PISCSI_TEST) $(SCSILOOP) +.PHONY: $(PISCSI) $(SCSICTL) $(SCSIDUMP) $(SCSIEXEC) $(SCSIMON) $(PISCSI_TEST) $(SCSILOOP) $(PISCSI) : $(BINDIR)/$(PISCSI) $(SCSICTL) : $(BINDIR)/$(SCSICTL) $(SCSIDUMP) : $(BINDIR)/$(SCSIDUMP) -$(SCSISEND) : $(BINDIR)/$(SCSISEND) +$(SCSIEXEC) : $(BINDIR)/$(SCSIEXEC) $(SCSIMON) : $(BINDIR)/$(SCSIMON) $(PISCSI_TEST): $(BINDIR)/$(PISCSI_TEST) $(SCSILOOP) : $(BINDIR)/$(SCSILOOP) diff --git a/cpp/scsisend/phase_executor.cpp b/cpp/scsiexec/phase_executor.cpp similarity index 100% rename from cpp/scsisend/phase_executor.cpp rename to cpp/scsiexec/phase_executor.cpp diff --git a/cpp/scsisend/phase_executor.h b/cpp/scsiexec/phase_executor.h similarity index 100% rename from cpp/scsisend/phase_executor.h rename to cpp/scsiexec/phase_executor.h diff --git a/cpp/scsisend/scsi_executor.cpp b/cpp/scsiexec/scsi_executor.cpp similarity index 91% rename from cpp/scsisend/scsi_executor.cpp rename to cpp/scsiexec/scsi_executor.cpp index db24b6ab..689f9c8e 100644 --- a/cpp/scsisend/scsi_executor.cpp +++ b/cpp/scsiexec/scsi_executor.cpp @@ -8,7 +8,7 @@ //--------------------------------------------------------------------------- #include "shared/scsi.h" -#include "scsisend/scsi_executor.h" +#include "scsiexec/scsi_executor.h" #include "generated/piscsi_interface.pb.h" #include #include @@ -56,7 +56,7 @@ void ScsiExecutor::Execute(const string& filename, bool binary) if (!binary) { const string json((const char *)buffer.data(), length); - cerr << "json received:\n" << json << endl; + spdlog::info("json received:\n" + json); } else { PbResult result; @@ -65,6 +65,6 @@ void ScsiExecutor::Execute(const string& filename, bool binary) } string json; google::protobuf::util::MessageToJsonString(result, &json); - cerr << "json (converted from binary) received:\n" << json << endl; + spdlog::info("json (converted from binary) received:\n" + json); } } diff --git a/cpp/scsisend/scsi_executor.h b/cpp/scsiexec/scsi_executor.h similarity index 95% rename from cpp/scsisend/scsi_executor.h rename to cpp/scsiexec/scsi_executor.h index a0b1d5fd..ca5ee1bb 100644 --- a/cpp/scsisend/scsi_executor.h +++ b/cpp/scsiexec/scsi_executor.h @@ -9,7 +9,7 @@ #pragma once -#include "scsisend/phase_executor.h" +#include "scsiexec/phase_executor.h" #include #include #include diff --git a/cpp/scsisend/scsisend.cpp b/cpp/scsiexec/scsiexec.cpp similarity index 84% rename from cpp/scsisend/scsisend.cpp rename to cpp/scsiexec/scsiexec.cpp index d593a38c..03dbe77e 100644 --- a/cpp/scsisend/scsisend.cpp +++ b/cpp/scsiexec/scsiexec.cpp @@ -7,7 +7,7 @@ // //--------------------------------------------------------------------------- -#include "scsisend/scsisend_core.h" +#include "scsisexec_core.h" using namespace std; @@ -15,5 +15,5 @@ int main(int argc, char *argv[]) { vector args(argv, argv + argc); - return ScsiSend().run(args); + return ScsiExec().run(args); } diff --git a/cpp/scsisend/scsisend_core.cpp b/cpp/scsiexec/scsisexec_core.cpp similarity index 91% rename from cpp/scsisend/scsisend_core.cpp rename to cpp/scsiexec/scsisexec_core.cpp index 2a09f47a..8f712e7a 100644 --- a/cpp/scsisend/scsisend_core.cpp +++ b/cpp/scsiexec/scsisexec_core.cpp @@ -7,7 +7,7 @@ // //--------------------------------------------------------------------------- -#include "scsisend/scsisend_core.h" +#include "scsisexec_core.h" #include "hal/sbc_version.h" #include "hal/gpiobus_factory.h" #include "controllers/controller_manager.h" @@ -25,14 +25,14 @@ using namespace spdlog; using namespace scsi_defs; using namespace piscsi_util; -void ScsiSend::CleanUp() const +void ScsiExec::CleanUp() const { if (bus != nullptr) { bus->Cleanup(); } } -void ScsiSend::TerminationHandler(int) +void ScsiExec::TerminationHandler(int) { instance->bus->SetRST(true); @@ -41,9 +41,9 @@ void ScsiSend::TerminationHandler(int) // Process will terminate automatically } -bool ScsiSend::Banner(span args) const +bool ScsiExec::Banner(span args) const { - cout << piscsi_util::Banner("(SCSI Action Trigger Utility)"); + cout << piscsi_util::Banner("(SCSI Action Execution Utility)"); if (args.size() < 2 || string(args[1]) == "-h" || string(args[1]) == "--help") { cout << "Usage: " << args[0] << " -t ID[:LUN] [-i BID] -f FILENAME [-L log_level] [-b] \n" @@ -60,7 +60,7 @@ bool ScsiSend::Banner(span args) const return true; } -bool ScsiSend::Init(bool) +bool ScsiExec::Init(bool) { instance = this; // Signal handler for cleaning up @@ -81,7 +81,7 @@ bool ScsiSend::Init(bool) return bus != nullptr; } -void ScsiSend::ParseArguments(span args) +void ScsiExec::ParseArguments(span args) { optind = 1; opterr = 0; @@ -122,7 +122,7 @@ void ScsiSend::ParseArguments(span args) } } -int ScsiSend::run(span args, bool in_process) +int ScsiExec::run(span args, bool in_process) { if (!Banner(args)) { return EXIT_SUCCESS; @@ -163,7 +163,7 @@ int ScsiSend::run(span args, bool in_process) return EXIT_SUCCESS; } -bool ScsiSend::SetLogLevel() const +bool ScsiExec::SetLogLevel() const { const level::level_enum l = level::from_str(log_level); // Compensate for spdlog using 'off' for unknown levels diff --git a/cpp/scsisend/scsisend_core.h b/cpp/scsiexec/scsisexec_core.h similarity index 87% rename from cpp/scsisend/scsisend_core.h rename to cpp/scsiexec/scsisexec_core.h index 510d60c7..8024f3e2 100644 --- a/cpp/scsisend/scsisend_core.h +++ b/cpp/scsiexec/scsisexec_core.h @@ -10,7 +10,7 @@ #pragma once #include "hal/bus.h" -#include "scsisend/scsi_executor.h" +#include "scsiexec/scsi_executor.h" #include #include #include @@ -18,13 +18,13 @@ using namespace std; -class ScsiSend +class ScsiExec { public: - ScsiSend() = default; - ~ScsiSend() = default; + ScsiExec() = default; + ~ScsiExec() = default; int run(span, bool = false); @@ -59,5 +59,5 @@ private: string log_level = "info"; // Required for the termination handler - static inline ScsiSend *instance; + static inline ScsiExec *instance; }; diff --git a/cpp/test/bus_test.cpp b/cpp/test/bus_test.cpp index fc78731c..30cca4ce 100644 --- a/cpp/test/bus_test.cpp +++ b/cpp/test/bus_test.cpp @@ -12,7 +12,7 @@ TEST(BusTest, GetCommandByteCount) { - EXPECT_EQ(41, scsi_defs::command_mapping.size()); + EXPECT_EQ(42, scsi_defs::command_mapping.size()); EXPECT_EQ(6, BUS::GetCommandByteCount(0x00)); EXPECT_EQ(6, BUS::GetCommandByteCount(0x01)); EXPECT_EQ(6, BUS::GetCommandByteCount(0x03)); @@ -47,13 +47,14 @@ TEST(BusTest, GetCommandByteCount) EXPECT_EQ(10, BUS::GetCommandByteCount(0x4a)); EXPECT_EQ(10, BUS::GetCommandByteCount(0x55)); EXPECT_EQ(10, BUS::GetCommandByteCount(0x5a)); - EXPECT_EQ(12, BUS::GetCommandByteCount(0xa0)); EXPECT_EQ(16, BUS::GetCommandByteCount(0x88)); EXPECT_EQ(16, BUS::GetCommandByteCount(0x8a)); EXPECT_EQ(16, BUS::GetCommandByteCount(0x8f)); EXPECT_EQ(16, BUS::GetCommandByteCount(0x91)); EXPECT_EQ(16, BUS::GetCommandByteCount(0x9e)); EXPECT_EQ(16, BUS::GetCommandByteCount(0x9f)); + EXPECT_EQ(12, BUS::GetCommandByteCount(0xa0)); + EXPECT_EQ(10, BUS::GetCommandByteCount(0xc0)); EXPECT_EQ(0, BUS::GetCommandByteCount(0x1f)); }