Hi Jim I suppose you have two different error for the two different situation: - if you place the function definition inside another one you have to augment the indentation level - if you define the function at the object level it will become a method and should be defined and called differently
There's one more option which is place it in the global scope but ... My suggestion is to place it inside the set_settings, you can look at _filter definition in get_settings (uv5r.py) for an example.
BTW It would be easier to test/debug your code if you attach the whole source or a hg patch (better) so we can see all the details and replicate the problem.
73 de IZ3GME Marco
On 22/01/2013 11:41, Jim Unroe wrote:
Thanks Les and Marc0,
I tried this quickly before work and ran into this problem "NameError: global name 'convert_freq_to_bytes' is not defined"
I study some other drivers after work to see if I can find something similar to mimic. Here is how I am trying to use it just in case you can spot what I am doing wrong.
I've added 2 "elif" bits of code to the set_settings procedure
def set_settings(self, settings): _settings = self._memobj.settings[0] for element in settings: if not isinstance(element, RadioSetting): self.set_settings(element) continue elif element.get_name() == "vfoa.freq": convert_freq_to_bytes(self._memobj.vfoa.freq,
element.value) elif element.get_name() == "vfob.freq": convert_freq_to_bytes(self._memobj.vfob.freq, element.value) try:
Then I placed the following just ahead of my menu item
def convert_freq_to_bytes(real_freq): bytes = [ 0 for x in range(0,8) ] # init list with 8 times 0 real_freq = int(freq * 100000) # it has to be integer for i in range(7, -1, -1): # go from 7 to 0 bytes[i] = real_freq%10 # extract last digit real_freq /= 10 # throw away last digit return bytes
When I got the "not defined" error, I moved it above "def set_settings(self, settings):" but got the same "not defined".
Jim
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