Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Parsing data from CSV file on: September 22, 2014, 01:51:28 pm
Hi, i try to get datas from a CSV file on SD Card.

the problem is that i'm trying to locate the "," character, to get field before and after.

For now, the error is : "Request for member 'indexOf' in 'buffer', which is a non class type 'char[90]
on ligne 41
I'm not understanding the error, please could you give me the issue ?


Thanks
Code:

#include <SdFat.h>

// SD chip select pin
const uint8_t chipSelect = 53;

// file system object
SdFat sd;

// create a serial stream
ArduinoOutStream cout(Serial);

void testGetline() {
 const int line_buffer_size = 90;
 char buffer[line_buffer_size];
 char Suffix, Command, Angle, DAngle;
 float Coor_X, Coor_Y, Dep_X, Dep_Y, Long_Stitch;
 
 ifstream sdin("TURTLE.CSV");
 int line_number = 0;

 while (sdin.getline(buffer, line_buffer_size, '\n') || sdin.gcount()) {
    int count = sdin.gcount();
    if (sdin.fail()) {
      cout << "Partial long line";
      sdin.clear(sdin.rdstate() & ~ios_base::failbit);
    } else if (sdin.eof()) {
      cout << "Partial final line";  // sdin.fail() is false
    } else {
      count--;  // Don’t include newline in count
      cout << "Line " << ++line_number;
    }
 cout << buffer << endl;
 int Flag1 = buffer.indexOf(',');               // Flag after the suffix
 int Flag2 = buffer.indexOf(',', Flag1 + 1);    // Flag after the Command
 int Flag3 = buffer.indexOf(',', Flag2 + 1);    // Flag after the Coord_X
 int Flag4 = buffer.indexOf(',', Flag3 + 1);    // Flag after the Coord_Y
 int Flag5 = buffer.indexOf(',', Flag4 + 1);    // Flag after the Dep_X
 int Flag6 = buffer.indexOf(',', Flag5 + 1);    // Flag after the Dep_Y
 int Flag7 = buffer.indexOf(',', Flag6 + 1);    // Flag after the Long_Stitch
Serial.println (buffer);
Serial.print ("Positions: ";
Serial.print (Flag1);
Serial.print (" / ");
Serial.print (Flag2);
Serial.print (" / ");
Serial.print (Flag3);
Serial.print (" / ");
Serial.print (Flag4);
Serial.print (" / ");
Serial.print (Flag5);
Serial.print (" / ");
Serial.print (Flag6);
Serial.print (" / ");
Serial.println (Flag7);
delay (500);
  }
}
//------------------------------------------------------------------------------
void setup(void) {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo

  // pstr stores strings in flash to save RAM
  cout << pstr("Type any character to start\n");
  while (Serial.read() <= 0) {}
  delay(400);  // catch Due reset problem

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

    testGetline();
  cout << "\nDone!\n";
}
//------------------------------------------------------------------------------
void loop(void) {}
2  International / Français / Re: Incompréhension transfert de valeurs par le port serie on: February 16, 2014, 06:55:35 am
Je transmet avec une paire d'APC220, par contre, les essais effectués, sont faits avec une liaison filaire entre les 2 MCU (Tx-Rx et GND)

Toutes les liaisons séries sont faites à 9600 Bauds.

Après, dans le terminal Série (No line Ending    9600 Bds     /     Autoscroll)

Merci
3  International / Français / Re: Incompréhension transfert de valeurs par le port serie on: February 16, 2014, 05:42:40 am
Merci pour la remarque,

mais cela n'a rien changé, je reçois toujours "  ÿ  ", sur le terminal Série du PC
4  International / Français / Re: Incompréhension transfert de valeurs par le port serie on: February 16, 2014, 05:22:07 am
Merci pour vos réponses, j'ai compris les boucles FOR !!!
J'ai modifié le code, les boucles s'executent, par contre les données renvoyées sur le terminal du PC ressemblent à "  ÿ  " !!!
Rien à voir avec ce que j'ai envoyé.
- Est ce que le MEGA 2560 interprète bien 'A'   ???
- Pourquoi la valeur renvoyée est "  ÿ  "    ???

Merci de votre aide !

Olivier

EMETTEUR
Code:
// Mega 1280  EMETTEUR

char Valeurs[4] = {'A','B','C','D'};
int Start = 2;
void setup()
{
Serial1.begin(9600);
pinMode (Start, HIGH);
pinMode (2, OUTPUT);
}
void loop()
{
  digitalWrite (2, HIGH);
//  if (digitalRead (Start) == HIGH){
    for (int i=0 ; i < 6 ; i++){
      if (i == 5){
        Serial1.println();
        break;
      }
      Serial1.println (Valeurs[i]);
      delay (100);
     }
//  }
}

RECEPTEUR:
Code:
// MEGA 2560 RECEPTEUR
char Valeurs[4];
char Temp = 0;
void setup()
{
Serial1.begin(9600);
Serial.begin(9600);
}
void loop()
{
  for(int i=0 ; i < 5 ; i++)
  {
   Valeurs[i] = Serial1.read ();
//   Serial.print ("DECIMAL:  ");
//   Serial.println (Valeurs[i], DEC);  // print as an ASCII-encoded decimal
//   Serial.print ("HEXA:  ");
//   Serial.println (Valeurs[i], HEX);  // print as an ASCII-encoded hexadecimal
//   Serial.print ("OCTAL:  ");
//   Serial.println (Valeurs[i], OCT);  // print as an ASCII-encoded octal
//   Serial.print ("BINAIRE:  ");
//   Serial.println (Valeurs[i], BIN);  // print as an ASCII-encoded binary
//   Serial.print ("RAW:  ");
   Serial.println (Valeurs[i],DEC);
   delay (250);
  }
}
5  International / Français / Nouveau club electronique / Robotique / Arduino en Nord Isere isererobot.fr on: February 15, 2014, 07:22:39 pm
Nous créons un club électronqiue, robotique, arduino, pour ceux qui sont intéressés.

Tous niveaux acceptés !

Prochaine réunion le Vendredi 21 février à 20H00, salle des fêtes de Rochetoirin,

si vous êtes intéressés, cela n'engage à rien, venez avec vos idées !!!
plus d'informations:
http://www.isererobot.fr
6  International / Français / Incompréhension transfert de valeurs par le port serie on: February 15, 2014, 06:17:02 pm
Bonjour a tous après BEAUCOUP de recherches personnelles, j'en suis arrivé à la conclusion que je ne comprends rien au port Série !
J'ai besoin de votre aide, jute pour comprendre comment envoyer et recevoir, correctement, des données par le port série:
1 MEGA 1280 envoie par liaison série (sans fil) à un MEGA 2560 un array de 4 valeurs.
le MEGA 2560 les envoi sur le port Série relié au PC, le PC les affiche dans le terminal (Ctrl Maj M).
Code de l'émetteur:
Code:
// Mega 1280  EMETTEUR

char Valeurs[4] = {'A','B','C','D'};
int Start = 2;
void setup()
{
Serial1.begin(9600);
pinMode (Start, HIGH);
}
void loop()
{
  if (digitalRead (Start) == HIGH){
    for (int i=0 ; i == 5 ; i++){
      if (i == 5){
        Serial1.println();
        break;
      }
      Serial1.print (Valeurs[i]);
      delay (100);
     }
  }
}

code du récepteur:
Code:
// MEGA 2560 RECEPTEUR
char Valeurs[4];
char Temp = 0;
void setup()
{
Serial1.begin(9600);
Serial.begin(9600);
}
void loop()
{
  for(int i=0 ; i==4 ; i++)
  {
   Valeurs[i] = Serial1.read ();
   Serial.println (Valeurs[i]);
   delay (100);
  }
}

Si quelqu'un pourrait me dire:
- Pourquoi je ne reçois rien sur le terminal Série du PC ?
- Est ce que si je vois inscrit (sur le terminal du PC) :  A   , le MEGA 2560 verra, lui aussi un A ?
- N'y a t'il pas quelques règles à respecter pour l'envoi et la réception de valeurs par le port Série ?

Merci à vous

Olivier
7  Using Arduino / Displays / Re: Graphic LCD Double text problem on: February 03, 2013, 04:44:11 am
Ok, thanks for reply,

i am agree with you that both chips receiving the same info, but i am sure that CS1 and CS2 are not connected together and it works with the demo program !

Please, do you have other idea ?
8  Using Arduino / Displays / Graphic LCD Double text problem on: February 02, 2013, 06:27:24 pm
Hello, thanks for this great forum !!!

 i'm running a 128x64 Graphic LCD with a Arduino MEGA 2560, and i try to make lines of text display on the screen,

Everything works fine with the demo Program, but with my program everything is displayed 2 times

this is a part of my program.

thanks

Code:

#include <glcd.h>
#include "fonts/Arial14.h"         // proportional font
#include "fonts/SystemFont5x7.h"   // system font

void setup()
{
  GLCD.Init();   // initialise the library, non inverted writes pixels onto a clear screen
}

void loop(){
  GLCD.ClearScreen();
  GLCD.SelectFont(System5x7);
  GLCD.Puts("PROGRAMME");
  GLCD.CursorTo (0 , 1);
  GLCD.Puts ("HEAT V1.06");
  delay (2000);
}

9  Using Arduino / Sensors / Nano and float bas result on: December 16, 2012, 09:09:12 am
Hello,

i"m here to ask for a bad result of float data acquisition on NANO Card.

I'm acquiring, with PulseIn(), the lenght (in µS) of a square wave impulsion.

Next i want to transform it to Second.

The problem is that the Float variable is limited at 0,001, no more decimals available.

I also, tried with Double, and get the same problem.

--> Do you know how to increase the decimal numbers.


thanks

Olivier
10  Using Arduino / Programming Questions / Re: DS1307 SPI incorrect values on: October 25, 2011, 01:16:07 pm
Thank you Paul for your informations !

I found my mistake,
i changed the Date/Time values type to INT, removed ,DEC at the end of each string addition, everything is running bright !


Many thanks for your help


Regards
11  Using Arduino / Programming Questions / Re: DS1307 SPI incorrect values on: October 25, 2011, 12:28:31 pm
Ok PaulS, but how do you explain that there is value "10" for all Date/time values ?

I fell that my values are not formatted correctly, but how do you do it ?


Please let me know,

Regards
12  Using Arduino / Programming Questions / DS1307 SPI incorrect values on: October 25, 2011, 12:26:25 am
Hi, i can't find solution at my problem,

maybe someone coud help me !

I'm running with an arudino MEGA2560, DS1307 is connected via I2C, SD Card is connected to SPI.


On the first code, it is a function to acquire date on RTC DS1307 (date and time variables are declared as byte)

On the second part of code, it a a string arrangement to send values to SD CARD file.
For date and time values, the data sent to the file are always "10", i can't have the real date and time values, i'm sure that the DS1307 is giving good informations (it's working with demo program)

I feel that the problem is in string arrangement with date/time variable format.

Please can you help me ?


Thanks

Code:
void getDateDs1307()
{
  // Reset the register pointer
  Wire.beginTransmission(0x68);
  Wire.send(0);
  Wire.endTransmission();
  Wire.requestFrom(0x68, 7);
 
  second     = bcdToDec(Wire.receive() & 0x7F);
  minute     = bcdToDec(Wire.receive());
  hour       = bcdToDec(Wire.receive() & 0x3F);  // Need to change this if 12 hour am/pm
  dayOfWeek  = bcdToDec(Wire.receive());
  dayOfMonth = bcdToDec(Wire.receive());
  month      = bcdToDec(Wire.receive());
  year       = bcdToDec(Wire.receive());
 
  Serial.print(hour,DEC);
  Serial.print(":");
  Serial.print(minute,DEC);
  Serial.print(":");
  Serial.print(second,DEC);
  Serial.print(" ");
  Serial.print(dayOfMonth,DEC);
  Serial.print("/");
  Serial.print(month,DEC);
  Serial.print("/20");
  Serial.print(year, DEC);
  Serial.println();
}



Code:

getDateDs1307(); 

dataString = "*** ";                      // *** sur la chaine de caractères
        dataString += commentaire;                // Ajout de la chaine commentaire dans la chaine de caractères
        dataString += "***";                      // *** sur la chaine de caracteres
        dataString += ";";
        dataString += hour;
        dataString += ":";
        dataString += minute;
        dataString += ":";
        dataString += (second,DEC);
        dataString += ";";
        dataString += (dayOfMonth,DEC);
        dataString += "/";
        dataString += (month,DEC);
        dataString += "/20";
        dataString += (year,DEC);
       
13  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 problems on: October 24, 2011, 04:01:03 pm
Thank you PaulS, it works fine ! You tips was the right one !

Following, i found why my DS1307 was not working, i was missing Wire.begin() inside setup !

Now i still have a last problem before running my Arduino on heater:

On the first code, it is a function to acquire date on RTC DS1307 (date and time variables are declared as byte)

On the second part of code, it a a string arrangement to send it to SD CARD file.
The data sent to the file are always "10", i can't have the real date and time values, i'm sure that the DS1307 is giving good informations.

I feel that the problem is in string arrangement with date/time variable format.

Please can you help me ?


Thanks

Code:
void getDateDs1307()
{
  // Reset the register pointer
  Wire.beginTransmission(0x68);
  Wire.send(0);
  Wire.endTransmission();
  Wire.requestFrom(0x68, 7);
 
  second     = bcdToDec(Wire.receive() & 0x7F);
  minute     = bcdToDec(Wire.receive());
  hour       = bcdToDec(Wire.receive() & 0x3F);  // Need to change this if 12 hour am/pm
  dayOfWeek  = bcdToDec(Wire.receive());
  dayOfMonth = bcdToDec(Wire.receive());
  month      = bcdToDec(Wire.receive());
  year       = bcdToDec(Wire.receive());
 
  Serial.print(hour,DEC);
  Serial.print(":");
  Serial.print(minute,DEC);
  Serial.print(":");
  Serial.print(second,DEC);
  Serial.print(" ");
  Serial.print(dayOfMonth,DEC);
  Serial.print("/");
  Serial.print(month,DEC);
  Serial.print("/20");
  Serial.print(year, DEC);
  Serial.println();
}










Code:
getDateDs1307(); 

dataString = "*** ";                      // *** sur la chaine de caractères
        dataString += commentaire;                // Ajout de la chaine commentaire dans la chaine de caractères
        dataString += "***";                      // *** sur la chaine de caracteres
        dataString += ";";
        dataString += hour;
        dataString += ":";
        dataString += minute;
        dataString += ":";
        dataString += (second,DEC);
        dataString += ";";
        dataString += (dayOfMonth,DEC);
        dataString += "/";
        dataString += (month,DEC);
        dataString += "/20";
        dataString += (year,DEC);
       
14  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 problems on: October 23, 2011, 12:27:13 pm
Hi PaulS, thanks for helping me,

my problem is with this part of code.

First, during serial connection, i write C with text after and sending to Arduino.
Arduino needs to read each character, adding the current date/time and write them inside SD file AND send the String to the serial.
The string sended to Arduino by Serial is for example: CAAA, but when arduino send it back to Serial, it sends 656565.

So i would him to send AAA.

Please help me,

Regards


Code:
if (command == 'C')                        // Si le caractère C est envoyé
          {
        int chrserial = 0;
        String dataString = "";
        String commentaire = "";
            for (int i=0 ; i<10 ; i++){
        chrserial = Serial.read ();             // Lecture du commentaire sur le port série
        commentaire += chrserial;
            }
           
        dataString = "*** ";                      // *** sur la chaine de caractères
        dataString += (commentaire);              // Ajout de la chaine commentaire dans la chaine de caractères
        dataString += "***";                      // *** sur la chaine de caracteres
        File dataFile = SD.open("data00.csv", FILE_WRITE);   // Ouverture du fichier Data00/csv sur la carte SD
            if (dataFile) {                                  // Si le fichier existe
            dataFile.println(dataString);                    // Ecriture de la chaine de caractères
            dataFile.close();                                // Fermeture du fichier dans la carte SD
            Serial.println ("Commentaire ajouté :");         // Envoi sur le porte série du résultat
            Serial.print (commentaire);                 // Envoi sur le porte série du commentaire ajouté
            }
15  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 problems on: October 23, 2011, 10:45:22 am
Sorry,

i forgot to tell you, that i'm using Arduino Mega 2560, I2C connected to 20 et 21 (I2C SDA/SCL).
I'm sure it is a syntax problem, because when using DS1307 demo program, all is functionning ok !

For ASCII, i tried what you tell Serial.print(Val,DEC), but it continue giving a A as 65.

Please let me know

Olivier
Pages: [1] 2