Fleker / MSP430-DAQ

Record data to MSP430 flash and automatically download to CSV
2 stars 1 forks source link

I get this error message when I compile typical/given example. #3

Open hemangjoshi37a opened 7 years ago

hemangjoshi37a commented 7 years ago

Using Board : MSP 430 F 5529 Launch pad OS : Linux Mint 18 Error Message :

Energia: 1.6.10E18 (Linux), Board: "MSP-EXP430F5529LP"

WARNING: Spurious .github folder in 'Adafruit PCD8544 Nokia 5110 LCD library' library WARNING: Spurious .github folder in 'RTClib' library

:0:12: warning: missing whitespace after the macro name [enabled by default] In file included from /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:23:0, from /tmp/arduino_modified_sketch_147698/SDCardTutorialWithEnergia.ino:1: /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:57:3: error: expected unqualified-id before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:57:3: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:95:25: error: expected primary-expression before ',' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:95:27: error: expected primary-expression before 'const' /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:95:38: error: expression list treated as compound expression in initializer [-fpermissive] /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:25: error: expected primary-expression before ',' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:34: error: expected primary-expression before '*' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:35: error: expected primary-expression before ')' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:35: error: expression list treated as compound expression in initializer [-fpermissive] In file included from /tmp/arduino_modified_sketch_147698/SDCardTutorialWithEnergia.ino:1:0: /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:37:11: error: expected unqualified-id before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:37:11: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected identifier before '(' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected ';' at end of member declaration /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected unqualified-id before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected identifier before '(' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected ';' at end of member declaration /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected unqualified-id before numeric constant exit status 1 Error compiling for board MSP-EXP430F5529LP. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Code :

#include <pfatfs.h>
//#include <pffconf.h>

/*----------------------------------------------------------------------*/
/* Petit FatFs sample project for generic uC  (C)ChaN, 2010             */
/*----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
   Ported to Energia by calinp
   Copy the file LOG.txt from this file's location to the root of the 
   SD-Card.

   12/21/2013
   Modified by bluehash(43oh) to log temperature data from the MSP430G2553
   internal temperature sensor and log it to a file on the SD-Card
   References:
   http://forum.43oh.com/topic/3209-energia-library-petit-fatfs-sd-card-library/
 */

#include "SPI.h" 
#include "pfatfs.h"

#define cs_pin      P2_6           // chip select pin 
#define read_buffer 128             // size (in bytes) of read buffer 
#define LOG_DELAY   5000          // 5000ms -> 5sec

unsigned short int bw, br;//, i;
char buffer[read_buffer];
int rc;
//FSDIR dir;                /* Directory object */
FILINFO fno;            /* File information object */

uint32_t ui32_ReadTemp = 0;
uint8_t StringLength = 0;
char buf[30];
uint32_t counter = 0;
uint32_t AccStringLength = 0;

void setup()
{
   pinMode(PUSH2, INPUT_PULLUP);
   Serial.begin(9600);                // initialize the serial terminal
   analogReference(INTERNAL1V5);
   analogRead(TEMPSENSOR);           // first reading usually wrong
   FatFs.begin(cs_pin);              // initialize FatFS library calls
   Serial.print("\n\n\n MSP430 Temperature Logger \n\r"); 
   Serial.println("Press S2 button to start...");
   while(digitalRead(PUSH2)==1){}
   delay(100);
   while(digitalRead(PUSH2)==0){}
}

/* Stop with dying message */         
void die ( int pff_err  )
{
   Serial.println();
   Serial.print("Failed with rc=");
   Serial.print(pff_err,DEC);
   for (;;) ;
}

void printDec(uint32_t ui) 
{
   Serial.print(ui/10, DEC);
   Serial.print(".");
   Serial.print(ui%10, DEC);
}

/*-----------------------------------------------------------------------*/
/* Program Main                                                          */
/*-----------------------------------------------------------------------*/
void loop()
{
   #if 0
   Serial.println();
   Serial.println("Press button to start...");
   while(digitalRead(PUSH2)==1){}
   delay(100);
   while(digitalRead(PUSH2)==0){}
   #endif

   ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)*27069 - 18169625) *10 >> 16;

   #if DEBUG
   Serial.println();
   Serial.println("Opening log file to write temperature(LOG.txt).");
   delay(100);
   #endif

   rc = FatFs.open("LOG.TXT");
   if (rc) die(rc);

   delay(100);
   bw=0;
   ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)*27069 - 18169625) *10 >> 16;
   sprintf( buf, "%lu Current temperature is %lu.%lu\r\n", counter, ui32_ReadTemp/10, ui32_ReadTemp%10 );
   counter++;
   StringLength =  strlen(buf);
   Serial.println(buf);        

   #if DEBUG
   Serial.print(StringLength, DEC);
   Serial.println();
   Serial.print(AccStringLength, DEC);
   #endif

   rc = FatFs.lseek(  AccStringLength );
   if (rc) die(rc);
   AccStringLength =  AccStringLength + 512;
   rc = FatFs.write(buf, StringLength,&bw);
   if (rc) die(rc);
   rc = FatFs.write(0, 0, &bw);  //Finalize write
   if (rc) die(rc);
   rc = FatFs.close();  //Close file
        if (rc) die(rc);

   #if READ         
   delay(100);
   Serial.println();
   Serial.println("Read Temp data from the log file (LOG.txt).");
   delay(100);
   rc = FatFs.open("LOG.TXT");
   if (rc) die(rc);

   delay(100);
   for (;;) {
   rc = FatFs.read(buffer, sizeof(buffer), &br);    /* Read a chunk of file */
   if (rc || !br) break;            /* Error or end of file */
   for (uint16_t i = 0; i < br; i++)        /* Type the data */
   Serial.print(buffer[i]);
   delay(100);
   }
   if (rc) die(rc);
   #endif

   // Log delay
   delay(LOG_DELAY);
}
Fleker commented 7 years ago

Seems like the errors are syntax issues related to two lib files. Can you confirm they are correct?

On Jun 5, 2017 9:30 AM, "Hemang Joshi" notifications@github.com wrote:

Using Board : MSP 430 F 5529 Launch pad OS : Linux Mint 18 Error Message :

Energia: 1.6.10E18 (Linux), Board: "MSP-EXP430F5529LP"

WARNING: Spurious .github folder in 'Adafruit PCD8544 Nokia 5110 LCD library' library WARNING: Spurious .github folder in 'RTClib' library :0:12: warning: missing whitespace after the macro name [enabled by default] In file included from /media/hemang/586E740B6E73DFE4/msp/energia- 1.6.10E18/libraries/pfatfs/pfatfs.h:23:0, from /tmp/arduino_modified_sketch_147698/SDCardTutorialWithEnergia.ino:1: /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:57:3: error: expected unqualified-id before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:57:3: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:95:25: error: expected primary-expression before ',' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:95:27: error: expected primary-expression before 'const' /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:95:38: error: expression list treated as compound expression in initializer [-fpermissive] /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:25: error: expected primary-expression before ',' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:34: error: expected primary-expression before '*' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:35: error: expected primary-expression before ')' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/utility/pff.h:96:35: error: expression list treated as compound expression in initializer [-fpermissive] In file included from /tmp/arduino_modified_sketch_147698/ SDCardTutorialWithEnergia.ino:1:0: /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:37:11: error: expected unqualified-id before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:37:11: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected identifier before '(' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected ';' at end of member declaration /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:81:19: error: expected unqualified-id before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected identifier before '(' token /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected ')' before numeric constant /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected ';' at end of member declaration /media/hemang/586E740B6E73DFE4/msp/energia-1.6.10E18/libraries/pfatfs/pfatfs.h:84:19: error: expected unqualified-id before numeric constant exit status 1 Error compiling for board MSP-EXP430F5529LP.

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Code :

include

//#include

/----------------------------------------------------------------------/ / Petit FatFs sample project for generic uC (C)ChaN, 2010 / /----------------------------------------------------------------------/ /*----------------------------------------------------------------------- Ported to Energia by calinp Copy the file LOG.txt from this file's location to the root of the SD-Card.

12/21/2013 Modified by bluehash(43oh) to log temperature data from the MSP430G2553 internal temperature sensor and log it to a file on the SD-Card References: http://forum.43oh.com/topic/3209-energia-library-petit-fatfs-sd-card-library/ */

include "SPI.h"

include "pfatfs.h"

define cs_pin P2_6 // chip select pin

define read_buffer 128 // size (in bytes) of read buffer

define LOG_DELAY 5000 // 5000ms -> 5sec

unsigned short int bw, br;//, i; char buffer[read_buffer]; int rc; //FSDIR dir; / Directory object / FILINFO fno; / File information object /

uint32_t ui32_ReadTemp = 0; uint8_t StringLength = 0; char buf[30]; uint32_t counter = 0; uint32_t AccStringLength = 0;

void setup() { pinMode(PUSH2, INPUT_PULLUP); Serial.begin(9600); // initialize the serial terminal analogReference(INTERNAL1V5); analogRead(TEMPSENSOR); // first reading usually wrong FatFs.begin(cs_pin); // initialize FatFS library calls Serial.print("\n\n\n MSP430 Temperature Logger \n\r"); Serial.println("Press S2 button to start..."); while(digitalRead(PUSH2)==1){} delay(100); while(digitalRead(PUSH2)==0){} }

/ Stop with dying message / void die ( int pff_err ) { Serial.println(); Serial.print("Failed with rc="); Serial.print(pff_err,DEC); for (;;) ; }

void printDec(uint32_t ui) { Serial.print(ui/10, DEC); Serial.print("."); Serial.print(ui%10, DEC); }

/-----------------------------------------------------------------------/ / Program Main / /-----------------------------------------------------------------------/ void loop() {

if 0

Serial.println(); Serial.println("Press button to start..."); while(digitalRead(PUSH2)==1){} delay(100); while(digitalRead(PUSH2)==0){}

endif

ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)27069 - 18169625) 10 >> 16;

if DEBUG

Serial.println(); Serial.println("Opening log file to write temperature(LOG.txt)."); delay(100);

endif

rc = FatFs.open("LOG.TXT"); if (rc) die(rc);

delay(100); bw=0; ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)27069 - 18169625) 10 >> 16; sprintf( buf, "%lu Current temperature is %lu.%lu\r\n", counter, ui32_ReadTemp/10, ui32_ReadTemp%10 ); counter++; StringLength = strlen(buf); Serial.println(buf);

if DEBUG

Serial.print(StringLength, DEC); Serial.println(); Serial.print(AccStringLength, DEC);

endif

rc = FatFs.lseek( AccStringLength ); if (rc) die(rc); AccStringLength = AccStringLength + 512; rc = FatFs.write(buf, StringLength,&bw); if (rc) die(rc); rc = FatFs.write(0, 0, &bw); //Finalize write if (rc) die(rc); rc = FatFs.close(); //Close file if (rc) die(rc);

if READ

delay(100); Serial.println(); Serial.println("Read Temp data from the log file (LOG.txt)."); delay(100); rc = FatFs.open("LOG.TXT"); if (rc) die(rc);

delay(100); for (;;) { rc = FatFs.read(buffer, sizeof(buffer), &br); / Read a chunk of file / if (rc || !br) break; / Error or end of file / for (uint16_t i = 0; i < br; i++) / Type the data / Serial.print(buffer[i]); delay(100); } if (rc) die(rc);

endif

// Log delay delay(LOG_DELAY); }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Fleker/MSP430-DAQ/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ADI58w1QvAcbZiAPy73PDmbtHi8k-SBvks5sBAMBgaJpZM4NwCn6 .

hemangjoshi37a commented 7 years ago

Well I have not modified any code of the files. I just have compiled the given example by the author. So I dont know if there is any syntax problem.

Fleker commented 7 years ago

the given example by the author

Oh no.

pff.h 57:3

typedef struct {
WORD    index;      /* Current read/write index number */
BYTE*   fn;         /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
CLUST   sclust;     /* Table start cluster (0:Static table) */
CLUST   clust;      /* Current cluster */
DWORD   sect;       /* Current sector */
} DIR;

pff.h:95:25

FRESULT pf_opendir (DIR*, const char*);         /* Open a directory */

pff.h:96:25

FRESULT pf_readdir (DIR*, FILINFO*);            /* Read a directory item from the open directory */

pfatfs.h:37:11

static DIR dir_obj;

pfatfs.h:81:19

FRESULT opendir (DIR*, const char*);        /* Open a directory */

pfatfs.h:84:19

FRESULT readdir (DIR*, FILINFO*);           /* Read a directory item from the open directory */

So, it seems like something weird is happening with defining DIR, potentially creating a cascading effect. However, I'm not sure why that error is happening. Probably something related to error: expected unqualified-id before numeric constant but not sure why.

Fleker commented 7 years ago

If you are using both the pfatfs and sd libraries, then maybe you are defining DIR twice. Try to remove one of the libraries.

hemangjoshi37a commented 7 years ago

Yes man, that is true but I dont know that kind of IT stuff. Do you have any repaired header file that do not have any this kind of syntax problems??

Fleker commented 7 years ago

That's the only version of the file that was committed, and nothing about it seems out of the ordinary. I got it working with the provided example and then wrote a new example for the project.

Seems like you comment out the include pffconf and the DIR variable declaration. Can you get one of the existing projects to compile? Maybe it's just some odd change on your end.