<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=11358&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-04-16T13:05:59+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=11358&amp;mode</id>
<entry>
<author><name><![CDATA[slodkimieciu]]></name></author>
<updated>2015-04-16T13:05:59+01:00</updated>
<published>2015-04-16T13:05:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126662#p126662</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126662#p126662"/>
<title type="html"><![CDATA[Re: PROGMEM i tablica struktur]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126662#p126662"><![CDATA[
Hej dzieki wielkie za odpowiedz. Pozdrawiam<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6071">slodkimieciu</a> — 16 kwi 2015, o 13:05</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Krauser]]></name></author>
<updated>2015-04-13T19:52:00+01:00</updated>
<published>2015-04-13T19:52:00+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126411#p126411</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126411#p126411"/>
<title type="html"><![CDATA[Re: PROGMEM i tablica struktur]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126411#p126411"><![CDATA[
<div class="quotetitle">slodkimieciu napisał(a):</div><div class="quotecontent"><br />[syntax=c]struct AT_command *zm = (struct AT_command*)pgm_read_word( &amp;( commands&#91;1&#93; ) );<br />strcpy_P(buf, (char*)pgm_read_word( &amp;zm-&gt;command ));[/syntax]<br /></div><br />Utworzyłeś tablicę struktur w pamięci programu i w zm jest już wskaźnik do Pos1 i nic nie trzeba robić:<br />[syntax=c]const char *zm = pgm_read_word( &amp;( commands&#91;1&#93; ) );<br />strcpy_P(buf, zm);[/syntax]<br /><br />Nie ratuje to sytuacji, bo nie dobierzesz się do wskaźnika funkcji.<br />Spróbuj:<br />[syntax=c]struct AT_command a;<br />memcpy_P(&amp;a, &amp;( commands&#91;1&#93;), sizeof(a)); //skopiowanie struktury do RAM<br />strcpy_P(buf, a.command); //skopiowanie łańcucha znaków z flash do bufora RAM<br />a.func_handler(buf); //wywołanie funkcji przez wskaźnik[/syntax]<br /><br />PS.<br /><div class="quotetitle">slodkimieciu napisał(a):</div><div class="quotecontent"><br />[syntax=c]uart_puts_P(&quot;OK\r\n&quot;);[/syntax]<br /></div><br />zastąp:<br />[syntax=c]uart_puts_P(PSTR(&quot;OK\r\n&quot;));[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=465">Krauser</a> — 13 kwi 2015, o 19:52</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[slodkimieciu]]></name></author>
<updated>2015-04-12T14:39:37+01:00</updated>
<published>2015-04-12T14:39:37+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126275#p126275</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126275#p126275"/>
<title type="html"><![CDATA[PROGMEM i tablica struktur]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11358&amp;p=126275#p126275"><![CDATA[
Witam serdecznie,<br /><br />Od jakiegos czasu borykam sie z nastepującym problemem:<br /><br />Deklaracje w pliku .h<br /><br />[syntax=c]void func( char * buffer );<br /><br />typedef struct AT_command {<br /><br />  const char * const command;<br />  void ( * func_handler ) ( char * param );<br /><br />};<br /><br />extern const struct AT_command commands&#91;&#93; PROGMEM;[/syntax]<br /><br />oraz plik .c<br /><br />[syntax=c]void func ( char * buffer ) {<br />        <br />        //test<br />uart_puts_P(&quot;OK\r\n&quot;);<br /><br />}<br /><br />const char Pos1&#91;&#93; PROGMEM = &quot;+RESET&quot;;<br />const char Pos2&#91;&#93; PROGMEM = &quot;+VERSION&quot;;<br />const char Pos3&#91;&#93; PROGMEM = &quot;+NAME&quot;;<br /><br />const struct AT_command commands&#91;&#93; PROGMEM = {<br /><br />  { Pos1    , func },<br />  { Pos2    , func },<br />  { Pos3    , func }<br /><br />};[/syntax]<br /><br /><br />Powyzszy kod kompiluje sie poprawnie, nastomiast nie za bardzo wychodzi mi dostep do poszczegolnych skladowych struktury.<br /><br />Probowalem tak aby wyswietlic poszczegolne stringi:<br /><br />[syntax=c]char buf&#91;32&#93;;<br /><br />struct AT_command *zm = (struct AT_command*)pgm_read_word( &amp;( commands&#91;1&#93; ) );<br />strcpy_P(buf, (char*)pgm_read_word( &amp;zm-&gt;command ));[/syntax]<br /><br />Niestety ten kod nie dziala i powodouje wywalenie sie procesora  <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" />  <br /><br />Jak odczytac wskaznik do funkcji aby potem moc go wywolac ?<br /><br />Z góry dziękuje<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6071">slodkimieciu</a> — 12 kwi 2015, o 14:39</p><hr />
]]></content>
</entry>
</feed>