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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2016-03-10T22:45:59+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=14814&amp;mode</id>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2016-03-10T22:45:59+01:00</updated>
<published>2016-03-10T22:45:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155893#p155893</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155893#p155893"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155893#p155893"><![CDATA[
<div class="quotetitle">gaza napisał(a):</div><div class="quotecontent"><br />nie musiałem robić extern<br />Wystarczyło ,ze w common.h<br /></div><br /><br />Czyli zainspirowało ciebie to co pisałem (podałeś cytat) a zrobiłeś CAŁKOWICIE ODWROTNIE czyli tragicznie <img src="https://forum.atnel.pl/images/smilies/icon_e_sad.gif" alt=":(" title="Smutny" /> bo zrobiłeś definicje zmiennych w pliku *.h<br /><br />uint16_t tempPeriodTime; //liczba sekund pomiedzy odczytami temperatury<br />uint16_t totalConsumption;<br /><br />i w cytacie jak widzisz piszę że DEFINICJE mają być w *.c<br /><br />Proszę poczytaj czym różni się DEFINICJA i DEKLARACJA bo brniesz w ślepy zaułek a to że teraz ci się dobrze skompilowało wcale nie oznacza że jest dobrze zrobione i że czkawką ci nie zacznie się niedługo odbijać<br /><br />czyli to czego się NIGDY nie robi w C i od czego będziesz miał w dalszych swoich losach same problemy z działaniem różnych swoich projektów i językiem C jako takim ponieważ ..... ponieważ nadal nie rozumiesz (z tego właśnie widać) czym różni się DEFINICJA od DEKLARACJI.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 10 mar 2016, o 22:45</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[gaza]]></name></author>
<updated>2016-03-10T22:06:11+01:00</updated>
<published>2016-03-10T22:06:11+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155885#p155885</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155885#p155885"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155885#p155885"><![CDATA[
jak mawiał mój dobry nauczyciel od matematyki ze szkoły podstawoej &quot; umiesz liczyć .... &quot;<br /><br />A tak poważnie , to zainspirował mnie ten post <a href="http://forum.atnel.pl/topic14683.html"  class="postlink">http://forum.atnel.pl/topic14683.html</a><br />i wypowiedz Mirka <div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />Bo to są DEKLARACJE zmiennych<br /><br />zaś w pliku d_led.c masz bez extern i to są DEFINICJE tych zmiennych<br /><br />nie zwróciłeś uwagi w Bluebooku na to jak naciskam mocno na to aby czytelnik zrozumiał czym różni się DEKLARACJA od DEFINICJI ? .... brak zrozumienia tego zagadnienia będzie powodował, że wciąż będzie się miało problemy ze zrozumieniem różnych części kodu w C<br /></div><br /><br />nie musiałem robić extern<br />Wystarczyło ,ze w common.h [syntax=c]enum heatState {PERMANENT, VARY, OFF};<br />enum heatState currentHeatState;<br />enum heatState previousHeatState;<br /><br />uint16_t tempPeriodTime; //liczba sekund pomiedzy odczytami temperatury<br />uint16_t totalConsumption;[/syntax]<br /><br />a w main.c <br />je zainicłowałem<br />[syntax=c]totalConsumption = 0;<br />tempPeriodTime = 60;<br />currentHeatState = VARY;<br />previousHeatState = OFF;[/syntax]<br /><br />Kompilacja przeszła bez błędów<br />Jutro wgram hex-a i zobaczę jak działa<br /><br />Dzięki za poświęcony czas i pomoc<br /><br />Pozdr.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=503">gaza</a> — 10 mar 2016, o 22:06</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Rafał555]]></name></author>
<updated>2016-03-10T21:37:53+01:00</updated>
<published>2016-03-10T21:37:53+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155884#p155884</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155884#p155884"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155884#p155884"><![CDATA[
Jak masz w błędach napisane 'undeclared' to znaczy, że program ich nie widzi, albo podałeś złą ścieżkę dostępu do pliku .h,<br /> albo dopisz extern przed zmienną. Przed zmiennymi typu &quot;enum&quot; też.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2697">Rafał555</a> — 10 mar 2016, o 21:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[gaza]]></name></author>
<updated>2016-03-10T20:39:12+01:00</updated>
<published>2016-03-10T20:39:12+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155874#p155874</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155874#p155874"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155874#p155874"><![CDATA[
plagiatu się nie obawiam, a jedynie może trochę wstyd to pokazywać <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br /><br />[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 2016-03-09<br /> *      Author: GL<br /> */<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &quot;MKUART/mkuart.h&quot;<br />#include &quot;1Wire/ds18x20.h&quot;<br />#include &quot;common.h&quot;<br />#include &quot;ATCOMMANDS/atcommands.h&quot;<br /><br />//deklaracje zmiennych<br />volatile uint16_t Timer1;<br />volatile uint8_t secFlag;<br />volatile uint8_t seconds;<br />volatile uint8_t int1_flag= 0;<br />volatile uint8_t heatFlag=0; //definicja flagi zdalnego włączenia grzania (RS)<br />volatile uint8_t int1_start=0; // zmienna przechowująca sekundę wystapienia int1<br />uint8_t cntSensor = 0; // liczba termometrów<br />uint8_t z; //zmienna petli<br />uint8_t thermostatKey = 0; //stan reguloatora pokojowego<br />uint8_t key1_lock, key2_lock; //zmienne pomocnicze obsługi drgań styków<br />uint8_t subzero, cel, cel_fract_bits;<br />char bufor&#91;100&#93;;// bufor na potrzeby odebranych danych z UART<br /><br />typedef struct {<br /> char devPath&#91;128&#93;;<br /> char devID&#91;16&#93;;<br /> char tempData&#91;6&#93;;<br />} TDS18B20;<br /><br /><br />#define RELAY_PIN (1&lt;&lt;PD4)            // Przekażnik<br />#define RELAY_TOG PORTD ^= RELAY_PIN    // makrodefinicja  zmiana stanu diody<br />#define RELAY_ON PORTD |= (1&lt;&lt;PD4)   // sterowanie przez tranzystor<br />#define RELAY_OFF PORTD &amp;= ~(1&lt;&lt;PD4) // dlatego odwrotnie<br /><br />#define LED_HALL_PIN (1&lt;&lt;PD5)<br />#define LED_HALL_OFF PORTD |= (1&lt;&lt;PD5)<br />#define LED_HALL_ON PORTD &amp;= ~(1&lt;&lt;PD5)<br /><br />#define LED_MANUAL_PIN (1&lt;&lt;PD6)<br />#define LED_MANUAL_OFF PORTD |= (1&lt;&lt;PD6)<br />#define LED_MANUAL_ON PORTD &amp;= ~(1&lt;&lt;PD6)<br /><br />#define LED_HEAT_PIN (1&lt;&lt;PD7)<br />#define LED_HEAT_OFF PORTD |= (1&lt;&lt;PD7)<br />#define LED_HEAT_ON PORTD &amp;= ~(1&lt;&lt;PD7)<br /><br />//przycisk zrzucenia totalConsumption<br />#define KEY_FLUSH_PIN (1&lt;&lt;PC1)<br />#define KEY_FLUSH_DOWN !(PINC &amp; KEY_FLUSH_PIN)<br />//sterownik pokojowy<br />#define KEY_HEAT_CONTROLLER_PIN (1&lt;&lt;PC0)<br />#define KEY_HEAT_CONTROLLER_DOWN !(PINC &amp; KEY_HEAT_CONTROLLER_PIN)<br /><br />//#define DS2408 &quot;2912345678ABC&quot; //8 switch<br />//#defineDS2423 &quot;1D12345678ABC&quot; //counter<br /><br />void sendConsumption(void){<br />uart_puts(&quot;C|&quot;);// wyślij tekst<br />uart_puts(DS2423);<br />uart_puts(&quot;|&quot;);<br />uart_putint(1, 10);<br />uart_putc('\n');// wyślij znak LF (nowa linia)<br />}<br /><br /><br /><br />void sendTemp(uint8_t x){<br />uint8_t status;<br />uint8_t i;<br />status = DS18X20_read_meas(gSensorIDs&#91;x&#93;, &amp;subzero, &amp;cel, &amp;cel_fract_bits) ;<br />if( DS18X20_OK == status){<br />uart_puts(&quot;T|&quot;);// wyślij tekst<br />for (i = 0; i &lt; 8; i++)<br />uart_putint(gSensorIDs&#91;x&#93;&#91;i&#93;,16);<br />uart_puts(&quot;#&quot;);<br />uart_putint(cel,10);<br />uart_puts(&quot;.&quot;);<br />uart_putint(cel_fract_bits, 10);<br />uart_puts(&quot;C&quot;);<br />uart_putc('\n');// nowa linia<br />}else {<br />uart_puts(&quot;T|&quot;);<br />for (i = 0; i &lt; 8; i++)<br />uart_putint(gSensorIDs&#91;x&#93;&#91;i&#93;,16);<br />uart_puts(&quot;#error:&quot;);// wyślij tekst<br />uart_putint(status, 10);<br />uart_putc('\n');// nowa linia<br />}<br /><br />}<br /><br />void setup(void)<br />{<br />//konfiguracja pinów<br />DDRD |= RELAY_PIN | LED_HALL_PIN | LED_MANUAL_PIN | LED_HEAT_PIN;<br />PORTD |= LED_HALL_PIN | LED_MANUAL_PIN | LED_HEAT_PIN;<br /><br />//przycisk<br />DDRC &amp;= ~KEY_FLUSH_PIN | ~KEY_HEAT_CONTROLLER_PIN;<br />PORTC |= KEY_FLUSH_PIN | KEY_HEAT_CONTROLLER_PIN;<br />// Przerwanie INT1<br />DDRD &amp;= ~(1&lt;&lt;PD3);      //INT1 jako wejscie<br />PORTD |= (1&lt;&lt;PD3);      // podciągnięcie pinu INT0 do VCC<br />EICRA |= (1&lt;&lt;ISC11);   // wyzwalanie zboczem opadajacym<br />EIMSK |= (1&lt;&lt;INT1);      // odblokowanie przerwania<br /><br /><br />//konfiguracja TIMER2 dla F_CPU 1159200<br />TCCR2A |= (1&lt;&lt;WGM21);<br />TCCR2B |= (1&lt;&lt;CS20) | (1&lt;&lt;CS21) | (1&lt;&lt;CS22);<br />OCR2A = 78;<br />TIMSK2 = (1&lt;&lt;OCIE2A);<br />cntSensor = search_sensors();<br />}<br /><br />//************ główna funkcja main() programu *****************************<br />int main(void) {<br /><br /><br />setup();<br />// inicjalizacja UART<br />USART_Init(__UBRR);<br />register_uart_str_rx_event_callback( parse_uart_data );<br /><br />sei();// globalne odblokowanie przerwać<br /><br />// przedstawienie się układu przez UART po starcie<br />uart_puts(&quot;I|CoManager ON\r\n&quot;);<br />// przedstawienie liczby znalezionych sensorów &#91; S &#93;<br />uart_puts(&quot;S|&quot;);<br />uart_putint(cntSensor, 10);<br />uart_putc('\n');// nowa linia*/<br /><br />LED_MANUAL_OFF;<br /><br />// petla główna programu<br />_delay_ms(1000);<br /><br />while(1) {<br />UART_RX_STR_EVENT(bufor);<br />// ******* KLAWISZ FLUSH<br />if( !key1_lock &amp;&amp; !KEY_FLUSH_DOWN ) {<br />key1_lock=1;<br />sendTotalConsumption(totalConsumption);<br />totalConsumption = 0;<br />} else if( key1_lock &amp;&amp; KEY_FLUSH_DOWN ) key1_lock++;<br /><br />// ******* Regulator pokojowy<br />if( !key2_lock &amp;&amp; !KEY_HEAT_CONTROLLER_DOWN ) {<br />// regulator pokojowy &quot;wcisniety&quot;<br />key2_lock=1;<br />uart_puts(&quot;|HC|&quot;);//29<br />uart_puts(DS2408);<br />uart_puts(&quot;|OFF&quot;);<br />uart_putc('\n');<br />thermostatKey = 0;<br />LED_MANUAL_OFF; //zielona<br />}<br />else if( key2_lock &amp;&amp; KEY_HEAT_CONTROLLER_DOWN )<br />{<br />if( !++key2_lock ) {<br />// reakcja na PUSH_UP (zwolnienie przycisku)<br />uart_puts(&quot;|HC|&quot;);<br />uart_puts(DS2408);<br />uart_puts(&quot;|ON&quot;);<br />uart_putc('\n');<br />thermostatKey = 1;<br />LED_MANUAL_ON; //zielona<br />}<br />}<br /><br /><br />switch (currentHeatState) {<br />case PERMANENT :<br />if(currentHeatState != previousHeatState) {<br />RELAY_ON;<br />uart_puts(&quot;|CHS|&quot;); //Central Heating Stove - piec centralnego ogrzewania<br />uart_puts(DS2408);<br />uart_puts(&quot;|ON|MANUAL&quot;);<br />uart_putc('\n');<br />previousHeatState = currentHeatState;<br />}<br />break;<br />case VARY :<br />if (thermostatKey) {<br />if(currentHeatState != previousHeatState) {<br />RELAY_ON;<br />uart_puts(&quot;|CHS|&quot;); //Central Heating Stove - piec centralnego ogrzewania<br />uart_puts(DS2408);<br />uart_puts(&quot;|ON|AUTO&quot;);<br />uart_putc('\n');<br />previousHeatState = currentHeatState;<br />}<br />}else{<br />currentHeatState = OFF;<br />}<br />break;<br />case OFF :<br />if (!thermostatKey) {<br />if(currentHeatState != previousHeatState) {<br />RELAY_OFF;<br />uart_puts(&quot;|CHS|&quot;); //Central Heating Stove - piec centralnego ogrzewania<br />uart_puts(DS2408);<br />uart_puts(&quot;|CHS|OFF&quot;);<br />uart_putc('\n');<br />previousHeatState = currentHeatState;<br />}<br />}else{<br />currentHeatState = VARY;<br />}<br />break;<br /><br />}<br /><br />//co minutę odczytujemy termometry i wysyłamy ich wynik<br />if (secFlag ){<br />if (seconds % tempPeriodTime == 0)<br />DS18X20_start_meas(DS18X20_POWER_EXTERN, NULL);<br />if (seconds % tempPeriodTime == 1)<br />for (z = 0; z &lt; cntSensor; z++){ sendTemp(z); };<br />secFlag = 0;<br /><br />/*<br /> * obsluga dekrementacji zmiennej z liczba sekund po ktorej mozna<br /> * powtornie obslugiwac przerwanie.<br /> * Gdy licznik sekund zero - wylaczamy diode ( pomaranczowa )<br /> */<br />if ( int1_start &gt; 0 )<br />int1_start--;<br />else if (int1_start == 0)<br />LED_HALL_OFF;<br /><br />}<br /><br />/*<br /> * Gdy jest flag przerwania i dodatkowo licznik sekund jest wyzerowany<br /> * to wysyłamy info o zuzyciu jednostkowy, zwiekszamy licznik calkowitego<br /> * zuzycia i zerujemy flage przerwania.<br /> * Na koniec ustawiamy licznik sekund na 10 co spowoduje mozliwosc<br /> * obslugi przerwania dopiero po 10 sekundach<br /> */<br />if (int1_flag &amp;&amp; int1_start == 0 ) {<br />sendConsumption();<br />int1_flag = 0;<br />totalConsumption++;<br />int1_start=10;<br />}<br />}<br /><br />}<br />//************************* koniec main() **********************<br /><br />ISR(TIMER2_COMPA_vect)<br />{<br />static uint8_t cnt=0;   /* statyczna zmienna cnt do odliczania setnych ms */<br />uint16_t x;<br />if(++cnt&gt;99) {  /* gdy licznik ms &gt; 99 (mineła 1 sekunda) */<br />cnt=0;  /* wyzeru licznik setnych ms */<br />secFlag=1;      /* ustaw flagę tyknięcia sekundy */<br />    seconds++;      /* zwiększ licznik sekund */<br />    if(seconds&gt;59)<br />    seconds=0; /* jeżeli ilość sekund &gt; 59 - wyzeruj */<br /><br />}<br /><br />x =Timer1;<br />if (x) Timer1 = --x;<br /><br />}<br /><br />// procedura obsługi przerwania INT 0<br />ISR( INT1_vect ) {<br />int1_flag = 1; // flaga obslugi przerwania<br />LED_HALL_ON; // zapalenie diody sygnalizacyjnej - pomaranczowa<br />//_delay_ms(40); //mało optymalne, ale bezpieczne<br />}[/syntax]<br /><br />do tego common.h<br />[syntax=c]/*<br /> * common.h<br /> *<br /> *  Created on: 9 mar 2016<br /> *      Author: GL<br /> */<br /><br />#ifndef COMMON_H_<br />#define COMMON_H_<br /><br />#define DS2408 &quot;2912345678ABC&quot; //8 switch<br />#defineDS2423 &quot;1D12345678ABC&quot; //counter<br /><br />enum heatState {PERMANENT, VARY, OFF};<br />enum heatState currentHeatState = VARY;<br />enum heatState previousHeatState = OFF;<br /><br />volatile uint16_t tempPeriodTime = 60; //liczba sekund pomiedzy odczytami temperatury<br />volatile uint16_t totalConsumption = 0;<br /><br /><br />void sendTotalConsumption(uint16_t consumption);<br /><br />#endif /* COMMON_H_ */[/syntax]<br /><br />i common.c<br />[syntax=c]/*<br /> * common.c<br /> *<br /> *  Created on: 9 mar 2016<br /> *      Author: GL<br /> */<br /><br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;stdint.h&gt;<br />#include &quot;common.h&quot;<br />#include &quot;MKUART/mkuart.h&quot;<br /><br /><br />void sendTotalConsumption(uint16_t consumption){<br />uart_puts(&quot;TC|&quot;);// wyślij tekst<br />uart_puts(DS2423);<br />uart_puts(&quot;|&quot;);<br />uart_putint(consumption, 10);<br />uart_putc('\n');// wyślij znak LF (nowa linia)<br />}[/syntax]<br /><br />no i na koniec dwie funkcje z atcommands<br />[syntax=c]/*<br /> * komendy_at.c  <br /> *<br /> *  Created on: 13-03-2012<br /> *      Author: Mirosław Kardaś<br /> */<br /><br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &quot;../MKUART/mkuart.h&quot;<br />#include &quot;atcommands.h&quot;<br />#include &quot;../common.h&quot;<br /><br />#define AT_CNT 6// iloć poleceń AT<br /><br />//----------- tablica z poleceniami AT i wskaźnikami funkcji do ich obsługi --------------------<br />const TATCMD polecenia_at&#91;AT_CNT&#93; PROGMEM = {<br />// { at_cmd } , { wskaźnik do funkcji obsługi at },<br />{&quot;AT&quot;, at_service},<br />{&quot;ATI&quot;, ati_service},<br />{&quot;AT+RST&quot;, at_rst_service},<br />{&quot;AT+LED&quot;, at_led_service},<br />{&quot;AT+TC&quot;, at_tc_service},<br />{&quot;AT+STATE&quot;,at_state_service},<br />};<br /><br /><br />int8_t at_tc_service(uint8_t inout, char * params) {<br />if( !inout ){<br />//sendTotalConsumption(13);<br />;<br />}<br />return 0;<br />}<br /><br />int8_t at_state_service(uint8_t inout, char * params) {<br />if( 1 == inout) {<br />//ustawienie statusu<br />if( params&#91;0&#93; &lt; '0' || params&#91;0&#93; &gt; '1' ) return -1;<br />if( '1' == params&#91;0&#93; )<br />currentHeatState = PERMANENT;<br />else<br />currentHeatState = VARY;;<br /><br />//currentHeatState = 'PERMANENT';<br />} else if( !inout ){<br />//odczyt statusu<br />uart_puts(&quot;+STATE: &quot;);<br />switch (currentHeatState) {<br />case PERMANENT : uart_puts(&quot;PERMANENT\r\n&quot;); break;<br />case VARY      : uart_puts(&quot;VARY\r\n&quot;); break;<br />case OFF   : uart_puts(&quot;OFF\r\n&quot;); break;<br />}<br />} else if( 2 == inout ){<br />uart_puts(&quot;AT+STATE = (0-1)\r\n&quot;);<br />}<br /><br />return 0;<br />}[/syntax]<br /><br />Nie załączam całego kodu atcommands.c bo to nie open-source <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=503">gaza</a> — 10 mar 2016, o 20:39</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[kicajek]]></name></author>
<updated>2016-03-10T18:39:32+01:00</updated>
<published>2016-03-10T18:39:32+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155858#p155858</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155858#p155858"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155858#p155858"><![CDATA[
Witam<br />Jak się napisze do ogółu to nikt nie przeczyta, jak do konkretnej osoby ( może inni zobaczą ) to troszkę niesmacznie brzmi, ale &quot; my tu staramy się pomóc w oparciu o jakieś podstawy programowe a nie raporty co jest źle - nie da się wróżyć&quot;<br /><div class="quotetitle">gaza napisał(a):</div><div class="quotecontent"><br />czyli common musi byc załączony<br /></div><br />Nie wiadomo co tam masz, ale może do tych zmiennych które mają też być w main.c dopisz <strong>extern</strong>.<br />Jeśli nie obawiasz się plagiatu  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" />  ani tego że ktoś Ci to podprowadzi to zamieść <strong>cały</strong> kod; może ktoś z nudów doprowadzi to do &quot;kompilowalności&quot;<br /><br />Pozdr.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=826">kicajek</a> — 10 mar 2016, o 18:39</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[gaza]]></name></author>
<updated>2016-03-10T18:02:21+01:00</updated>
<published>2016-03-10T18:02:21+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155854#p155854</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155854#p155854"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155854#p155854"><![CDATA[
rzeczywiście przeoczenie, bo ten kod był dzisiaj maglowany kilka razy.<br />w main były jeszcze raz te definicje, zakomentowałem i teraz mam inne błędy<br /><div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />17:53:54 **** Incremental Build of configuration Release for project usart ****<br />make all <br />Building file: ../main.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -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: z_uart.elf<br />Invoking: AVR C Linker<br />avr-gcc -Wl,-Map,z_uart.map -mmcu=atmega88 -o &quot;z_uart.elf&quot;  ./MKUART/mkuart.o  ./ATCOMMANDS/atcommands.o  ./1Wire/crc8.o ./1Wire/ds18x20.o ./1Wire/onewire.o  ./common.o ./main.o   <br />./main.o:(.bss.totalConsumption+0x0): multiple definition of `totalConsumption'<br />makefile:53: polecenia dla obiektu 'z_uart.elf' nie powiodły się<br />./ATCOMMANDS/atcommands.o:(.bss.totalConsumption+0x0): first defined here<br />./main.o:(.data.currentHeatState+0x0): multiple definition of `currentHeatState'<br />./ATCOMMANDS/atcommands.o:(.data.currentHeatState+0x0): first defined here<br />./main.o:(.data.previousHeatState+0x0): multiple definition of `previousHeatState'<br />./ATCOMMANDS/atcommands.o:(.data.previousHeatState+0x0): first defined here<br />./main.o:(.data.tempPeriodTime+0x0): multiple definition of `tempPeriodTime'<br />./ATCOMMANDS/atcommands.o:(.data.tempPeriodTime+0x0): first defined here<br />collect2: error: ld returned 1 exit status<br />make: *** [z_uart.elf] Błąd 1<br /><br />17:53:55 Build Finished (took 508ms)<br /></div><br /><br />Jak usunę include z common.h z pliku main.c to mam tak<br /><div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />17:57:13 **** Incremental Build of configuration Release for project usart ****<br />make all <br />Building file: ../main.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;main.d&quot; -MT&quot;main.d&quot; -c -o &quot;main.o&quot; &quot;../main.c&quot;<br />../main.c: In function ‘main’:<br />../main.c:166:25: error: ‘totalConsumption’ undeclared (first use in this function)<br />    sendTotalConsumption(totalConsumption);<br />                         ^<br />../main.c:166:25: note: each undeclared identifier is reported only once for each function it appears in<br />subdir.mk:21: polecenia dla obiektu 'main.o' nie powiodły się<br />../main.c:195:11: error: ‘currentHeatState’ undeclared (first use in this function)<br />   switch (currentHeatState) {<br />           ^<br />../main.c:196:8: error: ‘PERMANENT’ undeclared (first use in this function)<br />   case PERMANENT :<br />        ^<br />../main.c:197:27: error: ‘previousHeatState’ undeclared (first use in this function)<br />    if(currentHeatState != previousHeatState) {<br />                           ^<br />../main.c:206:8: error: ‘VARY’ undeclared (first use in this function)<br />   case VARY :<br />        ^<br />../main.c:217:24: error: ‘OFF’ undeclared (first use in this function)<br />     currentHeatState = OFF;<br />                        ^<br />../main.c:239:18: error: ‘tempPeriodTime’ undeclared (first use in this function)<br />    if (seconds % tempPeriodTime == 0)<br />                  ^<br />make: *** [main.o] Błąd 1<br /><br />17:57:13 Build Finished (took 205ms)<br /></div><br /><br />czyli common musi byc załączony w main.c ,ale wtedy mam info, że multiple definition<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=503">gaza</a> — 10 mar 2016, o 18:02</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2016-03-10T17:48:02+01:00</updated>
<published>2016-03-10T17:48:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155852#p155852</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155852#p155852"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155852#p155852"><![CDATA[
<div class="quotetitle">gaza napisał(a):</div><div class="quotecontent"><br />bo przy kompilacji mam taką listę błędów<br /></div><br />A czytasz ty chociaż po kolei te błędy co ci się pokazują ? Bo coś mi się wydaje, że nie za bardzo - bo nawet gdybyś chciał powiedzieć, że nie znasz angielskiego to wystarczyłoby użyć google translate .... a błędy masz podane jak na talerzu, proszę pierwszy:<br /><br /><div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />../main.c:18:19: error: redefinition of ‘tempPeriodTime’<br /></div><br /><br />co to znaczy ? .... no że w pliku main.c masz powtórnie zdefiniowaną zmienną o podanej tu nazwie. Żeby tego było mało w kolejnych linijkach kompilator cię informuje DOKŁADNIE,<br /><br /><div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />In file included from ../main.c:15:0:<br />../common.h:15:19: note: previous definition of ‘tempPeriodTime’ was here<br />volatile uint16_t tempPeriodTime = 60;<br /></div><br /><br />gdzie ją masz wcześniej zdefiniowaną czyli w pliku common.h ... no to powiedz sam - czego więcej oczekiwać ? Skoro widać, że zdublowałeś zmienne ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 10 mar 2016, o 17:48</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[gaza]]></name></author>
<updated>2016-03-10T17:37:17+01:00</updated>
<published>2016-03-10T17:37:17+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155851#p155851</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155851#p155851"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155851#p155851"><![CDATA[
poprawione<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=503">gaza</a> — 10 mar 2016, o 17:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jaglarz]]></name></author>
<updated>2016-03-10T17:22:43+01:00</updated>
<published>2016-03-10T17:22:43+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155849#p155849</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155849#p155849"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155849#p155849"><![CDATA[
<div class="quotetitle">gaza napisał(a):</div><div class="quotecontent"><br />PS. dlaczego po zmianie znaczników z code na syntax zginęły wartości includów ?<br /></div><br /><br />Bo źle wstawiłeś kod <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";-)" title="Puszcza oko" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=471">Jaglarz</a> — 10 mar 2016, o 17:22</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[BIGjack]]></name></author>
<updated>2016-03-10T17:00:51+01:00</updated>
<published>2016-03-10T17:00:51+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155848#p155848</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155848#p155848"/>
<title type="html"><![CDATA[Re: podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155848#p155848"><![CDATA[
<div class="quotetitle">gaza napisał(a):</div><div class="quotecontent"><br />jak zorganizować projekt aby było przejrzyście i zgodnie ze sztuką ?<br /></div><br /><br />Zacznij może od poprawnego wstawienia kodu na forum aby było przejrzyście i zgodnie ze sztuką <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1249">BIGjack</a> — 10 mar 2016, o 17:00</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[gaza]]></name></author>
<updated>2016-03-10T17:36:53+01:00</updated>
<published>2016-03-10T16:56:54+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155847#p155847</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155847#p155847"/>
<title type="html"><![CDATA[podział projektu na moduły]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14814&amp;p=155847#p155847"><![CDATA[
witam.<br />Zrobiłem sobie urządzenie do podglądu działań pieca CO. Piec retortowy opalany miałem ,ale to mniej istotne.<br />Urządzenie ma mieć możliwość współpracy z regulatorem pokojowym, liczyć ilość ruchów retory  (szuflady ), mierzyć i wysyłać temperatury w różnych punktach instalacji.<br />To tytułem wstępu.<br /><br />Program korzysta z bibliotek [syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &quot;MKUART/mkuart.h&quot;<br />#include &quot;1Wire/ds18x20.h&quot;<br />#include &quot;common.h&quot;<br />#include &quot;ATCOMMANDS/atcommands.h&quot;[/syntax]<br /><br />i tu zaczyna się problem, bo <br />w main korzystam między innymi  z kilku zmiennych i funkcji<br />[syntax=c]enum heatState {PERMANENT, VARY, OFF};<br />enum heatState currentHeatState = VARY;<br />enum heatState previousHeatState = OFF;<br /><br />volatile uint16_t tempPeriodTime = 60; //liczba sekund pomiedzy odczytami temperatury<br />volatile uint16_t totalConsumption = 0;<br /><br /><br />void sendTotalConsumption(uint16_t consumption);[/syntax]<br /><br />Program tych samych zmiennych musi korzystać w bibliotece ATCOMMANDS.<br />Zmienne na początku były zdefiniowane w main ( jak jeszcze nie korzystałem z ATCOMMANDS), ale potem okazało się że muszą być zdefiniowane gdzieś globalnie aby i w ATCOMMANDS były dostępne. Utowrzyłem zatem plik common.h i tam je wrzuciłem, po czym zainkludowałem je do main.c i atcommands.c [syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &quot;../MKUART/mkuart.h&quot;<br />#include &quot;atcommands.h&quot;<br />#include &quot;../common.h&quot;[/syntax]<br /><br />i tu pojawia się problem.<br />bo przy kompilacji mam taką listę błędów<div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />make all <br />Building file: ../ATCOMMANDS/atcommands.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;ATCOMMANDS/atcommands.d&quot; -MT&quot;ATCOMMANDS/atcommands.d&quot; -c -o &quot;ATCOMMANDS/atcommands.o&quot; &quot;../ATCOMMANDS/atcommands.c&quot;<br />Finished building: ../ATCOMMANDS/atcommands.c<br /> <br />Building file: ../1Wire/crc8.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;1Wire/crc8.d&quot; -MT&quot;1Wire/crc8.d&quot; -c -o &quot;1Wire/crc8.o&quot; &quot;../1Wire/crc8.c&quot;<br />Finished building: ../1Wire/crc8.c<br /> <br />Building file: ../1Wire/ds18x20.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;1Wire/ds18x20.d&quot; -MT&quot;1Wire/ds18x20.d&quot; -c -o &quot;1Wire/ds18x20.o&quot; &quot;../1Wire/ds18x20.c&quot;<br />Finished building: ../1Wire/ds18x20.c<br /> <br />Building file: ../1Wire/onewire.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;1Wire/onewire.d&quot; -MT&quot;1Wire/onewire.d&quot; -c -o &quot;1Wire/onewire.o&quot; &quot;../1Wire/onewire.c&quot;<br />Finished building: ../1Wire/onewire.c<br /> <br />Building file: ../common.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;common.d&quot; -MT&quot;common.d&quot; -c -o &quot;common.o&quot; &quot;../common.c&quot;<br />Finished building: ../common.c<br /> <br />../main.c:18:19: error: redefinition of ‘tempPeriodTime’<br /> volatile uint16_t tempPeriodTime = 60; //liczba sekund pomiedzy odczytami temperatury<br />                   ^<br />In file included from ../main.c:15:0:<br />../common.h:15:19: note: previous definition of ‘tempPeriodTime’ was here<br /> volatile uint16_t tempPeriodTime = 60; //liczba sekund pomiedzy odczytami temperatury<br />Building file: ../main.c<br />Invoking: AVR Compiler<br />avr-gcc -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega88 -DF_CPU=11059200UL -MMD -MP -MF&quot;main.d&quot; -MT&quot;main.d&quot; -c -o &quot;main.o&quot; &quot;../main.c&quot;<br />                   ^<br />../main.c:19:19: error: redefinition of ‘totalConsumption’<br /> volatile uint16_t totalConsumption = 0;<br />                   ^<br />In file included from ../main.c:15:0:<br />../common.h:16:19: note: previous definition of ‘totalConsumption’ was here<br />subdir.mk:21: polecenia dla obiektu 'main.o' nie powiodły się<br /> volatile uint16_t totalConsumption = 0;<br />                   ^<br />make: *** [main.o] Błąd 1<br /></div><br /><br />jak zorganizować projekt aby było przejrzyście i zgodnie ze sztuką ?<br /><br /><br /><br />Pozdr<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=503">gaza</a> — 10 mar 2016, o 16:56</p><hr />
]]></content>
</entry>
</feed>