RASCSI/cpp/devices/scsi_printer.h

69 lines
1.8 KiB
C
Raw Normal View History

Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
//---------------------------------------------------------------------------
//
// SCSI Target Emulator PiSCSI
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
// for Raspberry Pi
//
// Copyright (C) 2022-2023 Uwe Seimet
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
//
// Implementation of a SCSI printer (see SCSI-2 specification for a command description)
//
//---------------------------------------------------------------------------
#pragma once
#include "interfaces/scsi_printer_commands.h"
#include "primary_device.h"
#include <fstream>
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
#include <string>
Use vector for INQUIRY data, LUN list can have gaps, made methods const (#713) * Use vector for INQUIRY data, Inquiry() is const, moved EVPD check * Moved code * Fixed warning * Updated memcpy * Set length * Limit result vector size * Limit result buffer size * Inquiry() result buffer handling update * Logging update * Inquiry cleanup * NEC drive can also use PrimaryDevice::Inquiry() * NEC drive is never removable * Comment update * Bridge can also use PrimaryDevice::Inquiry() * Removed unused method argument * Comment update * Updated comment * Updated REQUEST SENSE buffer handling * Fixed typo * Fixed typo * Re-added comment * Updated additional length handling * Check for INQUIRY command support first * Added assertion * Size handling update * Renaming * Renaming * Removed obsolete casts * Cleanup * Moved error codes to scsi_defs namespace * Fixed ReadDefectData10 * Comment update * Updated buffer handling * Data type update * SendDiagnostic is now const * Removed obsolete forward declaration * removed unused enum * Reduced method visibility * Renaming * GetSendDelay() can be const * Made method const * Made method const * Added TODO * Use iterator * Made method const * Revert "Made method const" This reverts commit 38412b8dddbd1a60f34baa663a12d8285190e3a8. * No need to sort all set/maps * Do not sort all sets * Removed more unnecessary sorting * Cleaned up includes * More include cleanups * Updated REPORT LUNS * LUNs must not be consecutive anymore * Updated detaching of LUN * Improvements for devices without LUN 0 * Assume LUN 0 is always present * Enforce presence of LUN 0 * Updated error handling
2022-03-02 02:25:22 +00:00
#include <unordered_map>
#include <span>
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
using namespace std;
class SCSIPrinter : public PrimaryDevice, private ScsiPrinterCommands
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
{
uint64_t file_print_count = 0;
uint64_t byte_receive_count = 0;
uint64_t print_error_count = 0;
uint64_t print_warning_count = 0;
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
static const int NOT_RESERVED = -2;
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
static constexpr const char *PRINTER_FILE_PATTERN = "/piscsi_sclp-XXXXXX";
inline static const string FILE_PRINT_COUNT = "file_print_count";
inline static const string BYTE_RECEIVE_COUNT = "byte_receive_count";
inline static const string PRINT_ERROR_COUNT = "print_error_count";
inline static const string PRINT_WARNING_COUNT = "print_warning_count";
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
public:
explicit SCSIPrinter(int);
~SCSIPrinter() override = default;
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
bool Init(const param_map&) override;
void CleanUp() override;
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
param_map GetDefaultParams() const override;
vector<uint8_t> InquiryInternal() const override;
bool WriteByteSequence(span<const uint8_t>) override;
vector<PbStatistics> GetStatistics() const override;
private:
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void TestUnitReady() override;
void ReserveUnit() override { PrimaryDevice::ReserveUnit(); }
void ReleaseUnit() override { PrimaryDevice::ReleaseUnit(); }
void SendDiagnostic() override { PrimaryDevice::SendDiagnostic(); }
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void Print() override;
void SynchronizeBuffer();
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
string file_template;
string filename;
ofstream out;
Added support for SCSI printer device (SCLP) (#670) * Fixed buster compile-time issue * Host services inherit from ModePageDevice * Call base class * Visibility update * Updated includes * Updated dispatcher * Added TODOs * Logging update * Code cleanup * Use namespace instead of class for ScsiDefs * Renaming * Cleanup * Use dispatcher template in order to remove duplicate code * Updated all dispatchers * Clean up commands * Removed duplicate code * Removed duplicate code * Updated template definition * Fixed typo * Fixed warning * Code cleanup * Device list must be static * Cleanup * Logging update * Added comments * Cleanup * Base class update * SCSIBR is not a subclass of Disk anymore, but of PrimaryDevice * Updated includes * Fixed compile-time issue on the Pi * Header file cleanup * Interface cleanup * Removed wrong override * include file cleanup * Removed obsolete usage of streams * Removed more stream usages * Stream usage cleanup * Include cleanup * Renaming * Include cleanup * Interface update * SCLP device skeleton * Initial RELEASE/RESERVE UNIT * Added full set of commands * Extracted command phase code * Stripped SCSI controller code * Removed unused code * Commented out code * Initial naive implementation * Added debug output * Disable printing for now * Updated file handling * Updated DataOut() * Added comment * Updated assertion * Comment update * Updated assertion * Code cleanup * Reset bytes to transfer * Reverted change * Refactoring * Moved assertion * Updated ReceiveBytes() * Removed override * Added interface * Code cleanup * Updated TEST UNIT READY * Added flag for byte-oriented transfer * Updated TEST UNIT READY * Length handling update * Updated bytecount handling * Fixed warning * Added TODO * Updated assertion * Enabled priting * Updated error handling * Code cleanup * Logging update * First working version * Use temporary file * Logging update * Handle parameters * Updated format string * Updated logging * File handling update * Code cleanup * Fixed buffer size * Updated file handling * Manpage update * Initial reservation handling * Updated reservation handling * Initial reservation testing * Remember initiator ID * Extract initiator ID * Updated SCSI initiator ID handling * Logging update * Added reservation timeout * Updated timeout handling * Code cleanup * Only pass initiator ID to *SCSI* controller * Added comments * Added comment * Implemented STOP PRINT * Comment update * Comment update * Comment update * Added comment * Comment update * Removed useless comments * Updated printer parameter handling * Updated parameter handling * Manpage update * Manpage update * Comment update * Default printer product name update * Renaming * Updated logging * Logging update * Logging update * Comment update * Code cleanup * Added printer shortcut * Comment update * Comment update * Output formatting update * Updated error handling * Code cleanup * More cleanup * Revert "More cleanup" This reverts commit 05708986ee161c118bb0d3a17c1ddf2f201ccfb8. * Output formatting update * Output format update * Sort parameters * Comment update * Improved parsing of parameters * Manpage update * Updated SCSI level * Removed magic constants * Removed magic constant * Template update * Template usage update * Get rid of SASIDEV for printer * Get rid of SASIDEV for host services * Moved initiator_id field * Moved field * Moved field * Added comment * Error handling must use effective LUN * Removed obsolete casts * Removed unused method declarations * Comment update * Code cleanup * More code cleanup * Optimization * Removed duplicate code * Logging update * Fixed warning * Code cleanup * Added TODOs * TODO update * Backwards compatibility update * Comment update
2022-02-17 02:04:42 +00:00
};