Go Down

Topic: Help needed with declaration (Read 983 times) previous topic - next topic

Ashuk

Hello people, i got an error when i compile my codings in arduino IDE saying that the declaration of a text file is wrong, I have added the sdFAT library but still i coudnt declare the Test file with the variable FAT. Can anyone help me to declare,

My coding is,

#include <SoftwareSerial.h>
#include <byteordering.h>
#include <fat.h>
#include <FAT16.h>
#include <fat_config.h>
#include <partition.h>
#include <partition_config.h>
#include <sd-reader_config.h>
#include <sd_raw.h>
#include <sd_raw_config.h>

byte incomingbyte;
SoftwareSerial cameraSerial= SoftwareSerial(4,5);          // Set Arduino pin 4 and 5 as softserial
long int a=0x0000,j=0,k=0,count=0,i=0;                           
uint8_t MH,ML;
boolean EndFlag=0;
FAT TestFile;   //This is the place i get error   
                               
void SendResetCmd();
void SetBaudRateCmd();
void SetImageSizeCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{
  boolean sd_raw_init();
  Serial.begin(38400);
  cameraSerial.begin(38400);
  pinMode(2,OUTPUT);       //pin 2 is connected to LED to indicate the status of SD card initialization

  if(!sd_raw_init())
{
    digitalWrite(2,HIGH);
    while(1);     
}   
TestFile.initialize();
TestFile.create_file("xiaohui.jpg");     // create a new jpeg file

}

void loop()
{     
byte a[32];

     SendResetCmd();
     delay(4000);                            //Wait 2-3 second to send take picture command
     
      SendTakePhotoCmd();

     while(cameraSerial.available()>0)
      {
        incomingbyte=cameraSerial.read();
      }   

     TestFile.open();
      while(!EndFlag)
      { 
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();
         delay(20);
          while(cameraSerial.available()>0)
          {
               incomingbyte=cameraSerial.read();
               k++;
               if((k>5)&&(j<32)&&(!EndFlag))
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))     //tell if the picture is finished
               EndFlag=1;                           
               j++;
          count++;
               }
          }
         
        for(j=0;j<count;j++)
        {   if(a[j]<0x10)
         Serial.print("0");
        Serial.print(a[j],HEX);           // observe the image through serial port
         Serial.print(" ");
       }
       
          TestFile.write((char*)a);   
          Serial.println();
     
         i++;
     
      }
    TestFile.close();   
   Serial.print("Finished writing data to file"); 

     while(1);
}


void SendResetCmd()
{
  cameraSerial.write((byte)0x56);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x26);
  cameraSerial.write((byte)0x00);
}

void SetImageSizeCmd()
{
      cameraSerial.write((byte)0x56);
      cameraSerial.write((byte)0x00);
     cameraSerial.write((byte)0x31);
      cameraSerial.write((byte)0x05);
      cameraSerial.write((byte)0x04);
      cameraSerial.write((byte)0x01);
     cameraSerial.write((byte)0x00);
      cameraSerial.write((byte)0x19);
      cameraSerial.write((byte)0x11);
}

void SetBaudRateCmd()
{
     cameraSerial.write((byte)0x56);
     cameraSerial.write((byte)0x00);
     cameraSerial.write((byte)0x24);
     cameraSerial.write((byte)0x03);
      cameraSerial.write((byte)0x01);
      cameraSerial.write((byte)0xAE);
      cameraSerial.write((byte)0xC8);

}



void SendTakePhotoCmd()
{
  cameraSerial.write((byte)0x56);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x36);
  cameraSerial.write((byte)0x01);
  cameraSerial.write((byte)0x00); 
}


void SendReadDataCmd()
{
      MH=a/0x100;
      ML=a%0x100;
  cameraSerial.write((byte)0x56);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x32);
  cameraSerial.write((byte)0x0c);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x0a);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)MH);
  cameraSerial.write((byte)ML);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x20);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x0a);
      a+=0x20;     
}

void StopTakePhotoCmd()
{
  cameraSerial.write((byte)0x56);
  cameraSerial.write((byte)0x00);
  cameraSerial.write((byte)0x36);
  cameraSerial.write((byte)0x01);
  cameraSerial.write((byte)0x03);       
}

Ashuk

The error that i get,

sketch_aug16a:17: error: 'FAT' does not name a type
sketch_aug16a.ino: In function 'void setup()':
sketch_aug16a:38: error: 'TestFile' was not declared in this scope
sketch_aug16a.ino: In function 'void loop()':
sketch_aug16a:57: error: 'TestFile' was not declared in this scope

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy