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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2016-10-10T21:15:12+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=47&amp;t=16444&amp;mode</id>
<entry>
<author><name><![CDATA[iwi]]></name></author>
<updated>2016-10-10T21:15:12+01:00</updated>
<published>2016-10-10T21:15:12+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171180#p171180</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171180#p171180"/>
<title type="html"><![CDATA[Re: Funkcja serialEvent() z Arduino Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171180#p171180"><![CDATA[
Dziękuję - czyli tak jak myślałem musze tą funkcję Event wywołać.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1988">iwi</a> — 10 paź 2016, o 21:15</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Nefarious19]]></name></author>
<updated>2016-10-10T21:11:57+01:00</updated>
<published>2016-10-10T21:11:57+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171179#p171179</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171179#p171179"/>
<title type="html"><![CDATA[Re: Funkcja serialEvent() z Arduino Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171179#p171179"><![CDATA[
Każdego EVENTa wykonuje się na okragło żeby sprawdzić czy coś sie wydarzyło a Event jeżeli cos się wydarzy wywołuję Twoją funkcję callbakową.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2500">Nefarious19</a> — 10 paź 2016, o 21:11</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[iwi]]></name></author>
<updated>2016-10-10T20:58:28+01:00</updated>
<published>2016-10-10T20:58:28+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171178#p171178</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171178#p171178"/>
<title type="html"><![CDATA[Funkcja serialEvent() z Arduino Library]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16444&amp;p=171178#p171178"><![CDATA[
Witajcie. Po lekturze GreenBooka postanowiłem funkcję Callbacków wykorzystać w Arduino do cyklicznego odbierania danych z UARTa. Niestety z moimi umiejętnościami nic nie wyszło, ale przeszukując internet znalazłem funkcję serialEvent() w głównej bibliotece. Pomyślałem, że może się nada no i coś w niej jest nie tak. Pozwolę sobie ją przytoczyć.<br />[syntax=c]String inputString = &quot;&quot;;         // a string to hold incoming data<br />boolean stringComplete = false;  // whether the string is complete<br /><br />void setup() {<br />  // initialize serial:<br />  Serial.begin(9600);<br />  // reserve 200 bytes for the inputString:<br />  inputString.reserve(200);<br />  serialEvent();<br />}<br /><br />void loop() {<br />  // print the string when a newline arrives:<br /><br />  if (stringComplete) {<br />    Serial.println(inputString);<br />    // clear the string:<br />    inputString = &quot;&quot;;<br />    stringComplete = false;<br />  }<br />}<br /><br />/*<br />  SerialEvent occurs whenever a new data comes in the<br /> hardware serial RX.  This routine is run between each<br /> time loop() runs, so using delay inside loop can delay<br /> response.  Multiple bytes of data may be available.<br /> */<br />void serialEvent() {<br />  while (Serial2.available()) {<br />    // get the new byte:<br />    char inChar = (char)Serial2.read();<br />    // add it to the inputString:<br />    inputString += inChar;<br />    // if the incoming character is a newline, set a flag<br />    // so the main loop can do something about it:<br />    if (inChar == '\n') {<br />      stringComplete = true;<br />    }<br />  }<br />}[/syntax]<br />To jest gotowy pzykład który miał działać, ale nie działa. Żeby zaczęło to działać to trzeba wywołać w LOOP funkcję serialEvent() bo niby skąd to miałoby wiedzieć, ze ta funkcja ma się wykonać. Czy tą funkcję tak się używa, że wywołuje się ją w głównej pętli czy coś poknociłem.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1988">iwi</a> — 10 paź 2016, o 20:58</p><hr />
]]></content>
</entry>
</feed>