Humax USB codes

From Smop.co.uk

Jump to: navigation, search

Most commands fall into one of two camps depending on whether they send data _to_ or receive data _from_ the Humax. I wrote two commands to be used by these camps - sendDataCmd and readDataCmd.

Contents

sendDataCmd

  1. send a CBW with the supplied command and amount of data that will be transferred
  2. usb_bulk_write the supplied data (checks all the bytes were sent)
  3. checks the CSW for any residual data
  4. returns the amount of data sent (minus residual data)

readDataCmd

  1. send a CBW with the supplied command and the size of the receive buffer
  2. usb_bulk_read into the buffer data from the device (checks all bytes were received)
  3. checks the CSW for any residual data
  4. returns the amount of data received (minus residual data)


USB codes

Here are the details of the various commands available. Once again, many thanks to Andy Chappell for these details, and absolutely no thanks whatsoever to Humax who havn't even the decency to reply to my enquiries, let alone provide any help, documentation or contacts.

humaxGetNoPartitions [W\0\0\0\0\0\0\0]

reads 4 bytes, partitions =

  buf[3] + (buf[2] << 8) + (buf[1] << 16) + (buf[0] << 24)

humaxSetDiskNo [X\0\0\0\0\0\0\0]

sends 4 bytes. buf[0] = 0x0 for disk 0 (mp3), 0x1 for video.

humaxGetDiskSpace [L\0\0\0\0\0\0\0]

reads 16 bytes. Read these bytes like this:

     free = buf[4] + (buf[5] << 8) + (buf[6] << 16) + (buf[7] << 24)  + (buf[0] * 1000000000);
     total = buf[12] + (buf[13] << 8) + (buf[14] << 16) + (buf[15] << 24) + (buf[8] * 1000000000);

humaxSetDirectory [V\0\0\0\0\0\0\0]

sends null-terminated directory name. TODO: full and/or relative?

humaxCreateDir [S\0\0\0\0\0\0\0]

sends null-terminated directory name. TODO: full and/or relative?

humaxFormatDiskOne [U\0\0\0\0\0\0\0]

sends nothing (just performs CBW and CSW) - formats the MP3 disk.

humaxRenameFile [Rabcd\0\0\0]

Renames file/directory by sending "oldpath\0newpath\0" to the Humax. abcd are worked out as follows:

  a=(strlen(oldpath) +1) >>8;
  b=(strlen(oldpath) +1) & 0xff;
  c=(strlen(newpath) +1) >>8;
  d=(strlen(newpath) +1) & 0xff;

humaxDeleteFile [T\0\0\0\0\0\0\0]

Sends null-terminated filename/directory to be deleted. Apparently this can be problematic and even the Humax software has two attempts - one with a trailing slash, one without.

humaxGetNoDirEntries [J\0\0\0\0\0\0\0]

Reads four bytes which yields number of directory entries as follows:

  buf[3] + buf[2] << 8

humaxGetDirEntries [K\0\0\0\0\0\0\0]

Reads humaxGetNoDirEntries * 72 bytes. Each 72 bytes can be read as follows:

  0-59 = name
  60 & 0x01 = entry is a directory
  68 + (69 << 8) + (70 << 16) + (71 << 24) + (64 * 1000000) = size

File transfer

Ignoring gotchas (see later), the sequence to read a file from the Humax is:

  1. humaxXferBeginDevToHost
  2. humaxXferNextDevToHost (until finished)
  3. humaxXferEnd

To send a file to the Humax it is very similar:

  1. humaxXferBeginHostToDev
  2. humaxXferNextHostToDev (until finished)
  3. humaxXferEnd

humaxXferBeginDevToHost [ M\1\0\0\0\0\0\0]

send filename to be sent from Humax TODO: relative and/or absolute?

humaxXferBeginHostToDev [ M\2\0ab\0cd]

TODO: relative and/or absolute? send filename to be created on Humax. abcd are created as follows:

a = (filesize >>24) & 0xff;
b = (filesize >> 16) & 0xff;
c = (filesize) & 0xff;
d = (filesize >> 8) & 0xff;

humaxXferEnd [N\0\0\0\0\0\0\0]

sends filename on Humax to stop reading from/writing to.

humaxXferNextDevToHost [O\0\0\0\0\0\0\0]

reads given amount of data from Humax

humaxXferNextHostToDevDevToHost [P\0\0\0\0\0\0\0]

writes given amount of data to Humax

Personal tools