0
EM-406a GPS 수신기에서 정보 (위도, 경도)를 취하여 Arduino 방패의 SD 카드에 정보를 쓰도록 스케치했습니다. 프로그램 실행이 완료 될 때GPS 출력이 SD 카드의 파일에 잘못 쓰여졌습니다. Arduino
나는 SD 카드의 파일을 열#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <SD.h>
TinyGPSPlus gps;
SoftwareSerial ss(4, 3); //pins for the GPS
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
void setup()
{
Serial.begin(115200); //for the serial output
ss.begin(4800); //start ss at 4800 baud
Serial.println("gpsLogger by Aaron McRuer");
Serial.println("based on code by Mikal Hart");
Serial.println();
//initialize the SD card
if(!card.init(SPI_FULL_SPEED, 9))
{
Serial.println("card.init failed");
}
//initialize a FAT volume
if(!volume.init(&card)){
Serial.println("volume.init failed");
}
//open the root directory
if(!root.openRoot(&volume)){
Serial.println("openRoot failed");
}
//create new file
char name[] = "WRITE00.TXT";
for (uint8_t i = 0; i < 100; i++){
name[5] = i/10 + '0';
name[6] = i%10 + '0';
if(file.open(&root, name, O_CREAT | O_EXCL | O_WRITE)){
break;
}
}
if(!file.isOpen())
{
Serial.println("file.create");
}
file.print("Ready...\n");
}
void loop()
{
bool newData = false;
//For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ss.available())
{
char c = ss.read();
//Serial.write(c); //uncomment this line if you want to see the GPS data flowing
if(gps.encode(c)) //did a new valid sentence come in?
newData = true;
}
}
if(newData)
{
file.write(gps.location.lat());
file.write("\n");
file.write(gps.location.lng());
file.write("\n");
}
file.close();
}
, 나는 그것을 인코딩 오류가 있다는 메시지가 다음과 같이
프로그램입니다.
나는 내 현재 해요 (및 GPS 신호, 따라서 0을 얻을 수 없습니다)하지만, 인코딩 문제를 해결해야 할 필요가, 초 그만큼의 라인이 있어야한다 장치가 켜져 있습니다. 그 중 하나만 있습니다. 내가 제대로 작동하게하려면 무엇을해야합니까?
인코딩 오류 (또는 그것이 무엇이든지간에)를 처리했지만,'file.open (& root, name, O_CREAT | O_EXCL | O_WRITE)'의 다른 사본을'loop '함수를 사용하면 여전히 한 줄만 표시됩니다. – nerdenator
신경 쓰지 마라. – nerdenator