            humaxrw v1.15
            =============

This program will copy files from the disk fitted to the Humax 9200T PVR 
and also copy them back onto a Humax formatted disk. You will need the 
son_t/phew cable modification or directly connect the disk(s) to a host 
ide interface for the transfer.

This program will run on Intel/AMD 32 bit machines running Linux/Windows. It 
was originally developed on Linux.

Installation
============

Just copy it into a suitable directory. You may need to be an admin user to be
able to read/write the raw devices when running the program (see examples
below).

The device names for a directly connected disk are as follows:

  On Linux hosts the device names are typically: /dev/hda, /dev/hdb etc.

  On Windows the raw devices are \\.\physicaldrive0, \\.\physicaldrive1 etc.
  but humaxrw will accept names shortened to 0:, 1: etc.

WARNINGS
========
1. Use this program at your own risk. It has worked ok under testing but there
   is a chance that there be some unknown disk corruption on some boxes which
   could cause further problems.

2. Ensure that you can successfully list & read files from the Humax disk using
   this program before attempting to write anything back. This is to check that
   the cabling mod. and to check that the OS fully supports large file systems.

3. Advanced options are in uppercase (e.g. -M). These are used to discover 
   more about the Humax file system.

*Important* - Do *not* allow Windows to "Initialise" the disk in disk/device
-----------   manager. The disk should *not* appear under "My Computer".

Usage examples (assumes that the Humax disk is 2:):

   (Most functions will accept an additional -y option to suppress prompts about
   overwriting or deleting files)

   To display the program options
      humaxrw -h

   To list the files on the Humax disk
      humaxrw 2: -l

   To display the full information about entry numbers 20, 23 to 26 & 40 to 43
      humaxrw 2: -i 20,23-26,40-43

   To get the ts file (and associated files) for each entry 20 and 23 to 26
   and copy them to the current working directory.
      humaxrw 2: -g 20,23-26

   To copy (put) a file back onto a new Humax disk (say 3:)
      humaxrw 3: -p file.ts
   To copy all the ts files in the current directory onto the Humax disk
      humaxrw 3: -p *.ts
  
   To delete entry numbers 20 and 23 to 26 on the disk:
   [Note: If the file is protected, use the -u option to unprotect first.]
      humaxrw 2: -u 20,23-26
      humaxrw 2: -d 20,23-26

   To perform a direct transfer of entry 20 and 23 to 26 from one Humax disk 
   (2:) to another Humax disk (3:)
      humaxrw 2: 3: -g 20,23-26

   To create backup files for all video files on the Humax disk 
   (excluding files which already exist on the Linux disk)
      humaxrw 2: -b

   To perform a direct backup of all video files on one Humax disk (2:)
   to another Humax disk (3:)
      humaxrw 2: 3: -b

Recovery Mode
=============

If the record list has disappeared or has become corrupt you may be able to 
recover some recordings using the recovery mode. In this mode it is not 
possible to copy hre files from the Humax drive. If the record list has been
lost the file information will be incomplete. humaxrw guesses the name of the
recording using the programme detailed information (which could be wrong!).
Each programme may have several entries so it will attempt to show all the
entries in this mode. This is the only mode which can also be used to copy 
the two buffers. There is an additional '-n' opton which disables the reading
of any programme info. This can be used to recover the ts files when the info
is corrupt.

To use the recovery mode:

  To list the files (note that the list order may be different to that 
  produced in normal mode):
    humaxrw 2: -r -l
    (-n can be added if disk corruption causes problems with the list)

  To display the full information about entry numbers 10 to 12 and 18
      humaxrw 2: -i 10-12,18

  To get file numbers 10 to 12 and 18 to the current directory as 
  "recover_nnnn.ts" where "nnnn" is 0010, 0011, 0012 & 0018.
    humaxrw 2: -r -g 10-12,18
     (-n can be added if disk corruption causes problems with the list but
      only the ts & elu files will be copied in this case)

To copy files back after using recovery mode:

  In recovery mode the record klist is assumed to be corrupt so no hre files
  are copied from the Humax disk. The utility ts2hrw will create hre files 
  given a list of ts files. iIt will not replace any existing hre files.
  After the hre files have been created it is then possible to use the 
  humaxrw "put" function as above to copy the files back onto the Humax disk.

    ts2hrw  *.ts

  Note: If the elu files are not present the Humax elapsed time and timebar
  will run slow.

  Record list swapping:

  The Humax maintains two copies of the record list - a main copy and a backup
  copy. In recovery mode the -s option swaps the two copies over.

      humaxrw 2: -r -s

  Note that I am not sure how often the Humax updates the backup copy. It
  may not include all of the recent changes so you my find that some later 
  recordings are inaccessible. Alternatively, deleted recordings may appear
  in the list but not point to anything or may access another recording.
  Use with care and only when the main list is missing/corrupt.

Modify Function
===============

*Warning* This is an advanced option for those who like to tinker.
Modifying some locations will cause incorrect operation of the Humax.

This is used to modify parameters within the record list entry without
transferring files.
The valid offset ranges are 0 to 303 for the 9200T/PVR-Smart and 
0 to 315 for the 9200C. The valid data range is 0 to 255.

  To change the value at offset 105 to 27 for entry number 10:
    humaxrw 2: -M 10 -O 105 -V 27
  or..
    humaxrw 2: -M 10 -O 0x69 -V 0x1b

  To get just the hre file for recording 10:
    humaxrw 2: -H 10

MG Icon
-------

When viewing a previously recorded programme which starts with an unencrypted
section and then continues with a previously encrypted section, the Humax may
not play the encrypted section if the MG icon has not been set. This is despite
the fact that the file has been decrypted on the disk by the viewer card.

  To turn on the MG icon for recording 10:
    humaxrw 2: -M 10 -O MG -V 1
  To tun off the MG icon for recording 10:
    humaxrw 2: -M 10 -O MG -V 0
  This will not transfer any data - the record list is changed on the 
  Humax disk.

Files
=====

When copying a .ts file to or from the Humax disk three other associated 
files are also copied (when not in recovery mode). These are:

   .epg : contains the detailed program information 
          - does not have to be present for playback of the ts file

   .elu : Contains timestamps and offsets pointing to some of the 
          synchronisation bytes within the ts file. If this file is not 
          present when playing a recording the timebar may show an incorrect 
          length and the elapsed timer indicator on the front panel display
          may also run at the wrong speed. It may also be required for  
          proper editing of the recording on the Humax.
          This file does not have to be present for playback of the ts file.

   .hre : This is the record list entry for the particular file.
          In addition to the information shown in the record list, it 
          contains the following:
             PIDs for most of the streams contained within the ts file.
             The point at which playback is to start.
             Bookmarks.
             Some other parameters which are unknown.
          This file is essential for the Humax to playback the ts file.

Known Bugs
==========

Command line only
No sorting of entries
Fragmentation of new files could be reduced with an improved file creation
algorithm.
9200C info display disabled
The -D option should be a function of humaxcheck instead. In order to
implement this in humaxcheck, it would have to be re-written. This is not
likely to happen any time soon.

Version History
===============

1.15  Added -Z option to delete 'epgsave.dat' which fixes the problem where it
      can become corrupt and cause the machine to freeze 15 seconds after 
      startup.
      Entries in record list which have no associated .av (.ts) file
      are now displayed in parenthesis and can be deleted.
      (ts2hrw) Improved handling of corrupt ts files
      Added -D option to help listing

1.14  Added support for the 9300T

1.13  Stricter filename legalisation

1.12a Added warning to the Windows version of this file about not allowing
      Windows to "initailise" the disk.

1.12  Fixed problem where a phantom entry would appear in the Record List
      on the 9200 if all the recordings were deleted using humaxrw.
      Fixed bug (introduced in v1.11) which causes program crash when
      "putting" files to an empty disk

1.11  Identify partition in error messages
      Improved error reporting
      Only check 1st partition when -r & -n options used

1.10a Fixes problem with ts2hrw creating hre files of the wrong size.

1.10  Fixes problem in detecting the machine type on some Finnish versions of 
      the 9200.

1.09  It will now copy epg & elu files as well as the ts file when in recovery 
      mode.
      Added the -E option. This fixes the problem where the info. display is
      not correct when programmes recorded with earlier versions of firmware
      are displayed on V1.00.20 or later. It updates the file format to
      V1.00.20 or later. 
      The recovery mode with -n option will now only look at the first
      partition if the partition table is corrupt.
      Added further checks to the partition tables and file allocation tables.
      Enabled 9200C writes (info disabled)
      Additional recovery mode option '-s' added
      Fixed listing for when invalid characters are present.
      Improved performance when copying humax disk to humax disk.
      Fixed potential lock-up problem in recover mode
      Added ts2hrw so that files retrieved using recover mode can be put back.

1.08  Fixed problem with 9200T trashing the record list if the first recording 
      was transferred first onto a freshly formatted disk.
      Extra checks added.
      Fixed recover file numbering when range used.
      Added the -x option. This when used with the -l list option will show 
      the internal filenames which can be used with humaxdiag.

1.07  Fixed the problems with the display of detailed programme info.
      One problem was due to the different file format used by 1.00.20
      firmware. The info should now be displayed correctly by humaxrw for
      recordings created with both old and new firmware.

1.06  Added progress indication when "putting" multiple files

1.05  Added list specification to most options
      Added file wildcard processing to the put (-p) option
      Added the advanced (uppercase) functions (-H -M -O -V)
      Added read only support for the 9200C
      Added a wait for keypress option (-w) 

1.04  Added support for PVR-Smart (Australia)
      Added the unprotect option. It will no longer delete protected files.
      Added extra checks on host free space (Humax disk free space was
      already checked).

1.03  Fixed a problem creating a new recording if '255.av' exists
      Added the -y option to enable multiple files copying on Win32

1.02  Fixed the date in Win32 listings
      Improved missing file detection when "getting" a file from the Humax
      disk.
      Removed duplicate entries in the info display.
      Listing now ignores entries where the associated av file doesn't exist

1.01  Added recovery mode. Improved error reporting.
      Win32 port.

1.00  Large rewrite. Added the delete option and 
      direct Humax disk to Humax disk transfers
      Changed the command line options for specifying the Humax disk

0.04  Fixed last byte of epg entry

0.03  Fixed times in EPG

0.02  Added the backup option

0.01  Initial beta release

Acknowledgements
================

Big thanks to phew for his work in deciphering the disk format, to son_t for
his help and to boden01 for information on the MG icon.

(c) xyz321 23/12/09

