<?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=7069&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-05-15T18:15:25+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=7069&amp;mode</id>
<entry>
<author><name><![CDATA[Krauser]]></name></author>
<updated>2014-05-15T18:15:25+01:00</updated>
<published>2014-05-15T18:15:25+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81220#p81220</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81220#p81220"/>
<title type="html"><![CDATA[Re: rprintf.h i błąd &quot;undefined reference to...&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81220#p81220"><![CDATA[
W linii 18 masz <em>return (0);</em>. Wartość 0 jest zwracana jeśli funkcja nie znajdzie % w przekazanym łańcuchu znaków. Funkcja zwraca wartość. Błędem jest zatem, że nie każde rozgałęzienie tej funkcji zwraca wartość. Dopisanie <em>return 0;</em> na końcu usunie ostrzeżenie. Można dyskutować co zwróci bez tej dopisanej linijki. Kto chce niech sprawdzi, że zwróci 0.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=465">Krauser</a> — 15 maja 2014, o 18:15</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Ksk]]></name></author>
<updated>2014-05-14T21:57:39+01:00</updated>
<published>2014-05-14T21:57:39+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81165#p81165</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81165#p81165"/>
<title type="html"><![CDATA[Re: rprintf.h i błąd &quot;undefined reference to...&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81165#p81165"><![CDATA[
<div class="quotetitle">Krauser napisał(a):</div><div class="quotecontent"><br />Brak zwracanej wartości w funkcji która ma coś zwrócić to błąd. Można dodać return 0; albo zmienić typ zwracany na void w pliku c i h<br /></div><br /><br />Sądziłem, że biblioteka powinna działać poprawnie. Błąd dotyczy fragmentu:<br />[syntax=c]int rprintf1RamRom(unsigned char stringInRom, const char *format, ...)<br />{<br />// simple printf routine<br />// define a global HexChars or use line below<br />//static char HexChars&#91;16&#93; = &quot;0123456789ABCDEF&quot;;<br />char format_flag;<br />unsigned int u_val, div_val, base;<br />va_list ap;<br /><br />va_start(ap, format);<br />for (;;)<br />{<br />while ((format_flag = READMEMBYTE(stringInRom,format++) ) != '%')<br />{// Until '%' or '\0'<br />if (!format_flag)<br />{<br />va_end(ap);<br />return(0);<br />}<br />rprintfChar(format_flag);<br />}<br /><br />switch (format_flag = READMEMBYTE(stringInRom,format++) )<br />{<br />case 'c': format_flag = va_arg(ap,int);<br />default:  rprintfChar(format_flag); continue;<br />case 'd': base = 10; div_val = 10000; goto CONVERSION_LOOP;<br />//case 'x': base = 16; div_val = 0x10;<br />case 'x': base = 16; div_val = 0x1000;<br /><br />CONVERSION_LOOP:<br />u_val = va_arg(ap,int);<br />if (format_flag == 'd')<br />{<br />if (((int)u_val) &lt; 0)<br />{<br />u_val = - u_val;<br />rprintfChar('-');<br />}<br />while (div_val &gt; 1 &amp;&amp; div_val &gt; u_val) div_val /= 10;<br />}<br />do<br />{<br />//rprintfChar(pgm_read_byte(HexChars+(u_val/div_val)));<br />rprintfu04(u_val/div_val);<br />u_val %= div_val;<br />div_val /= base;<br />} while (div_val);<br />}<br />}<br />va_end(ap);<br />}<br />#endif[/syntax]<br />zmiana zmiennej na void (w obu plikach) skutkuje błędem <br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">Return has value, in function returning void   rprintf.c   /Master   line 337   Code Analysis Problem</div><br /><br />dodanie &quot;return=0;&quot; w linii 51 usuwa ostrzeżenie, ale nie jestem przekonany poprawnego działania biblioteki po takiej modyfikacji. Mógłby ktoś potwierdzić?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=4395">Ksk</a> — 14 maja 2014, o 21:57</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Krauser]]></name></author>
<updated>2014-05-14T21:46:02+01:00</updated>
<published>2014-05-14T21:46:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81164#p81164</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81164#p81164"/>
<title type="html"><![CDATA[Re: rprintf.h i błąd &quot;undefined reference to...&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81164#p81164"><![CDATA[
Ostrzeżenie związane z brakiem instrukcji break należy zignorować. Jeśli dany case nie posiada break to wykona się kod następnego np.<br />[syntax=c]switch(a)<br />{<br />   case 0:<br />      //instrukcja 0<br />   case 1:<br />      //instrukcja 1<br />      break;<br />   case 2:<br />      //instrukcja 2<br />      break;<br />   default:<br />      break;<br />}<br />//gdy a jest równe zero wykona się instrukcja 0 i instrukcja 1, dla a równego 1 tylko instrukcja 1.[/syntax]<br />Brak zwracanej wartości w funkcji która ma coś zwrócić to błąd. Można dodać return 0; albo zmienić typ zwracany na void w pliku c i h<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=465">Krauser</a> — 14 maja 2014, o 21:46</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Ksk]]></name></author>
<updated>2014-05-14T21:34:32+01:00</updated>
<published>2014-05-14T21:34:32+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81161#p81161</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81161#p81161"/>
<title type="html"><![CDATA[Re: rprintf.h i błąd &quot;undefined reference to...&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81161#p81161"><![CDATA[
<div class="quotetitle">Antystatyczny napisał(a):</div><div class="quotecontent"><br />A masz również plik rprintf.c  w tym folderze?<br /></div><br />Nie sądziłem, że również jest potrzebny skoro nie ma odwołania do niego oraz nie wyświetla błędu z nim związanego.<br />Jednak faktycznie umieszczenie go odniosło skutek <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> jednak pozostały jeszcze 3 ostrzeżenia (nie wiem czy się nimi przejmować ponieważ dotyczą &quot;gotowej&quot; biblioteki):<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">No break at the end of case   rprintf.c   /Master   line 344   Code Analysis Problem<br />No break at the end of case   rprintf.c   /Master   line 367   Code Analysis Problem<br />No return, in function returning non-void   rprintf.c   /Master   line 320   Code Analysis Problem</div><br /><br /><div class="quotetitle">Krauser napisał(a):</div><div class="quotecontent"><br />Kod w języku C należy wstawić wykorzystując listing kodu: [SYNTAX wybierz] i wybrać C. Edytuj post i zobaczysz, że lepiej wtedy wygląda. Kod z konsoli może tak zostać.<br /></div><br />Będę pamiętać następnym razem <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=4395">Ksk</a> — 14 maja 2014, o 21:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Krauser]]></name></author>
<updated>2014-05-14T21:25:22+01:00</updated>
<published>2014-05-14T21:25:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81158#p81158</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81158#p81158"/>
<title type="html"><![CDATA[Re: rprintf.h i błąd &quot;undefined reference to...&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81158#p81158"><![CDATA[
Kod w języku C należy wstawić wykorzystując listing kodu: [SYNTAX wybierz] i wybrać C. Edytuj post i zobaczysz, że lepiej wtedy wygląda. Kod z konsoli może tak zostać.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=465">Krauser</a> — 14 maja 2014, o 21:25</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Ksk]]></name></author>
<updated>2014-05-14T21:58:22+01:00</updated>
<published>2014-05-14T21:15:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81153#p81153</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81153#p81153"/>
<title type="html"><![CDATA[rprintf.h i błąd &quot;undefined reference to...&quot;]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7069&amp;p=81153#p81153"><![CDATA[
Witam,<br />dopiero zaczynam z programowaniem i nie potrafię się uporać z błędem &quot;undefined reference to&quot;<br /><br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br /><br />#include &quot;rprintf.h&quot;<br /><br />&#91;...część kodu pominięta...&#93;<br /><br />void DoCommand(void);<br />void InitSPI(void);<br />void print_byte_to_usart(uint8_t dana);<br />void USART_Init(uint16_t baud);<br />uint8_t TransferByteSpi(uint8_t bajt);<br />void SendCharSpi(char znak);<br />void SendByteSpi(uint8_t byte);<br />void OdczytParametrowSpi(void);<br />void PrzypisParametrowSpi(void);<br />void WypiszParametryRS(void);<br />void OdczytajPozycjeSpi(void);<br /><br />&#91;...część kodu pominięta...&#93;<br /><br />int main(void)<br />{<br />InitSPI();//inicjalizacja SPI<br />USART_Init(__UBRR);// inicjalizacja UART<br />rprintfInitRS(print_byte_to_usart);// Inicjalizacja funkcji rprintf dla RSa<br /><br /><br /><br />sei();//zezwolenie na globalne przerwania<br /><br />    rprintf(&quot;\nSkaner X-Y&quot;);<br /><br />  rprintf(&quot;\nver. 1.0&quot;);<br /><br />  rprintf(&quot;\nNacisnij 'H' by zobaczyc pomoc&quot;);<br /><br />  rprintf(&quot;\nREADY&gt;&quot;);<br /><br /><br />while(1)<br />{<br />}<br /><br />}<br /><br />&#91;...część kodu pominięta...&#93;<br /><br />void WypiszParametryRS(void)<br />{<br />rprintf(&quot;\nP gain           =&quot;);<br />rprintfNum(10, 6, 1, ' ',Servo.gainP);<br />rprintf(&quot;\nI gain           =&quot;);<br />rprintfNum(10, 6, 1, ' ',Servo.gainI);<br />rprintf(&quot;\nD gain           =&quot;);<br />rprintfNum(10, 6, 1, ' ',Servo.gainD);<br />rprintf(&quot;\nEnkoder pozycja =&quot;);<br />rprintfNum(10, 6, 1, ' ',encoder0Pos);<br />rprintf(&quot;\nPoz. zadana    =&quot;);<br />rprintfNum(10, 6, 1, ' ',Servo.position);<br />rprintf(&quot;\nMax. detec. error =&quot;);<br />rprintfNum(10, 6, 1, ' ',Servo.maxPosError);<br />rprintf(&quot;\nMax error        =&quot;);<br />rprintfNum(10, 6, 1, ' ',Servo.maxError);<br />rprintf(&quot;\nMax I error      =&quot;);<br />rprintfNum(10, 6, 0, ' ',Servo.maxErrorI);<br />rprintf(&quot;\nMax D error      =&quot;);<br />rprintfNum(10, 6, 0, ' ',Servo.maxErrorD);<br />rprintf(&quot;\nMax output       =&quot;);<br />rprintfNum(10, 6, 0, ' ',Servo.maxOutput);<br />rprintf(&quot;\nDead band        =&quot;);<br />rprintfNum(10, 6, 0, ' ',Servo.deadBand);<br />}<br /><br />&#91;...część kodu pominięta...&#93;<br /><br />case 'P': Servo.gainP = atoi(inBuf);<br />  s_bajt = (uint8_t)(Servo.gainP &gt;&gt; 8);<br />m_bajt = (uint8_t)(Servo.gainP &amp; 0xFF);<br /><br />if(Buf1=='X')<br />{<br />SS1_ON;<br />SendByteSpi(s_bajt);<br />SendByteSpi(m_bajt);<br />SS1_OFF;<br />}<br />else if(Buf1=='Y')<br />{<br />SS2_ON;<br />SendByteSpi(s_bajt);<br />SendByteSpi(m_bajt);<br />SS2_OFF;<br />}<br />            rprintf(&quot;\nP gain           =&quot;);<br />            rprintfNum(10, 6, 1, ' ',Servo.gainP);[/syntax]<br />i przy próbie kompilacji wyrzuca mi błędy<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">**** Build of configuration Release for project Master ****<br /><br />make all <br />Building file: ../main.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega16 -DF_CPU=8000000UL -MMD -MP -MF&quot;main.d&quot; -MT&quot;main.d&quot; -c -o &quot;main.o&quot; &quot;../main.c&quot;<br />Finished building: ../main.c<br /> <br />Building target: Master.elf<br />Invoking: AVR C Linker<br />avr-gcc -Wl,-Map,Master.map -L&quot;D:\ProjWork\Master&quot; -mmcu=atmega16 -o &quot;Master.elf&quot;  ./main.o   <br />./main.o: In function `WypiszParametryRS':<br />main.c:(.text+0x30e): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x32c): undefined reference to `rprintfNum'<br />main.c:(.text+0x342): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x360): undefined reference to `rprintfNum'<br />main.c:(.text+0x376): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x394): undefined reference to `rprintfNum'<br />main.c:(.text+0x3aa): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x3cc): undefined reference to `rprintfNum'<br />main.c:(.text+0x3e2): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x404): undefined reference to `rprintfNum'<br />main.c:(.text+0x41a): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x43c): undefined reference to `rprintfNum'<br />main.c:(.text+0x452): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x474): undefined reference to `rprintfNum'<br />main.c:(.text+0x48a): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x4ac): undefined reference to `rprintfNum'<br />main.c:(.text+0x4c2): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x4e4): undefined reference to `rprintfNum'<br />main.c:(.text+0x4fa): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x51c): undefined reference to `rprintfNum'<br />main.c:(.text+0x532): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x552): undefined reference to `rprintfNum'<br />./main.o: In function `OdczytajPozycjeSpi':<br />main.c:(.text+0x5ca): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x5ec): undefined reference to `rprintfNum'<br />./main.o: In function `DoCommand':<br />main.c:(.text+0x818): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x83c): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x960): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0x9da): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0xa54): undefined reference to `rprintf1RamRom'<br />./main.o:main.c:(.text+0xae0): more undefined references to `rprintf1RamRom' follow<br />./main.o: In function `DoCommand':<br />main.c:(.text+0xda8): undefined reference to `rprintfNum'<br />./main.o: In function `__vector_11':<br />main.c:(.text+0xe58): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0xeb4): undefined reference to `rprintf1RamRom'<br />./main.o: In function `main':<br />main.c:(.text+0xf16): undefined reference to `rprintfInitRS'<br />main.c:(.text+0xf30): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0xf42): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0xf54): undefined reference to `rprintf1RamRom'<br />main.c:(.text+0xf66): undefined reference to `rprintf1RamRom'<br />make: *** &#91;Master.elf&#93; Error 1<br /><br />**** Build Finished ****<br /></div><br />Oczywiście w folderze z main.c znajduje się rprintf.h<br /><br />Będę wdzięczny z wszelkie wskazówki.<br />Pozdrawiam<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=4395">Ksk</a> — 14 maja 2014, o 21:15</p><hr />
]]></content>
</entry>
</feed>