<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I was wondering what "capacity" meant. So, if that's just the
count, where is the actual linkage between the bank and the
memories? Anyway, the Anytone model I'm working on right now is
the same (each mem is limited to one bank, or none):</p>
<div style="color: #d6deeb;background-color: #000000;font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;font-weight: normal;font-size: 12px;line-height: 16px;white-space: pre;"><div><span style="color: #c792ea;font-style: italic;">class</span><span style="color: #d6deeb;"> </span><span style="color: #ffcb8b;">AnytoneBankModel</span><span style="color: #d6deeb;">(</span><span style="color: #addb67;">chirp_common</span><span style="color: #d6deeb;">.</span><span style="color: #addb67;">BankModel</span><span style="color: #d6deeb;">):</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">"""</span></div><div><span style="color: #ecc48d;"> The Anytone bank model, for the radios that support it, is that a memory</span></div><div><span style="color: #ecc48d;"> channel can only belong to one bank at a time. There are 10 banks (A-J </span></div><div><span style="color: #ecc48d;"> with no alternate names). The mapping is done in a block of bytes that </span></div><div><span style="color: #ecc48d;"> correspond to the 750 memories (one byte per memory). The possible values </span></div><div><span style="color: #ecc48d;"> are 0-9 (A-J) or 15 (x0F) for "off".</span></div><div><span style="color: #ecc48d;"> </span><span style="color: #d9f5dd;">"""</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">__init__</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">radio</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">name</span><span style="color: #76aba8;">=</span><span style="color: #d9f5dd;">"</span><span style="color: #ecc48d;">Banks</span><span style="color: #d9f5dd;">"</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">num_banks</span><span style="color: #76aba8;">=</span><span style="color: #f78c6c;">10</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">num_memories</span><span style="color: #76aba8;">=</span><span style="color: #f78c6c;">750</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #addb67;">super</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">AnytoneBankModel</span><span style="color: #d9f5dd;">,</span><span style="color: #82aaff;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">).</span><span style="color: #82aaff;">__init__</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">radio</span><span style="color: #d9f5dd;">,</span><span style="color: #82aaff;"> name</span><span style="color: #d6deeb;">)</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._bank_bounds </span><span style="color: #76aba8;">=</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">range</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">num_banks</span><span style="color: #d6deeb;">)</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._mem_bounds </span><span style="color: #76aba8;">=</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">range</span><span style="color: #d6deeb;">(</span><span style="color: #f78c6c;">1</span><span style="color: #d9f5dd;">,</span><span style="color: #82aaff;"> num_memories </span><span style="color: #76aba8;">+</span><span style="color: #82aaff;"> </span><span style="color: #f78c6c;">1</span><span style="color: #d6deeb;">)</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._banks </span><span style="color: #76aba8;">=</span><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">[</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #d6deeb;"><span style="color: #d6deeb;"></span><span style="color: #addb67;">chirp_common</span><span style="color: #d6deeb;"></span>.</span><span style="color: #b2ccd6;">Bank</span><span style="color: #d6deeb;">(</span><span style="color: #8eace3;">self</span><span style="color: #d9f5dd;">,</span><span style="color: #82aaff;"> i</span><span style="color: #d9f5dd;">,</span><span style="color: #82aaff;"> string.ascii_uppercase</span><span style="color: #d6deeb;">[</span><span style="color: #82aaff;">i</span><span style="color: #d6deeb;">]) </span><span style="color: #c792ea;font-style: italic;">for</span><span style="color: #d6deeb;"> i </span><span style="color: #c792ea;font-style: italic;">in</span><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._bank_bounds</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">]</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">get_num_mappings</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">return</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">len</span><span style="color: #d6deeb;">(</span><span style="color: #8eace3;">self</span><span style="color: #82aaff;">._banks</span><span style="color: #d6deeb;">)</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">get_mappings</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">return</span><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._banks</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">add_memory_to_mapping</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">memory</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">bank</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._radio.</span><span style="color: #b2ccd6;">set_bank</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">memory.number</span><span style="color: #d9f5dd;">,</span><span style="color: #82aaff;"> bank.</span><span style="color: #b2ccd6;">get_index</span><span style="color: #d6deeb;">())</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">remove_memory_from_mapping</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">memory</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">mapping</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._radio.</span><span style="color: #b2ccd6;">clr_bank</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">memory.number</span><span style="color: #d6deeb;">)</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">get_mapping_memories</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">bank</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">"""</span><span style="color: #ecc48d;">Returns a list of all memories assigned to the given bank</span><span style="color: #d9f5dd;">"""</span></div><div><span style="color: #d6deeb;"> memories </span><span style="color: #76aba8;">=</span><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">[]</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">for</span><span style="color: #d6deeb;"> i </span><span style="color: #c792ea;font-style: italic;">in</span><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._mem_bounds:</span></div><div><span style="color: #d6deeb;"> bank_index </span><span style="color: #76aba8;">=</span><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._radio.</span><span style="color: #b2ccd6;">get_bank</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">i</span><span style="color: #d6deeb;">)</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">if</span><span style="color: #d6deeb;"> bank_index </span><span style="color: #c792ea;">is</span><span style="color: #d6deeb;"> </span><span style="color: #c792ea;">not</span><span style="color: #d6deeb;"> </span><span style="color: #ff5874;">None</span><span style="color: #d6deeb;"> </span><span style="color: #c792ea;">and</span><span style="color: #d6deeb;"> bank_index </span><span style="color: #76aba8;">==</span><span style="color: #d6deeb;"> bank.</span><span style="color: #b2ccd6;">get_index</span><span style="color: #d6deeb;">():</span></div><div><span style="color: #d6deeb;"> memories.</span><span style="color: #b2ccd6;">append</span><span style="color: #d6deeb;">(</span><span style="color: #8eace3;">self</span><span style="color: #82aaff;">._radio.</span><span style="color: #b2ccd6;">get_memory</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">i</span><span style="color: #d6deeb;">))</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">return</span><span style="color: #d6deeb;"> memories</span></div>
<div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">def</span><span style="color: #d6deeb;"> </span><span style="color: #82aaff;">get_memory_mappings</span><span style="color: #d9f5dd;">(</span><span style="color: #7fdbca;">self</span><span style="color: #d6deeb;">, </span><span style="color: #7fdbca;">memory</span><span style="color: #d9f5dd;">)</span><span style="color: #d6deeb;">:</span></div><div><span style="color: #d6deeb;"> bank_index </span><span style="color: #76aba8;">=</span><span style="color: #d6deeb;"> </span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._radio.</span><span style="color: #b2ccd6;">get_bank</span><span style="color: #d6deeb;">(</span><span style="color: #82aaff;">memory.number</span><span style="color: #d6deeb;">)</span></div><div><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">return</span><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">[]</span><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">if</span><span style="color: #d6deeb;"> bank_index </span><span style="color: #c792ea;">is</span><span style="color: #d6deeb;"> </span><span style="color: #ff5874;">None</span><span style="color: #d6deeb;"> </span><span style="color: #c792ea;font-style: italic;">else</span><span style="color: #d6deeb;"> </span><span style="color: #d9f5dd;">[</span><span style="color: #8eace3;">self</span><span style="color: #d6deeb;">._banks[bank_index]</span><span style="color: #d9f5dd;">]</span></div>
</div>
<p></p>
<p>BTW, "scrabmler_code" is misspelled. <br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 5/24/2023 1:52 PM, Joseph Scanlan
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:1A32FA73-3D49-4E29-A057-EDF42C3E0204@n7xsd.us">
<pre class="moz-quote-pre" wrap="">A memory can not be in more than one bank simultaneously.
A memory need not be in a bank.
Memories are stored sequentially starting from [0]. Each number in banks holds the count of memories in that bank. The count can be 0. So to find the start index of the first memory in a bank we have to sum the sizes of all previous banks.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">On May 23, 2023, at 14:06, Craig Jones via chirp_devel <a class="moz-txt-link-rfc2396E" href="mailto:chirp_devel@intrepid.danplanet.com"><chirp_devel@intrepid.danplanet.com></a> wrote:
I just went through that myself. The first two questions: 1. Can one
memory belong to multiple banks simultaneously? 2. Does every memory
have to belong to at least one bank? The answers determine which base
class you use for the bank model.
You need to implement a bank model so that Chirp can inquire, for
example, which memories are in bank C?
You also need to implement get_bank(), set_bank(), clear_bank() for a
memory (in the radio class), which will be called by the bank model.
Hopefully, that's enough to get you started.
On 5/23/2023 1:47 PM, Joseph Scanlan via chirp_devel wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Does anyone have an example that will help me understand MemoryMapping, MappingModel, Bank, and BankModel classes? I’m working on a driver for the Icom IC-F520 land mobile radio.
The F520 has 256 channels and 16 banks. This is how they look in MEM_FORMAT:
struct {
u16 capacity;
} banks[16];
struct {
char name[10];
u32 inhibit:1,
freq_rx:31;
u32 inhibit_tx:1,
freq_tx:31;
u8 rx_tone_off:1,
rx_tone_digital:1,
unk01:6;
u8 rx_tone;
u8 tx_tone_off:1,
tx_tone_digital:1,
unk02:6;
u8 tx_tone;
u8 unk03:3,
tot_on:1,
lockout_repeater:1,
lockout_busy:1,
power_rf:2;
u8 log_in:2,
log_out:2,
unk04:1,
text_on:1,
unk05:1,
two_tone_unk1:1;
u8 unk06:4,
two_tone_unk2:2
auto_reset_a:1,
unk07:1;
u8 narrow:1,
scrambler_on:1,
scrambler_inhibit:1,
compander_on:1,
unk08:4;
u8 unk09;
u8 scrabmler_code;
u16 unk10;
u16 unk11;
u8 unk12:6,
two_tone_index:2;
} memory[256];
_______________________________________________
chirp_devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:chirp_devel@intrepid.danplanet.com">chirp_devel@intrepid.danplanet.com</a>
<a class="moz-txt-link-freetext" href="http://intrepid.danplanet.com/mailman/listinfo/chirp_devel">http://intrepid.danplanet.com/mailman/listinfo/chirp_devel</a>
Developer docs: <a class="moz-txt-link-freetext" href="http://chirp.danplanet.com/projects/chirp/wiki/Developers">http://chirp.danplanet.com/projects/chirp/wiki/Developers</a>
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
--
This email has been checked for viruses by AVG antivirus software.
<a class="moz-txt-link-abbreviated" href="http://www.avg.com">www.avg.com</a>
_______________________________________________
chirp_devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:chirp_devel@intrepid.danplanet.com">chirp_devel@intrepid.danplanet.com</a>
<a class="moz-txt-link-freetext" href="http://intrepid.danplanet.com/mailman/listinfo/chirp_devel">http://intrepid.danplanet.com/mailman/listinfo/chirp_devel</a>
Developer docs: <a class="moz-txt-link-freetext" href="http://chirp.danplanet.com/projects/chirp/wiki/Developers">http://chirp.danplanet.com/projects/chirp/wiki/Developers</a>
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
</blockquote>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /><table style="border-top: 1px solid #D3D4DE;"><tr><td style="width: 55px; padding-top: 13px;"><a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-green-avg-v1.png" alt="" width="46" height="29" style="width: 46px; height: 29px;"/></a></td><td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free.<a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avg.com</a></td></tr></table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>