2012-03-08 10 views
1

Arduino Unoをskm53 GPSモジュールに接続しようとしていますが、Arduinoソフトウェアでスケッチをアップロードする前に確認し、次のエラーが見つかりました。Arduino UnoとSKYNAV skm53 GPSモジュールとの接続エラー

Error: #error NewSoftSerial has been moved into the Arduino core as of version 1.0. Use SoftwareSerial instead.

私はArduinoのツールのライブラリディレクトリ内のライブラリのTinyGPSとNewSoftSerialが含まれていた、私が検索し、ほぼすべてのコードは私と同じであることを見出しました。

#include <TinyGPS.h> 
#include <NewSoftSerial.h> 

unsigned long fix_age; 
NewSoftSerial GPS(2,3); 
TinyGPS gps; 
void gpsdump(TinyGPS &gps); 
bool feedgps(); 
void getGPS(); 
long lat, lon; 
float LAT, LON; 

void setup(){ 
    GPS.begin(9600); 
    //Serial.begin(115200); 
} 

void loop(){ 
    long lat, lon; 
    unsigned long fix_age, time, date, speed, course; 
    unsigned long chars; 
    unsigned short sentences, failed_checksum; 

    // Retrieves +/- latitude/longitude in 100000ths of a degree. 
    gps.get_position(&lat, &lon, &fix_age); 

    getGPS(); 
    Serial.print("Latitude : "); 
    Serial.print(LAT/100000,7); 
    Serial.print(" :: Longitude : "); 
    Serial.println(LON/100000,7); 
} 

void getGPS(){ 
    bool newdata = false; 
    unsigned long start = millis(); 
    // Every 1 seconds we print an update. 
    while (millis() - start < 1000) 
    { 
     if (feedgps()){ 
      newdata = true; 
     } 
    } 
    if (newdata) 
    { 
     gpsdump(gps); 
    } 
} 

bool feedgps(){ 
    while (GPS.available()) 
    { 
     if (gps.encode(GPS.read())) 
      return true; 
    } 
    return 0; 
} 

void gpsdump(TinyGPS &gps) 
{ 
    //byte month, day, hour, minute, second, hundredths; 
    gps.get_position(&lat, &lon); 
    LAT = lat; 
    LON = lon; 
    { 
     feedgps(); // If we don't feed the GPS during this long 
        //routine, we may drop characters and get 
        //checksum errors. 
    } 
} 

答えて

1

旧式の例(アルドゥーノ1.0より前、ソフトアライアンス前)があります。 これらの例は、Arduino .23以前で使用されていました。 はちょうどこのようなコードのあなたの最初の4行を変更し、それは大丈夫コンパイルします:

#include <TinyGPS.h> 
#include <SoftwareSerial.h> 

unsigned long fix_age; 
SoftwareSerial GPS(2,3); 

その後、将来の問題を回避するためにNewSoftLibraryを削除することができます。

また、同じ名前だが大文字と小文字が異なる2つの変数を持つと、非常に混乱します。 名前をすばやく識別するために、よりわかりやすい名前を使用する方がよいでしょう。おそらく、シリアルソフトウェア接続インターフェースの場合はssGPS、小さなGPSライブラリーの場合はtlibGPSが適しています。

関連する問題