From: Michael McMaster Date: Sat, 2 Mar 2019 05:09:04 +0000 (+1000) Subject: Add command-line test utility X-Git-Tag: v6.2.3-beta~7 X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=c1b97768c16e949241a0a68cb12cea539406b339;p=SCSI2SD-V6.git Add command-line test utility --- diff --git a/src/scsi2sd-util6/scsi2sd-test.cc b/src/scsi2sd-util6/scsi2sd-test.cc new file mode 100644 index 00000000..5c5273a2 --- /dev/null +++ b/src/scsi2sd-util6/scsi2sd-test.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2018 Michael McMaster +// +// This file is part of SCSI2SD. +// +// SCSI2SD is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// SCSI2SD is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SCSI2SD. If not, see . + + +// For compilers that support precompilation, includes "wx/wx.h". +#include "SCSI2SD_HID.hh" +#include "Dfu.hh" + +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#include +using std::shared_ptr; +#else +#include +#include +using std::tr1::shared_ptr; +#endif + +using namespace SCSI2SD; + +int main() +{ + shared_ptr hid; + try + { + hid.reset(HID::Open()); + if (hid) + { + std::cout << "SCSI2SD Ready, firmware version " << + hid->getFirmwareVersionStr() << "\n"; + + std::vector csd(hid->getSD_CSD()); + std::vector cid(hid->getSD_CID()); + std::cout << "SD Capacity (512-byte sectors): " << + hid->getSDCapacity() << std::endl; + + int errcode; + std::cout << "SCSI Self-Test: "; + if (hid->scsiSelfTest(errcode)) + { + std::cout << "Passed\n"; + } + else + { + std::cout << "FAIL (" << errcode << ")\n"; + } + } + else + { + std::cerr << "Device not found" << std::endl; + } + } + catch (std::runtime_error& e) + { + std::cerr << e.what() << std::endl; + } +} +