SCSI查询数据

时间:2013-08-22 10:41:57

标签: scsi

我是SCSI编程的新手,因此很抱歉提出基本问题。我通过6字节CDB将SCSI查询命令发送到磁带设备

ccb =(Exec_IO_CCB *)(buffer + header_size);

ccb-> ccb_length = sizeof(Exec_IO_CCB);

ccb-> cam_opcode = 0x1;

ccb-> connect_id = 0;

ccb-> sense_buf_ptr =(长)(header_size + ccb-> ccb_length);

ccb-> sense_buf_length = MAX_SENSE_LEN;

ccb-> time_out = CAM_TIMEOUT;

ccb-> cdb_length = 6;

/ *对于INQUIRY设置cam_flags和cdb [0] * /

ccb-> cam_flags = NO_DATA;

ccb-> cdb [0] =询问; / * 0x12用于查询命令的SCSI操作码* /

ccb-> cdb [1] = 0;

ccb-> cdb [2] = 0;

ccb-> cdb [3] = 0;

ccb-> cdb [4] = 3200;

ccb-> cdb [5] = 0;

SCSI命令成功。我如何捕获INQUIRY命令的输出,以便我可以得到 供应商ID /产品ID ??

我已将Execute I / O SCSI缓冲区声明如下

typedef struct {

long        ccb_address;            /* Address of this CCB               */
short       ccb_length;             /* CAM Control Block Length          */
char        cam_opcode;             /* CAM Operation Code                */
char        status;                 /* CAM Status                        */
long        connect_id;             /* Connect ID - no fields supported  */
long        cam_flags;              /* CAM Flags                         */
long        pd_pointer;             /* Peripheral driver pointer         */
long        next_ccb_ptr;           /* Next CCB Pointer                  */
long        req_map_info;           /* Request mapping information       */
long        call_on_comp;           /* Callback on completion            */
long        data_buf_ptr;           /* Data Buffer Pointer               */
long        data_xfer_length;       /* Data transfer length              */
long        sense_buf_ptr;          /* Sense information buffer pointer  */
char        sense_buf_length;       /* Sense information buffer length   */
char        cdb_length;             /* Command Descriptor Block (CDB)    **
                                    **  length                           */
short       num_sg_entries;         /* Number of scatter/gather entries  */
long        vendor_unique;          /* Vendor Unique field               */
char        scsi_status;            /* SCSI status                       */
char        auto_resid;             /* Auto sense residual length        */
short       reserved;               /* Reserved                          */
long        resid_length;           /* Residual length                   */
char        cdb[12];                /* Command Descriptor Block (CDB)    */
long        time_out;               /* Time-out value                    */
long        msg_buf_ptr;            /* Message buffer pointer            */
short       msg_buf_length;         /* Message buffer length             */
short       vu_flags;               /* Vendor-unique flags               */
char        tag_queue_act;          /* Tagged Queue action               */
char        tag_id;                 /* Tag ID (target only)              */
char        init_id;                /* Initiator ID (target only)        */
char        reserved2;              /* Reserved                          */

} Exec_IO_CCB;

此结构永远不会捕获SCSI输出?

我已将查询结构声明如下。但我不确定Inquire命令会如何 填充Inquiry_Data结构数据??

typedef struct {

short data_valid;           /* Flag that indicates whether or not the */
                            /*   structure has been filled in with    */
                            /*   inquiry data from the device.        */
byte  periph_qual;
byte  periph_dev_type;
byte  rmb;
byte  iso_version;
byte  ecma_version;
byte  ansi_version;
byte  resp_data_format;
byte  rel_adr;
byte  sync;
byte  linked;
byte  cmd_que;
byte  sft_rst;
char  vendor_id[9];
char  prod_id[17];
char  prod_rev[5];
char  reserved;

} Inquiry_Data;

1 个答案:

答案 0 :(得分:0)

你已经为cdb [4]分配了一个短片,但是cdb [4]是一个字节。由于编译器会截断,因此赋值可能会为0。由于字节3和4是分配长度,因此您告诉目标不要发送任何内容。也许你准备将32分配给cdb [4];但由于您的Inquiry_Data结构是44字节,您可能想要将44分配给cdb [4]。