Show Posts
Pages: 1 ... 9 10 [11] 12 13 ... 33
151  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 20, 2013, 03:06:45 pm
my goal is record some set

at 0x00ii at the first loop.
at 0x01ii at the 2nd loop
at 0x02ii at the third loop
at 0x03ii at the 4th loop

etc

"ii" being 08,18,28,38,48 depending of the subjetc (LAT, LON, ALT etc

152  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 20, 2013, 03:01:55 pm
Dear Michael,

Your example is interresting but I do not understand a part.
Code:
// Set mask EPROM_INC in state
state |= EPROM_INC;
I miss skills, if EPROM_INC is 0x0100, state will be 1 or 0x0100 as well? |= is lake to copy a value to another variable? I0ve never see |
Code:
// clear EPROM_INC in state
state &= ~EPROM_INC;
I also never see this &= ~. And what do you mean by clearing. EPROM_INC must keep its value as it was a const
Code:
// do action if mask is set
if ((state & EPROM_INC) != 0)  { ... }
In Above condition, EPROM_INC will never be egal to 0, it will always be 0x0100, or may 0x0200...
Code:
// do action if mask is not set
if ((state & EPROM_INC) == 0) { ... }
idem
153  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 20, 2013, 02:32:04 pm
Hello, thank for your answer and example.

May be I used a bad word with mask. I called "mask" because is going to be "applay" to a value, increment the 2nd digit. But it true, it's more an incrementation.
154  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 19, 2013, 05:06:44 pm
Hello

Thank for your answer. It's look really better and it helps
I changed like this

Code:
// THIS WILL INCREMENT THE MASK
#define EPROM_INC 0x0100

#define EPROM_LAT 0x0008

unsigned int result;

// THIS IS A MASK
unsigned int mask = 0x0000;

mask = mask+EPROM_INC;

result = mask+EPROM_LAT;

We are agree, that now result will be 0x0108?

I will do better test tomorrow that I can not do right now.


0x0008 represente a position in the EEPROM to record a value.
This value change and it's important that the new value is recorded at
0x0108. And the next is recorded at
0x0208, and the next is recorded at
0x0308 etc....

(there will have a loop for the that)

Thank a lot
155  Using Arduino / Programming Questions / How use a hexa as a mask on: September 19, 2013, 04:38:41 pm
Dear All,

I am trying to increment a hexa

Code:
// THIS WILL INCREMENT THE MASK
#define EPROM_INC 0x0100

#define EPROM_LAR 0x0008
byte result;

// THIS IS A MASK
byte mask = 0x0000;

mask = mask+EPROM_INC; // MASK SHOULD BE 0x0100

result = mask+EPROM_LAR; // RESULT SHOULD 0x0108 but apparently the operation does not works as I expected

Following my example, maks should be egal to 0x0100?

and "result" should be 0x0108

How can I use a mask to change the value of a hexa?
How could you correct me?

many thnak

Cheers
156  Using Arduino / Programming Questions / Re: How to return a char from a function on: September 19, 2013, 03:50:42 pm
Ok this clear. I was hesitating to so like this, but I am bit surpise we can not return a char while we can do with a bit. It a point I do not undertand, but let change regarding to your example.

I am going to try and test

Cheers
157  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 19, 2013, 03:47:46 pm
Par contre, je suis surpis d'un truc

Code:
#define EPROM_INC 0x0100
byte mask = 0x1100;

mask = mask+EPROM_INC;


mask devrait être egal à
Quote
0x1200
non?

158  Using Arduino / Programming Questions / Re: How to return a char from a function on: September 19, 2013, 03:06:55 pm
Dear all and Tom

Thank for your suggeston but I do not understand your change.
in my example
Code:
char readEEPROM(int deviceaddress, int eeaddress)
{
 
  int i=0;
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
 
  byte val = EEPROM.read(eeaddress);
  int va = (int)val;
 
  char data[va+1];
 
  Wire.requestFrom(deviceaddress, va);
 
  while(Wire.available()){
   
    data[i] = Wire.read();
    i++;
  }
  data[i]='\0';
 
  Serial.println(data);
  //return datas;

}
Serial.println(data); display exactely what I need, and "data" is a char. So my idea was to return what Serial display
159  Using Arduino / Programming Questions / How to return a char from a function on: September 19, 2013, 01:47:45 pm
Dear All, Good day !  smiley

I have found a function and I am trying to adapt it

Here is the function and I explain in capital letter
Code:
char lat[15];
lat = readEEPROM(rom,0x0008);

char readEEPROM(int deviceaddress, int eeaddress)
{
 
  int i=0;
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
 
// HERE IT READ THE ARDUINO EEPROM BECAUSE I SAVE THE LENTH OF THE STRING HERE. NO WORRIES ABOUT THIS.
  byte val = EEPROM.read(eeaddress);
  int va = (int)val;
 
  char data[va+1];
 
// HERE IT REQUEST THE DATA FOR THE LENTH OF va
  Wire.requestFrom(deviceaddress, va);
 
//  HERE, AS LONG AS WIRE IS AVAILABLE, IT "FILLUP" THE data VAR. AT THE END WE WILL HAVE THE LONGITUDE, LATITUDE ETC...
  while(Wire.available()){
   
    data[i] = Wire.read();
    i++;
  }
// I TERMINATE WITH \0
  data[i]='\0';
 
 // Serial.println(data);
// I RETURN THE VALUR OF DATA TO HAVE IT IN lat VARIABLE
 return datas;

}

The problem is , my terminal return me
Quote
incompatible type of assignement of 'char' to 'char[15]'

I ask me self if it's because of the lenth of data, which is aleatoiry. By I try to define a lenth of 15, and the problem is the same.
160  Using Arduino / Programming Questions / Re: Can we parse into a XML file with Arduino on: September 19, 2013, 01:15:32 pm
Quote
You seem to have a misunderstanding of what parse means
You are right. Sorry. I do not want to parse, but create an XML format
Quote
In the above code, I know there is an issue. the functon readEEPROM() return a char
I will not continue this Post with this issue. I am going to create a new Post for this problem.

Quote
You simply need to write the appropriate start and end tags manually
Ok then there is no library or some things else.

So I am still a bit worries because coords has a lenth of 87 (char coords[87]smiley-wink
If I want to add to coords 5 set of coordinate, I have to extent the length to 435
If I have to add the xml format, I have to extent the length to xxx. It's a lot, no? It will take a lot of memory?
My sketch code have 25000, and the maximum of arduino is 32000.

No my question, is better to use the function
Code:
if(inet.httpPOST(host, port, path, coords, "Result", 0)){}else{}
for each set of cordinate. The each minute it collect a GPS it will send it.

Or it better to have a large lenth of coords, and send a 5 sets ina XML format?


161  Using Arduino / Programming Questions / Can we parse into a XML file with Arduino on: September 19, 2013, 03:51:13 am
Dear All,

Acrually, I am collecting data and saving it into an EEPROM.
The data is a set of pisition
  • Course
  • Longitude
  • Latitude
  • Altitude
  • Time
  • Spped
  • Stat

I have not test this code yet, but I will past it

Each minutes the a set of GPS coordinate is save into the EEPROM
Each 5 minutes, the 5 sets of coordinate is set to a sevrer . It should send all sets once, this is to avoid 5 connections.
And I am looking how the send the 5 sets in once


Before, how it works,
the void GetGPS() funtion is collection the GPS cordinate each minutes. And exh minute the mask in incremented of 0x0100 (the 1 is representing the inute) . So, at the fift minute, the mask variable is egual at 0x0500;

Code:
byte mask = 0x0000;
define EPROM_INC x0100 // THis is the incrementation

char stat[2];
char lon[15];
char lat[15];
char alt[15];
char time[15];
char vel[15];
char coords[74];
char courseid[6];

// THIS IS CALL EACH 5 MIN:
void SendDATA(void){

  Serial.println(F("Data is going to be collected form EEPROM"));
  // Read and get the pos record from the EEPROM

  // HERE I AM MAKING A LOOP STARTING FROM 0x000 and going to the "mask" VALUE. USUAL , IT SHOULD BE 0x0500
  for(byte xmask = 0x0000; xmask <= mask ; xmask = xmask + EPROM_INC){
    courseid = readEEPROM(rom, xmask+EPROM_COU); // READ THE EPROM AT 0x0008, then READ THE EPROM AT 0x0108, then READ THE EERPOM at 0x0208, etc
    lon = readEEPROM(rom, xmask+EPROM_LON); // READ THE EPROM AT 0x0018, then READ THE EPROM AT 0x0118, then READ THE EERPOM at 0x0218, etc
    lat = readEEPROM(rom, xmask+EPROM_LAT); // READ THE EPROM AT 0x0028, then READ THE EPROM AT 0x0128, then READ THE EERPOM at 0x0228, etc
    alt = readEEPROM(rom, xmask+EPROM_ALT); // READ THE EPROM AT 0x0038, then READ THE EPROM AT 0x0138, then READ THE EERPOM at 0x0238, etc
    time = readEEPROM(rom, xmask+EPROM_TIM); // READ THE EPROM AT 0x0048, then READ THE EPROM AT 0x0148, then READ THE EERPOM at 0x0248, etc
    vel = readEEPROM(rom, xmask+EPROM_VEL); // READ THE EPROM AT 0x0058, then READ THE EPROM AT 0x0158, then READ THE EERPOM at 0x0258, etc
    sta = readEEPROM(rom, xmask+EPROM_STA); // READ THE EPROM AT 0x0068, then READ THE EPROM AT 0x0168, then READ THE EERPOM at 0x0268, etc


 sprintf(coords, "g=%s,%s,%s,%s,%s,%s,%s",course_id,lon,lat,alt,tim,vel,_stat);


    Serial.println(F("\n"));
   
    // HERE I WOULD LIKE TO PARSE THE VARIABLE coords INTO XML FORMAT, AND EACH NEW LOOP, IT ADD TO THE END OF XML THE NEW VALUE


   // THIS SEND THE FUTURE XML FORMAT TO THE REMOTE SERVER. TJHE FORTH PARAMETER IS THE DATA TO SEND
if(inet.httpPOST(host, port, path, coords, "Result", 0)){
         // Check if there is collected data then send
         #ifdef DEBUG
           Serial.println(F("Data sent"));
         #endif
         //Read EEPROM
      }else{
         #ifdef DEBUG
           Serial.println(F("Data not sent"));
           // Save in EEPROM
         #endif
         #ifdef LED 
           blinkLed(redGPRS,5, MSEC);
         #endif
         
      }
  }

In the above code, I know there is an issue. the functon readEEPROM() return a char and I do not know to do in the way that for example, vel take the value of the return char value
Code:
vel = readEEPROM(rom, xmask+EPROM_VEL)
May be should I use sprintf, as I did with coords?

But for now my main worries is how to parse into XML file to send once, to a remote server, the 5 sets of coordinates.

I hope I provided you enough information and it clear for you.
..... and many thank for your help. Feel you free to ask me aditionnal information

Cheers
162  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 17, 2013, 05:18:45 pm
D'acord, je vous remercie pour ces informations.
Quote
J'en pense que tu t'égares.
Probablement  smiley je nage un peu, mais je commence à m'orienter  smiley

Quote
Lorsque tu écris un chiffre de cette manière 101 c'est du décimal
Lorsque tu écris un chiffre de cette manière 0x101 c'est de l'hexadécimal
Lorsque tu écris un chiffre de cette manière B101 c'est du binaire
En effet, je n'avais pas bien compris, désolé.
Quote
utiliser une chaine de caractères pour stocker une valeur numérique n'a pas de sen

En fait, la librairie que j'utilise, retourne les positions dans une variable de type char. Mais ta remarque sur l'espace qu'utilise un char m'intrique. Mais vu mon niveau, je vais rester avec des char. Et uen fois que j'aurais la métrise, je regarderai ensuite.

Mais sur ce plan, je vais donc garder le meme résonnement que j'ai décris dans mon précédent post, mais je vais informer les positions en hexas
Quote
#define EPROM_COU 0x0001
#define EPROM_LON 0x0008
...
#define EPROM_LAT 0x0018
Quote
position 0xC01 pour COU la 12eme minute
position 0xC08 pour LON la 12eme minute
position 0xC18 pour LAT la 12eme minute

Quote
char cou1[6] = "100000";
char cou2[6] = "050000";

char cou3[6] = cou1 + cou2;
Je ne ferai jamais ca. je stoke des infromations, je n'ai pas besoin de faire des calculs etc


Et donc pour incrémenté les positions en fonction des minutes, je pense que ceci est valable, selon un précédent post

Code:
#define EPROM_COU 0x0001
byte increment = 0x0100;
byte result;

result = EPROM_COU + increment;
Serial.println(result); // 0x0101;

ou encore
Code:
#define EPROM_TEST 0x0901
byte increment = 0x0100;
byte result;

result = EPROM_COU + increment;
Serial.println(result); // 0x0A01;

Merci encore pour vos lumières
163  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 17, 2013, 02:41:51 pm
En fait je cherche a faire la chose suivante, pour etre plus clair sur ma prochaine questionnement

J'ai des variable de type char

char cou[6]
qui peut contenir une valeur entre 0 et 999999

char lon[15]
qui peut contenir un nombre de 14 chiffre  : expl: 45.123540300000

char lat[15]
qui peut contenir un nombre de 15 chiffre  : expl: 235.12354030000

char alt[15]
qui peut contenir un nombre de 15 chiffre  : expl: 845.12000000000
( ca eut avoir pas de sens, mais je préfère garder 15 unité, pour le moment, meme si deux apres la virgule suffit)

char tim[15]
qui peut contenir un chiffre a 14 chiffre
20130936293040

char vel[15]
qui peut contenir un nombre a 15 chiffre : expl : 2.9999999999999

char sta[1] doit aussi, comme pour les autre ajouté 1 pour le \0 ?(char sta[2])
qui contient un chiffre a à nombre, expl : 3

J'aimerais prévoir un espace de mon EEPROM pour stoské ces chiifre, mais je ne sais pas encore comment prévoir cette espace.

Par exemple
pour pos, ce chiffre de 1 à 999999, sera enregistré à la position une
Code:
#define EPROM_COU 1
mais pour les suivante, comment je peux savoir la position qu'il faut prévoir, juste après l'enregistrement de cou, à la position1

Etant donné que 999999 à 6 "untié", je pense que la position pour lon sera 8
Code:
#define EPROM_LON 8

Et etant donné que LAT peut avoir 15 caravtere LAT sera à 24
Code:
#define EPROM_LAT 24

Mon résonnement est juste? En fait j'ai un mega doute, parce que 24 en exa c'est 18, car j'oublie de conter A,B,C,D,E,F après 9

Donc si je corrige
Code:
#define EPROM_LAT 18

Et si je continue pour alt en additonant 15, ca serait pas 40 (en fair c'est 24+15=39, mais je compte 40), ca ferait 28 en hexa.

C'est bien ca non?

Si je veux incrémenter de 100, c'est que par la suite je veux enregistrer des positions tous les minutes. Donc pour plus facilement me retrouver (mais encore a déterminer), je pensais enregistrer au centaine pour la premiere minuet, au 200 pour la deuxiem minute comme pare exemple

Quote
position 101 pour COU la premiere minute
position 108 pour LON la premiere minute
position 118 pour LAT la premiere minute
etc..
Quote
position 201 pour COU la deuxime minute
position 208 pour LON la deuxieme minute
position 218 pour LAT la deuxime minute
etc..
Quote
position A01 pour COU la 10eme minute
position A08 pour LON la 10eme minute
position A18 pour LAT la 10eme minute
etc..
Quote
position C01 pour COU la 12eme minute
position C08 pour LON la 12eme minute
position C18 pour LAT la 12eme minute
etc..
Quote
position F01 pour COU la 15eme minute
position F08 pour LON la 15eme minute
position F18 pour LAT la 15eme minute
etc..

Voilà l'idée.

Qu'en pensez vous?
164  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 16, 2013, 08:28:51 am
Donc je peux aussi remplacer ceci
Code:
#define EPROM_POS 0x0001
#define EPROM_LON 0x0008
#define EPROM_LAT 0x0024
#define EPROM_ALT 0x0040
#define EPROM_TIM 0x0056
#define EPROM_VEL 0x0072
#define EPROM_STA 0x0088
par un truc du genre
Code:
#define EPROM_POS 100
#define EPROM_LON 106
#define EPROM_LAT 132
#define EPROM_ALT 148
#define EPROM_TIM 164
#define EPROM_VEL 180
#define EPROM_STA 196
Ca serait en effet, plus simple pour moi
165  Using Arduino / Programming Questions / Re: How can I get the right value (LAC,MNC,MCC,cellid) on: September 16, 2013, 08:25:38 am
Dear Paul,

But it's what I did
Code:
int SIMCOM900::readCellData(int &mcc, int &mnc, long &lac, long &cellid)
 
 
  if (getStatus()==IDLE)
    return 0;
   
 
 
   //_tf.setTimeout(_GSM_DATA_TOUT_);
   //_cell.flush();
  SimpleWriteln(F("AT+QENG=1,0"));
  SimpleWriteln(F("AT+QENG?"));
  if(gsm.WaitResp(5000, 50, "+QENG")!=RX_FINISHED_STR_NOT_RECV)
    return 0;

  //mcc=_tf.getValue(); // The first one is 0
  mcc=_cell.read();
  //mcc=_tf.getValue();
  mcc=_cell.read();
  //mnc=_tf.getValue();
  mnc=_cell.read();
  //lac=_tf.getValue();
  lac=_cell.read();
  //cellid=_tf.getValue();
  cellid=_cell.read();
 
// THE BELOW SERIAL.PRINTLN DISPLAY -1
  Serial.println(mcc);
  Serial.println(mnc);
  Serial.println(lac);
  Serial.println(cellid);
 
  gsm.WaitResp(5000, 50, "+OK");
  SimpleWriteln(F("AT+QENG=1,0"));
  gsm.WaitResp(5000, 50, "+OK");
 
 
  return 1;
}
Pages: 1 ... 9 10 [11] 12 13 ... 33