Logo Search packages:      
Sourcecode: u3-tool version File versions  Download package

int u3_cd_write ( u3_handle_t device,
uint32_t  block_num,
uint8_t *  block 

Write CD block

This function write's a block to the CD partition. Blocks are 2048 bytes in size.

device U3 device handle
block_num The block number to write
block A pointer to buffer containing block
U3_SUCCESS if successful, else U3_FAILURE and an error string can be obtained using u3_error()

Definition at line 221 of file u3_commands.c.

References packed, and u3_send_cmd().

      uint8_t status;
      uint8_t cmd[U3_CMD_LEN] = {
            0xff, 0x42, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x01
      struct _write_cmd_t {
            uint8_t      scsi_opcode;
            uint16_t command;
            uint8_t  unknown1;
            uint32_t block_num;
            uint32_t unknown2;
      } __attribute__ ((packed)) *write_command;

      // fill command data
      write_command = (struct _write_cmd_t *) &cmd;
      write_command->block_num = htonl(block_num);

      if (u3_send_cmd(device, cmd, U3_DATA_TO_DEV, 2048,
            block, &status) != U3_SUCCESS)
            return U3_FAILURE;

      if (status != 0) {
            u3_set_error(device, "Device reported command failed: status %d", status);
            return U3_FAILURE;

      return U3_SUCCESS;

Generated by  Doxygen 1.6.0   Back to index