Thanks, I'll make the changes this weekend and repost. 

For the auto file identification, I was going to try looking at the frequency ranges in the image file for identification.  These are non-overlapping between the three models, and they are in a fixed location in the image file.   Eg.   The 144 mhz models has a settable tx/rx range between 132 and 152 Mhz (or close to this), the 220 Mhz model has 200-250 mhz, etc.     

The file sizes are the same, AFAIK, for all three, so I can't use that approach.  The image files don't have a consistent or usable "id string" to help identity them ( I did a od/hex dump and reviewed what's there), at least for the two radios ( 2 meter and 220 mhz models) that I have. 

Dave


On Fri, Apr 24, 2015 at 4:45 PM, Dan Smith <dsmith@danplanet.com> wrote:
> All previous features are currently working for this patch, with the
> exception of automatic file identifcation. The TH radios do not have
> a identifer that can safely distingush between the radios, this
> feature is still TBD.  You will need to manually select the correct
> model when you open a radio image file.

None of the other drivers have this problem right now, so I'd hate to
add one that does. Many of our drivers detect by file size. Is this not
possible with this driver for some reason?

> diff -r 31a7494c324a -r d5eee1cd5418 chirp/drivers/th9000.py
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/chirp/drivers/th9000.py Sat Apr 18 22:02:22 2015 -0700
> @@ -0,0 +1,882 @@
> +# Copyright 2012 Dan Smith <dsmith@danplanet.com>

This should be your copyright, with a proper date.

> +#from chirp.settings import RadioSetting, RadioSettingGroup, \
> +#        RadioSettingValueInteger, RadioSettingValueList, \
> +#        RadioSettingValueBoolean, RadioSettingValueString, \
> +#        RadioSettingValueFloat, InvalidValueError

Please don't do this. Remove these lines if you don't need them.

> +#  Chirp Driver for TYT TH-9000D  Radio (2 meter, 1.25 and 70cm radios)
> +#  by David Fannin <dfannin@sushisoft.com>, KK6DF

The copyright, when fixed, should cover this so you can drop it.

> +#
> +#  Version 0.5 (Experimental - Known Bugs and Issues)
> +#  Use for development purposes only!
> +#  Features working:
> +#         - single class file for 3 radio types - 144, 220 and 440 mhz models)
> +#         - Download from Radio
> +#         - Display Memories (only None, Tone, TSQL signalling supported)
> +#         - Save image file
> +#         - memory map decoded (about 90%)
> +#         - Upload to radio
> +#         - Modification of memories
> +#         - feature settings
> +#         - added Startup ID label
> +#
> +#  Features not working:
> +#         - DCS , Cross Signaling
> +#         - Skip channels

I don't think you need to put all this in the driver, except for maybe
the known issues.

Also, the "use for development only" means I shouldn't put this in the
tree, even if the other issues were addressed, is that right?

> +SETTING_LISTS = {
> +        "auto_power_off": APO_LIST,
> +        "bg_color"      : BGCOLOR_LIST,
> +        "bg_brightness" : BGBRIGHT_LIST,
> +        "squelch"       : SQUELCH_LIST,
> +        "timeout_timer" : TIMEOUT_LIST,
> +        "choose_tx_power": TXPWR_LIST,
> +        "tbst_freq"     : TBSTFREQ_LIST,
> +        "voice_prompt"  : BEEP_LIST
> +}
> +
> +
> +#
> +#
> +#

I think you can drop these three blank(ish) lines :)

> +"""
> +Overall Memory Map:
> +
> +    Memory Map (Range 0x0100-3FF0, step 0x10):
> +
> +        Field                   Start  End  Size
> +                                (hex)  (hex) (hex)
> +
> +        1 Channel Set Flag        0100  011F   20
> +        2 Channel Skip Flag       0120  013F   20
> +        3 Blank/Unknown           0140  01EF   B0
> +        4 Unknown                 01F0  01FF   10
> +        5 TX/RX Range             0200  020F   10
> +        6 Bootup Passwd           0210  021F   10
> +        7 Options, Radio          0220  023F   20
> +        8 Unknown                 0240  019F
> +            8B Startup Label      03E0  03E7   07
> +        9 Channel Bank            2000  38FF 1900
> +             Channel 000          2000  201F   20
> +             Channel 001          2020  202F   20
> +             ...
> +             Channel 199          38E0  38FF   20
> +        10 Blank/Unknown          3900  3FFF  6FF  14592  16383    1792
> +            Total Map Size           16128 (2^8 = 16384)
> +
> +
> +"""
> +
> +"""
> +  TH9000/220  memory map
> +  section: 1 and 2:  Channel Set/Skip Flags
> +
> +    Channel Set (starts 0x100) : Channel Set  bit is value 0 if a memory location in the channel bank is active.
> +    Channel Skip (starts 0x120): Channel Skip bit is value 0 if a memory location in the channel bank is active.
> +
> +    Both flag maps are a total 24 bytes in length, aligned on 32 byte records.
> +    bit = 0 channel set/no skip,  1 is channel not set/skip
> +
> +    to index a channel:
> +        cbyte = channel / 8 ;
> +        cbit  = channel % 8 ;
> +        setflag  = csetflag[cbyte].c[cbit] ;
> +        skipflag = cskipflag[cbyte].c[cbit] ;
> +
> +    channel range is 0-199, range is 32 bytes (last 7 unknown)
> +"""

Like Tom said, these should be comments, not strings.

> +"""
> +  TH9000/220  memory map
> +  section: 5  TX/RX Range
> +     used to set the TX/RX range of the radio (e.g.  222-228Mhz for 220 meter)
> +     possible to set range to 220-260Mhz for tx/rx
> +
> +"""

This too.

> +"""
> +  TH9000/220  memory map
> +  section: 6  bootup_passwd
> +     used to set bootup passwd (see boot_passwd checkbox option)
> +
> +  options - bootup password
> +
> +  bytes:bit   type                 description
> +  ---------------------------------------------------------------------------
> +  6         u8 bootup_passwd[6]     bootup passwd, 6 chars, numberic chars 30-39 , see boot_passwd checkbox to set
> +  10        u8 unknown;
> +
> +"""

And this.

> +"""
> +  TH9000/220  memory map
> +  section: 7  Radio Options
> +        used to set a number of radio options
> +
> +  bytes:bit   type                 description
> +  ---------------------------------------------------------------------------
> +  1         u8 display_mode     display mode, range 0-2, 0=freq,1=channel,2=name (selecting name affects vfo_mr)
> +  1         u8 vfo_mr;          vfo_mr , 0=vfo, mr=1
> +  1         u8 unknown;
> +  1         u8 squelch;         squelch level, range 0-19, hex for menu
> +  1         u8 unknown[2];
> +  1         u8 channel_lock;    if display_mode[channel] selected, then lock=1,no lock =0
> +  1         u8 unknown;
> +  1         u8 bg_brightness ;  background brightness, range 0-21, hex, menu index
> +  1         u8 unknown;
> +  1         u8 bg_color ;       bg color, menu index,  blue 0 , orange 1, purple 2
> +  1         u8 tbst_freq ;      tbst freq , menu 0 = 1750Hz, 1=2100 , 2=1000 , 3=1450hz
> +  1         u8 timeout_timer;   timeout timer, hex, value = minutes, 0= no timeout
> +  1         u8 unknown;
> +  1         u8 auto_power_off;   auto power off, range 0-3, off,30min, 1hr, 2hr, hex menu index
> +  1         u8 voice_prompt;     voice prompt, value 0,1 , Beep ON = 1, Beep Off = 2
> +
> + description of function setup options, starting at 0x0230
> +
> +  bytes:bit   type                 description
> +  ---------------------------------------------------------------------------
> +  1         u8  // 0
> +   :4       unknown:6
> +   :1       elim_sql_tail:1   eliminate squelsh tail when no ctcss checkbox (1=checked)
> +   :1       sql_key_function  "squelch off" 1 , "squelch momentary off" 0 , menu index
> +  2         u8 unknown[2] /1-2
> +  1         u8 // 3
> +   :4       unknown:4
> +   :1       inhibit_init_ops:1 //bit 5
> +   :1       unknownD:1
> +   :1       inhibit_setup_bg_chk:1 //bit 7
> +   :1       unknown:1
> +  1         u8 tail_elim_type    menu , (off=0,120=1,180=2),  // 4
> +  1         u8 choose_tx_power    menu , (60w=0,25w=1) // 5
> +  2         u8 unknown[2]; // 6-7
> +  1         u8 bootup_passwd_flag  checkbox 1=on, 0=off // 8
> +  7         u8 unknown[7]; // 9-F
> +
> +"""

Also this.

> +"""
> +  TH9000/220  memory map
> +  section: 8B  Startup Label
> +
> +  bytes:bit   type                 description
> +  ---------------------------------------------------------------------------
> +  7     char start_label[7]    label displayed at startup (usually your call sign)
> +"""

Yep, this too.

> +"""
> +  TH9000/220  memory map
> +  section: 9  Channel Bank
> +         description of channel bank (200 channels , range 0-199)
> +         Each 32 Byte (0x20 hex)  record:
> +  bytes:bit   type                 description
> +  ---------------------------------------------------------------------------
> +  4         bbcd freq[4]        receive frequency in packed binary coded decimal
> +  4         bbcd offset[4]      transmit offset in packed binary coded decimal (note: plus/minus direction set by 'duplex' field)
> +  1         u8
> +   :4       unknown:4
> +   :4       tuning_step:4         tuning step, menu index value from 0-9
> +            5,6.25,8.33,10,12.5,15,20,25,30,50
> +  1         u8
> +   :4       unknown:4          not yet decoded, used for DCS coding?
> +   :2       channel_width:2     channel spacing, menu index value from 0-3
> +            25,20,12.5
> +   :1       reverse:1           reverse flag, 0=off, 1=on (reverses tx and rx freqs)
> +   :1       txoff:1             transmitt off flag, 0=transmit , 1=do not transmit
> +  1         u8
> +   :1       talkaround:1        talkaround flag, 0=off, 1=on (bypasses repeater)
> +   :1       compander:1         compander flag, 0=off, 1=on (turns on/off voice compander option)
> +   :2       unknown:2
> +   :2       power:2             tx power setting, value range 0-2, 0=hi,1=med,2=lo
> +   :2       duplex:2            duplex settings, 0=simplex,2= minus(-) offset, 3= plus (+) offset (see offset field)
> +
> +  1         u8
> +   :4       unknown:4
> +   :2       rxtmode:2           rx tone mode, value range 0-2, 0=none, 1=CTCSS, 2=DCS  (ctcss tone in field rxtone)
> +   :2       txtmode:2           tx tone mode, value range 0-2, 0=none, 1=CTCSS, 3=DCS  (ctcss tone in field txtone)
> +  1         u8
> +   :2       unknown:2
> +   :6       txtone:6            tx ctcss tone, menu index
> +  1         u8
> +   :2       unknown:2
> +   :6       rxtone:6            rx ctcss tone, menu index
> +  1         u8 txcode           ?, not used for ctcss
> +  1         u8 rxcode           ?, not used for ctcss
> +  3         u8 unknown[3]
> +  7         char name[7]        7 byte char string for channel name
> +  1         u8
> +   :6       unknown:6,
> +   :2       busychannellockout:2 busy channel lockout option , 0=off, 1=repeater, 2=busy  (lock out tx if channel busy)
> +  4         u8 unknownI[4];
> +  1         u8
> +   :7       unknown:7
> +   :1       scrambler:1         scrambler flag, 0=off, 1=on (turns on tyt scrambler option)
> +"""

You guessed it, this as well ;)

I'd like to see the above fixed up on the next revision. From the looks
of it, this is more than just ready for development purposes. I think
functionally, it's probably fine for testing with a wider audience,
especially since you've got the runtime experimental warning bit.

Thanks!

--Dan


_______________________________________________
chirp_devel mailing list
chirp_devel@intrepid.danplanet.com
http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers