[chirp_devel] def convert_freq_to_bytes(real_freq):

Jim Unroe
Mon Jan 21 19:08:08 PST 2013


Hi group,

I'm trying to create a helper function to convert a floating point number
to a group of bytes

For example I have this value: 146.52000
I think I need it change to something like
0x01,0x04,0x06,0x05,0x02,0x00,0x00,0x00

The first thing I beieve I need to do is shift the decimal point to the
right 5 places. So I did this

    real_freq *= 100000.0

I believe this gets me 14652000

Now I think I need to do something like this to separate the individual
digits

    digits =[int(i) for i in str(real_freq)]

I'm not positive, but I think this makes an array something like

digits[0] = 1
digits[1] = 4
digits[2] = 6
digits[3] = 5
digits[4] = 2
digits[5] = 0
digits[6] = 0
digits[7] = 0

Here is where I'm stuck. I've tried a few think but so far no luck. I've
searched the other drivers to see if I could locate something similar. If
there is, I missed it.

Then ultimately, I think I need to end with

    return bytes

So am I on the right track? Any advice on what I need to do next.

Thanks,
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20130121/bc2b71d5/attachment-0001.html 


More information about the chirp_devel mailing list