Pages: [1]   Go Down
Author Topic: Hiiiilfeeeee  (Read 756 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ich habe hier den folgenden programmcode gefunden :

void loop() {
  while (gpsSerial.available()) {
    hauptZeile[hschlecht] = gpsSerial.read();
    if (hauptZeile[hschlecht++] == '\n') {
      hauptZeile[hschlecht-1] = '\0'; // Ende einer Zeile -> Ende des Strings
      if (hauptZeile[0] == '$' && hauptZeile[1] == 'G' && hauptZeile[2] == 'P' && hauptZeile[3] == 'R' && hauptZeile[4] == 'M' && hauptZeile[5] == 'C') {
        Serial.println(hauptZeile);// GPRMC..

und ich bin neu im gebiet programmieren ^^
da wollte ich mal wissen was genau die bedingung der zeile:

 if (hauptZeile[hschlecht++] == '\n') {

bedeutet... kann mal nix mit dem '\n' anfangen
danke schonmal für die hilfe smiley))
Logged

Forum Moderator
BZ (I)
Offline Offline
Brattain Member
*****
Karma: 251
Posts: 21243
+39 349 2158303
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if (hauptZeile[hschlecht++] == '\n') {
Da wird die das Arrayelement "hauptZeile[hschlecht]" verglichen ob es das Zeichen "\n" (return oder 13 oder 0X0A) ist und sofort nach dem vergleich der index "hschlecht" um 1 erhöht.
Grüße Uwe
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello smiley i've this code :

void loop() {
  while (gpsSerial.available()) {
    hauptZeile[hschlecht] = gpsSerial.read();
    if (hauptZeile[hschlecht++] == '\n') {
      hauptZeile[hschlecht-1] = '\0'; // Ende einer Zeile -> Ende des Strings
      if (hauptZeile[0] == '$' && hauptZeile[1] == 'G' && hauptZeile[2] == 'P' && hauptZeile[3] == 'R' && hauptZeile[4] == 'M' && hauptZeile[5] == 'C') {
        Serial.println(hauptZeile);// GPRMC..

and i'm new in programming ^^
and i dont know what this means:

 if (hauptZeile[hschlecht++] == '\n') {

another example:

if(string[i++]=='\n'

i dont know what the '\n' makes
could someone explain to me ??
thx 4 help
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

\n is the way C represents the linefeed (LF) character. It is Ascii character 10
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

daaaanke für die schnelle antwort smiley
Logged

Offline Offline
Jr. Member
**
Karma: 4
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
hauptZeile[] is an array of character and the code

Code:
if (hauptZeile[hschlecht++] == '\n')

simply checks if the character at index hschlecht is equal to the constant '\n' that is a newline. A character constant is specified between single quotation marks es. 'A', '2', 'b', etc. Special characters are indicated by using the escape sequence: '\n' is a new-line, '\t' is a tab, etc.
It seems that your code is reading characters from the serial port and detects the end of a sentence by  checking the new-line character.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the fast reply smiley

helps much smiley

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hat mir sehr geholfen smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25761
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the German for "DO NOT CROSS-POST", please?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Offline Offline
Newbie
*****
Karma: 13
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ben1306
Es ist schlechtes Benehmen (Netikette) in einem Forum die gleiche Frage in verschiedenen Kategorien zu stellen.
Grüße Uwe Federer
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25761
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Danke
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Das tut mir leid kommt nicht mehr vor smiley-wink ist mein erstes forum in dem ich angemeldet bin ^^
Logged

Germany
Online Online
Edison Member
*
Karma: 46
Posts: 2310
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Das tut mir leid kommt nicht mehr vor smiley-wink ist mein erstes forum in dem ich angemeldet bin ^^
Dann gebe ich dir noch einen weiteren Tipp auf den Weg: Wähle als Titel etwas aussagekräftigeres als "Hiiiilfeeee".  Man soll hieran ja erkennen, worum es geht.
Logged

Mein Arduino-Blog: http://www.sth77.de/ - letzte Einträge: Teensy 3.0 - Teensyduino unter Window 7 - Teensyduino unter Windows 8

Pages: [1]   Go Up
Jump to: