need of lower case .tcx not .TCX extension

Hello guys,

I’m working on a Gps data logger,logging the data into the SD Card, and while it creates a new .tcx file in the SD card, the system saving it as a .TCX extension, I probably needs it in a lower case .tcx not in upper case .TCX

Please help!

Thanks

Here is my code :

#include <TinyGPS++.h>
#include <SPI.h>
#include <SD.h>
#include <EEPROM.h>
int addr = 0;
TinyGPSPlus gps;
File dataFile;
char abc[32];
char def[32];
char aaa[32];
int dat = 0, v = 0;
float lat0 = 0.0, lat1 = 0.0, lng0 = 0.0, lng1 = 0.0, dis = 0.0;
String kk;
int LED = 5;
int LEDD = 6;
void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(LEDD, OUTPUT);

  Serial.begin(9600);
  Serial2.begin(9600);
  pinMode(7, INPUT_PULLUP);
  if (!SD.begin(53))
  {
    Serial.println("Card failed");
    return;
  }
  Serial.println("card initialized.");
  v = EEPROM.read(0);
  v++;
  EEPROM.write(0, v);
}


void loop()
{

  printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
  printInt(gps.hdop.value(), gps.hdop.isValid(), 5);
  printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
  printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
  printDateTime(gps.date, gps.time);
  printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
  Serial.println();

  smartDelay(1000);
  
  if (millis() > 5000 && gps.charsProcessed() < 10)
  Serial.println(F("No GPS data received: check wiring"));
  Serial.println(dat);

  do {
    lat0 = (String(gps.location.lat(), 6)).toFloat();
    lng0 = (String(gps.location.lng(), 6)).toFloat();

  }
  while (lat0 == 0.0);


  if (lat0 !=  0.0 && dat == 1)
  {
    Serial.println("Co-ordinates Achived");
    Serial.println("Date Achived");
    kk = String(v) + ".tcx";
    Serial.println(kk);
    dataFile = SD.open(kk, FILE_WRITE);
    if (dataFile) {
      Serial.println("File created");
      dataFile.println(F("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
      dataFile.println(F("<TrainingCenterDatabase xmlns=\"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2\">"));
      dataFile.println(F("<Activities>"));
      dataFile.println(F("<Activity Sport=\"Other\">"));
      Serial.println(F("done 1st part"));
      dataFile.println("<Id>");
      dataFile.print(String(def));
      dataFile.print("T");
      //dataFile.print(String(abc));
      dataFile.print(".000Z");
      dataFile.println("</Id>");
      dataFile.println("<Lap StartTime=\"");
      //dataFile.print(String(def));
      dataFile.print("T");
      dataFile.print(String(abc));
      dataFile.print(".000Z\">");
      dataFile.println("<Track>");

      digitalWrite(LED, HIGH);
    }
    else
    {
      digitalWrite(LED, LOW);
    }
    logging();
  }
  else {
    Serial.println("CANT OPEN FILE");
  }

}

void logging()
{
  Serial.println("came in loop 1");
  while (1)
  {
    if (digitalRead(7) == LOW)
      endtask();
    printDateTime(gps.date, gps.time);
    if (millis() > 5000 && gps.charsProcessed() < 10)
      Serial.println(F("No GPS data received: check wiring"));

    dataFile.println("<Trackpoint>");
    dataFile.println("<Time>");
    dataFile.print(String(def));
    dataFile.print("T");
    dataFile.print(String(abc));
    dataFile.print(".000Z");
    dataFile.print("</Time>");
    dataFile.println("<Position>");
    {
      lat1 = (String(gps.location.lat(), 6)).toFloat();
      lng1 = (String(gps.location.lng(), 6)).toFloat();

      float distLat = abs(lat0 - lat1) * 111194.9;
      float distLong = 111194.9 * abs(lng0 - lng1) * cos(radians((lat0 + lat1) / 2));
      dis = dis + sqrt(pow(distLat, 2) + pow(distLong, 2));
      Serial.println(dis, 6);
      lat0 = lat1;
      lng0 = lng1;
    }
    {
      dataFile.print("<LatitudeDegrees>");
      dataFile.print(String(lat1, 6));
      Serial.println(String(lat1, 6));
      dataFile.println("</LatitudeDegrees>");
      dataFile.print("<LongitudeDegrees>");
      dataFile.print(String(lng1, 6));
      Serial.println(String(lng1, 6));
      dataFile.println("</LongitudeDegrees>");
      dataFile.println("</Position>");
      dataFile.print("<AltitudeMeters>");
      dataFile.print((String(gps.altitude.meters(), 2)));
      dataFile.println("</AltitudeMeters>");
      dataFile.println("<DistanceMeters>");
      dataFile.println(String(dis, 6));
      dataFile.println("</DistanceMeters>");
      dataFile.println("</Trackpoint>");
      Serial.print("Recorded");
    }
    def[0] = NULL;
    abc[0] = NULL;
    smartDelay(1000);
  }
}


static void printFloat(float val, bool valid, int len, int prec)
{
  if (!valid)
  {
    while (len-- > 1)
      Serial.print('*');
    Serial.print(' ');
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1); // . and -
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i = flen; i < len; ++i)
      Serial.print(' ');
  }
  smartDelay(0);
}






void endtask()
{
  dataFile.println("</Track>");
  dataFile.println("</Lap>");
  dataFile.println("</Activity>");
  dataFile.println("</Activities>");
  dataFile.println("</TrainingCenterDatabase>");
  dataFile.close();
  Serial.print("file close");
  digitalWrite(LEDD, HIGH);

  while (1);
}







static void printInt(unsigned long val, bool valid, int len)
{
  char sz[32] = "*****************";
  if (valid)
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i = strlen(sz); i < len; ++i)
    sz[i] = ' ';
  if (len > 0)
    sz[len - 1] = ' ';
  Serial.print(sz);
  smartDelay(0);
}






static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)
{
  if (!d.isValid())
  {
    Serial.print(F("********** "));
    dat = 0;
  }
  else
  {

    sprintf(def, "%02d-%02d-%02d", d.year(), d.month(), d.day());
    Serial.print(def);
    dat = 1;
  }

  if (!t.isValid())
  {
    Serial.print(F("******** "));
  }
  else
  {

    sprintf(abc, "%02d:%02d:%02d", t.hour(), t.minute(), t.second());
    Serial.print(abc);
    sprintf(aaa, "%02d%02d%02d", t.hour(), t.minute(), t.second());
    Serial.print(aaa);

  }
  smartDelay(0);
}

static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (Serial2.available())
      gps.encode(Serial2.read());
  } while (millis() - start < ms);
}

SD.h only supports upper case 8.3 filenames.

SD.h uses an early version of SdFat that I wrote in 2009.

Newer versions of SdFat support long filenames with upper/lower case.

Try SdFat-beta, it is mostly compatible with the old Arduino SD.h wrapper.

Replace this:

#include <SD.h>

With this:

#include "SdFat.h"
SdFat SD;