X

FPGA SPI Bridge Panel(2)NCO

AndroidからFPGA内部のNCOの周波数を設定できるように、Python Instrument Panel(12)AD9851 DDSモジュール用のパネルを変更して、Androidアプリ「GUI Maker for Avalon Bus – FPGA SPI Bridge Panel」用のパネルを作りました。

NCOの編集ツール画面の希望周波数と加算器増分をNCOパネルのFreqとValueに10進数で入力します。AddrにはNCOの加算器増分をセットするPIOのアドレスを16進数で入力します。

 

Androidアプリ「GUI Maker for Avalon Bus – FPGA SPI Bridge Panel」で作成した”NCO”パネルのPanel contextは次のようになります。Androidのブラウザでコピーして、で追加した新規パネルのPanel context でペースト、さらにで新規パネルが”NCO”パネルになります。

<?xml version="1.0" encoding="utf-8"?>
<PanelContext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Id>a5d8a98a-fcae-471e-b62e-bc67f12d8320</Id>
  <PredefinedId>00000000-0000-0000-0000-000000000000</PredefinedId>
  <Name>NCO</Name>
  <ItemList>
    <ItemContext>
      <Id>032ff4f9-a027-4aac-acc9-43dfa5dc08f3</Id>
      <Index>1</Index>
      <ItemType>3</ItemType>
      <X>250</X>
      <Y>-10</Y>
      <TextW>350</TextW>
      <TextH>120</TextH>
      <TextText>
      </TextText>
      <TextFontSize>58</TextFontSize>
      <TextTextAlignment>2</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>65535</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>c289292f-12d2-4152-a8ab-24d28918c0e5</Id>
      <Index>2</Index>
      <ItemType>0</ItemType>
      <X>520</X>
      <Y>-140</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>BS</ButtonText>
      <ButtonFontSize>32</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>if len(freqStr) &gt; 0:
    freqStr = freqStr[:-1]</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>2e9d8355-73a9-417e-ad10-c26677e50a85</Id>
      <Index>3</Index>
      <ItemType>0</ItemType>
      <X>520</X>
      <Y>-230</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>MHz</ButtonText>
      <ButtonFontSize>32</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>setFreq(1000000)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>26f946a7-b7b9-41f3-87b7-f2ed560ac1ba</Id>
      <Index>4</Index>
      <ItemType>0</ItemType>
      <X>520</X>
      <Y>-320</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>kHz</ButtonText>
      <ButtonFontSize>32</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>setFreq(1000)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>b7df6212-8023-41db-ab14-b1ad7deb8d66</Id>
      <Index>5</Index>
      <ItemType>0</ItemType>
      <X>520</X>
      <Y>-410</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>Hz</ButtonText>
      <ButtonFontSize>32</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>setFreq(1)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>b2714698-6933-400d-a96b-ae56bd8e89f6</Id>
      <Index>6</Index>
      <ItemType>0</ItemType>
      <X>430</X>
      <Y>-140</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>9</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>8992d33e-63ea-4c25-85c8-14ad8234217a</Id>
      <Index>7</Index>
      <ItemType>0</ItemType>
      <X>340</X>
      <Y>-140</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>8</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>c956e21c-2192-4a69-abed-c56e56b5557d</Id>
      <Index>8</Index>
      <ItemType>0</ItemType>
      <X>250</X>
      <Y>-140</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>7</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>53b7ba0b-f2f1-40fb-b349-b071d28c1b66</Id>
      <Index>9</Index>
      <ItemType>0</ItemType>
      <X>430</X>
      <Y>-230</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>6</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>661f47bc-9fb9-4b10-bca0-783648daf1e9</Id>
      <Index>10</Index>
      <ItemType>0</ItemType>
      <X>340</X>
      <Y>-230</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>5</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>db5bd6c2-bc65-42a0-af5f-8d08cd481f21</Id>
      <Index>11</Index>
      <ItemType>0</ItemType>
      <X>250</X>
      <Y>-230</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>4</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>d0e69df5-1356-455a-822e-13c9478e552e</Id>
      <Index>12</Index>
      <ItemType>0</ItemType>
      <X>430</X>
      <Y>-320</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>3</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>d88ac82b-1108-4591-af2c-24a901f400cb</Id>
      <Index>13</Index>
      <ItemType>0</ItemType>
      <X>340</X>
      <Y>-320</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>2</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>57aa44c8-7a7e-476e-b2f0-1ea8566100ee</Id>
      <Index>14</Index>
      <ItemType>0</ItemType>
      <X>250</X>
      <Y>-320</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>1</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>3e9fe91b-ed59-4d4b-8e37-2410f70c723e</Id>
      <Index>15</Index>
      <ItemType>0</ItemType>
      <X>430</X>
      <Y>-410</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>C</ButtonText>
      <ButtonFontSize>32</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr = ''
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>8ef315fa-2bcd-48d0-898e-90cade2b7015</Id>
      <Index>16</Index>
      <ItemType>0</ItemType>
      <X>340</X>
      <Y>-410</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>.</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>a1693212-1152-4ec4-80c0-27c754bf72e5</Id>
      <Index>17</Index>
      <ItemType>0</ItemType>
      <X>250</X>
      <Y>-410</Y>
      <ButtonW>80</ButtonW>
      <ButtonH>80</ButtonH>
      <ButtonText>0</ButtonText>
      <ButtonFontSize>48</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>freqStr += sender.Text
dispFreq(freqStr)</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>168a0789-2d08-47b8-b38c-1f893a3db8f9</Id>
      <Index>18</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-270</Y>
      <TextW>200</TextW>
      <TextH>40</TextH>
      <TextText>594,000 </TextText>
      <TextFontSize>32</TextFontSize>
      <TextTextAlignment>2</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>65535</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>233f0490-41e8-431a-a32d-0f02dfb42ab9</Id>
      <Index>19</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-180</Y>
      <TextW>200</TextW>
      <TextH>40</TextH>
      <TextText>1,494,000 </TextText>
      <TextFontSize>32</TextFontSize>
      <TextTextAlignment>2</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>65535</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>265dd608-c2bb-4dfc-a2ed-7818da9a8e04</Id>
      <Index>20</Index>
      <ItemType>0</ItemType>
      <X>10</X>
      <Y>-230</Y>
      <ButtonW>200</ButtonW>
      <ButtonH>40</ButtonH>
      <ButtonText>Start freq</ButtonText>
      <ButtonFontSize>28</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>startFreq = freq
dispStartFreq()</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>ea4533a7-57e6-4c6a-87a3-9b7d1128c827</Id>
      <Index>21</Index>
      <ItemType>0</ItemType>
      <X>10</X>
      <Y>-140</Y>
      <ButtonW>200</ButtonW>
      <ButtonH>40</ButtonH>
      <ButtonText>Stop freq</ButtonText>
      <ButtonFontSize>28</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>stopFreq = freq
dispStopFreq()</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>f14aee8b-f5c6-4a43-9173-a71e6bc55b91</Id>
      <Index>22</Index>
      <ItemType>0</ItemType>
      <X>10</X>
      <Y>-420</Y>
      <ButtonW>200</ButtonW>
      <ButtonH>70</ButtonH>
      <ButtonText>Sweep</ButtonText>
      <ButtonFontSize>32</ButtonFontSize>
      <ButtonTextAlignment>1</ButtonTextAlignment>
      <ButtonF>255</ButtonF>
      <ButtonB>4076008191</ButtonB>
      <ButtonScript>if Items[23].Value == 0:
    sender.B = 0x00ff00ff
    freq = stopFreq
    longWait = 0
    Items[23].Value = 1
else:
    sender.B = 0xF2F2F2FF
    Items[23].Value = 0</ButtonScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>f189f1d9-d135-46fc-8cf8-eaff94ffa418</Id>
      <Index>23</Index>
      <ItemType>5</ItemType>
      <X>0</X>
      <Y>0</Y>
      <TimerValue>false</TimerValue>
      <TimerInterval>1</TimerInterval>
      <TimerScript>if longWait &gt; 0:
    longWait -= sender.Interval
if longWait &lt;= 0.0:
    step = (stopFreq - startFreq) / points
    if freq &gt;= stopFreq:
        freq = startFreq
        longWait = 0.5
    elif freq + step &gt;= stopFreq:
        freq = stopFreq
    else:
        freq += step
    sendFreq()</TimerScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>9ef56f11-c51e-4d50-a6b7-8eeca5a18b06</Id>
      <Index>24</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-320</Y>
      <TextW>100</TextW>
      <TextH>40</TextH>
      <TextText>Points</TextText>
      <TextFontSize>28</TextFontSize>
      <TextTextAlignment>1</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>0</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>b9d8d0b3-b0eb-4a5f-a551-41ec1a7503c0</Id>
      <Index>25</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-370</Y>
      <TextW>100</TextW>
      <TextH>40</TextH>
      <TextText>Wait</TextText>
      <TextFontSize>28</TextFontSize>
      <TextTextAlignment>1</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>0</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>763bbc5d-9840-4c4f-a096-59d2e915bf95</Id>
      <Index>26</Index>
      <ItemType>4</ItemType>
      <X>110</X>
      <Y>-320</Y>
      <DropdownW>100</DropdownW>
      <DropdownH>40</DropdownH>
      <DropdownText>10;20;30;40;50;60;70;80;90;100</DropdownText>
      <DropdownFontSize>24</DropdownFontSize>
      <DropdownValue>9</DropdownValue>
      <DropdownScript>points = int(sender.Options[sender.Value])</DropdownScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>9d9f540f-a901-42df-9db4-b1d14a956e3d</Id>
      <Index>27</Index>
      <ItemType>4</ItemType>
      <X>110</X>
      <Y>-370</Y>
      <DropdownW>100</DropdownW>
      <DropdownH>40</DropdownH>
      <DropdownText>0.1s;0.2s;0.3s;0.4s;0.5s;0.6s;0.7s;0.8s;0.9s;1s</DropdownText>
      <DropdownFontSize>24</DropdownFontSize>
      <DropdownValue>9</DropdownValue>
      <DropdownScript>Items[23].Interval = float( sender.Options[sender.Value][:-1])</DropdownScript>
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>2a3cb661-1b7e-4fbd-9d06-8318706995d4</Id>
      <Index>28</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-10</Y>
      <TextW>80</TextW>
      <TextH>40</TextH>
      <TextText>Addr</TextText>
      <TextFontSize>28</TextFontSize>
      <TextTextAlignment>1</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>0</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>7d833f66-abeb-43a2-a04e-f98e8b95b363</Id>
      <Index>29</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-50</Y>
      <TextW>80</TextW>
      <TextH>40</TextH>
      <TextText>Freq</TextText>
      <TextFontSize>28</TextFontSize>
      <TextTextAlignment>1</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>0</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>14a46024-7798-4bba-a548-47ccc6033a63</Id>
      <Index>30</Index>
      <ItemType>3</ItemType>
      <X>10</X>
      <Y>-90</Y>
      <TextW>80</TextW>
      <TextH>40</TextH>
      <TextText>Value</TextText>
      <TextFontSize>28</TextFontSize>
      <TextTextAlignment>1</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>0</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>10b01b82-6a75-4a3a-a654-9f39d4a1e437</Id>
      <Index>31</Index>
      <ItemType>1</ItemType>
      <X>90</X>
      <Y>-10</Y>
      <InputFieldW>125</InputFieldW>
      <InputFieldH>40</InputFieldH>
      <InputFieldText>10</InputFieldText>
      <InputFieldFontSize>24</InputFieldFontSize>
      <InputFieldScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>70a40773-6e7d-4581-858f-6ad8f95ad2e3</Id>
      <Index>32</Index>
      <ItemType>1</ItemType>
      <X>90</X>
      <Y>-50</Y>
      <InputFieldW>150</InputFieldW>
      <InputFieldH>40</InputFieldH>
      <InputFieldText>1000000</InputFieldText>
      <InputFieldFontSize>24</InputFieldFontSize>
      <InputFieldScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>73012067-09bd-4df8-9fa4-68fa2d16a85c</Id>
      <Index>33</Index>
      <ItemType>1</ItemType>
      <X>90</X>
      <Y>-90</Y>
      <InputFieldW>150</InputFieldW>
      <InputFieldH>40</InputFieldH>
      <InputFieldText>85899346</InputFieldText>
      <InputFieldFontSize>24</InputFieldFontSize>
      <InputFieldScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
    <ItemContext>
      <Id>475a35ba-e3d8-4476-97f3-5fe6c18fecd3</Id>
      <Index>34</Index>
      <ItemType>3</ItemType>
      <X>215</X>
      <Y>-10</Y>
      <TextW>25</TextW>
      <TextH>40</TextH>
      <TextText>(16)</TextText>
      <TextFontSize>12</TextFontSize>
      <TextTextAlignment>1</TextTextAlignment>
      <TextF>4294967295</TextF>
      <TextB>0</TextB>
      <TextScript />
      <V1_0_5 />
      <V1_1_0 />
    </ItemContext>
  </ItemList>
  <CurrentItemId>f14aee8b-f5c6-4a43-9173-a71e6bc55b91</CurrentItemId>
  <SetupScript>from System import String
   
def sendFreq():
    dispFreq('{:,}'.format(freq))
    addr = int(Items[31].Text, 16)
    refFreq = int(Items[32].Text)
    refValue = int(Items[33].Text)
    data = int(round(float(freq) / float(refFreq) * float(refValue)))
    #print data
    if Remote.CanWrite:
        res = Remote.WriteUInt32Packet(addr, data)
        print 'Response:',
        for b in res:
            print '%02x' % b,
        print
  
    
def textToFreq(str):
    try:
        return int(str.replace(',', ''))
    except ValueError:
        return -1
   
def dispFreq(str):
    Items[1].Text = str + ' '
    
def dispStartFreq():
    Items[18].Text = '{:,}'.format(startFreq) + ' '
    
def dispStopFreq():
    Items[19].Text = '{:,}'.format(stopFreq) + ' '
    
def setFreq(mag):
    global freqStr, freq
    
    if freqStr == '':
        return
    freq = int(float(freqStr) * mag)
    freqStr = ''
    sendFreq()
    
points = int(Items[26].Options[Items[26].Value])
Items[23].Interval = float(Items[27].Options[Items[27].Value][:-1])
freqStr = ''
freq = textToFreq(Items[1].Text)
startFreq = textToFreq(Items[18].Text)
stopFreq = textToFreq(Items[19].Text)
if freq &gt;= 0:
    dispFreq('{:,}'.format(freq))
dispStartFreq()
dispStopFreq()</SetupScript>
  <TeardownScript />
</PanelContext>
snoopy: