2022-02-17 02:04:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-08-26 01:01:39 +00:00
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
2022-02-17 02:04:42 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
// 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 <string>
|
2022-03-02 02:25:22 +00:00
|
|
|
#include <unordered_map>
|
2022-02-17 02:04:42 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#define TMP_FILE_PATTERN "/tmp/rascsi_sclp-XXXXXX"
|
|
|
|
|
|
|
|
class SCSIPrinter: public PrimaryDevice, ScsiPrinterCommands
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
SCSIPrinter();
|
|
|
|
~SCSIPrinter();
|
|
|
|
|
|
|
|
virtual bool Dispatch(SCSIDEV *) override;
|
|
|
|
|
2022-03-02 02:25:22 +00:00
|
|
|
bool Init(const unordered_map<string, string>&);
|
2022-02-17 02:04:42 +00:00
|
|
|
|
2022-03-02 02:25:22 +00:00
|
|
|
vector<BYTE> Inquiry() const override;
|
2022-02-17 02:04:42 +00:00
|
|
|
void TestUnitReady(SCSIDEV *);
|
|
|
|
void ReserveUnit(SCSIDEV *);
|
|
|
|
void ReleaseUnit(SCSIDEV *);
|
|
|
|
void Print(SCSIDEV *);
|
|
|
|
void SynchronizeBuffer(SCSIDEV *);
|
|
|
|
void SendDiagnostic(SCSIDEV *);
|
|
|
|
void StopPrint(SCSIDEV *);
|
|
|
|
|
|
|
|
bool WriteBytes(BYTE *, uint32_t) override;
|
|
|
|
bool CheckReservation(SCSIDEV *);
|
|
|
|
void DiscardReservation();
|
|
|
|
void Cleanup();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
typedef PrimaryDevice super;
|
|
|
|
|
|
|
|
Dispatcher<SCSIPrinter, SCSIDEV> dispatcher;
|
|
|
|
|
|
|
|
char filename[sizeof(TMP_FILE_PATTERN) + 1];
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
int reserving_initiator;
|
|
|
|
|
|
|
|
time_t reservation_time;
|
|
|
|
int timeout;
|
|
|
|
};
|