Bonjour, j'ai créé un petit système à base d'arduino pour commandé ma climatisation à distance.
En gros j'ai :
- un raspberry avec Domoticz installé.
- un émetteur RF 433 sur le RPI
- un Arduino nano avec récepteur RF + led IR

Grâce à l'émetteur j'envoi une commande type "lgChaud18fast"
le récepteur capte l'info et envoi la trame infra rouge correspondant à l'ordre "Chauffage à 18 degrés en vitesse rapide"

Le problème étant : je veux passer la trame infra rouge qui est un tableau d'entiers entre 59 et 69 valeurs, à la fonction qui va émettre la trame infra rouge.

Voilà le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 
 
#include <IRremote.h>
#include <avr/pgmspace.h>
#include <VirtualWire.h>
 
 
/**
 * Module de reception radio pour envoi d'ordre infra rouge à climatisation LG
 */
 
 
IRsend irsend;
int khz=38;
const unsigned int PROGMEM tlgChaud22fast[] = { 444, 14876, 104, 11372, 184, 9016, 364, 1724, 232, 30844, 3208, 9880, 500, 1576, 500, 564, 476, 540, 496, 560, 472, 1596, 476, 556, 476, 556, 472, 568, 476, 560, 476, 560, 472, 556, 476, 556, 476, 556, 476, 1588, 448, 576, 496, 556, 476, 556, 476, 1588, 476, 1584, 476, 1604, 476, 556, 472, 1588, 476, 556, 476, 556, 476, 1588, 476, 1580, 496, 1588, 476, 1588, 476 };
const unsigned int PROGMEM tlgChaud18fast[] = { 3208, 9848, 476, 1600, 504, 540, 504, 544, 496, 532, 496, 1604, 476, 540, 504, 552, 476, 532, 500, 556, 476, 556, 476, 532, 496, 540, 500, 544, 504, 1596, 476, 536, 504, 552, 476, 532, 500, 532, 500, 1588, 476, 1584, 476, 536, 504, 1588, 476, 536, 504, 532, 496, 1596, 476, 532, 500, 1584, 476, 1596, 476 };
const unsigned int PROGMEM tlgSwingOn[]     = { 3232, 9832, 496, 1584, 500, 556, 476, 556, 476, 552, 476, 1612, 476, 540, 496, 560, 472, 556, 476, 556, 476, 556, 476, 556, 476, 1600, 452, 572, 500, 556, 476, 1588, 476, 1576, 500, 564, 476, 564, 476, 556, 476, 1584, 476, 556, 476, 1588, 476, 540, 496, 556, 476, 1588, 476, 564, 452, 572, 500, 1584, 476 };
const unsigned int PROGMEM tlgSwingOff[]    = { 3204, 9848, 500, 1584, 500, 556, 476, 556, 472, 556, 480, 1584, 476, 540, 500, 556, 472, 560, 472, 556, 476, 556, 476, 556, 476, 1584, 476, 560, 472, 556, 452, 1612, 500, 1584, 476, 564, 476, 540, 500, 548, 500, 564, 472, 1604, 476, 540, 500, 556, 476, 1588, 476, 1576, 476, 1612, 500, 556, 476, 1600, 476 };
const unsigned int PROGMEM tlgFroid25fast[] = { 3208, 9848, 472, 1616, 504, 532, 500, 532, 500, 528, 504, 1568, 500, 536, 504, 536, 504, 536, 504, 524, 504, 532, 500, 532, 500, 540, 500, 532, 500, 532, 500, 528, 500, 536, 504, 1568, 504, 536, 504, 1584, 476, 532, 500, 532, 500, 1576, 504, 532, 504, 532, 500, 1612, 476, 1572, 504, 1564, 500, 540, 500 };
const unsigned int PROGMEM tlgFroid25auto[] = { 3208, 9860, 532, 1592, 480, 532, 504, 532, 500, 532, 500, 1576, 500, 544, 496, 564, 452, 568, 504, 528, 504, 528, 504, 528, 504, 536, 500, 532, 500, 532, 500, 556, 476, 536, 504, 1584, 476, 536, 504, 1592, 480, 536, 500, 532, 500, 1592, 480, 532, 500, 1584, 476, 1568, 504, 1572, 504, 1588, 476, 1600, 480 };
const unsigned int PROGMEM tlgFroid26auto[] = { 3288, 9876, 500, 1596, 504, 540, 500, 536, 504, 528, 504, 1584, 480, 528, 500, 532, 500, 532, 500, 528, 504, 532, 496, 532, 500, 536, 504, 532, 500, 532, 500, 528, 504, 528, 504, 1564, 496, 532, 500, 1576, 504, 1560, 500, 540, 500, 1576, 504, 532, 508, 1584, 476, 532, 500, 532, 500, 528, 500, 532, 500 };
const unsigned int PROGMEM tlgFroid26fast[] = { 3288, 9880, 476, 1600, 504, 536, 500, 532, 504, 528, 500, 1564, 500, 536, 504, 532, 472, 568, 504, 532, 500, 532, 500, 532, 500, 536, 504, 528, 504, 528, 500, 532, 500, 536, 504, 1584, 480, 532, 504, 1596, 476, 1568, 504, 536, 500, 1572, 500, 536, 504, 528, 504, 1584, 476, 1596, 476, 1584, 476, 1604, 476 };
const unsigned int PROGMEM tlgFan[]         = { 3368, 9860, 528, 1596, 476, 536, 504, 528, 504, 528, 500, 1604, 476, 536, 504, 536, 500, 536, 496, 544, 504, 532, 500, 532, 500, 532, 500, 532, 504, 532, 500, 1596, 480, 532, 504, 528, 504, 528, 500, 1576, 496, 1568, 504, 532, 504, 532, 500, 532, 500, 528, 504, 540, 500, 1592, 476, 532, 500, 1596, 476 };
const unsigned int PROGMEM tlgFanOff[]      = { 3368, 9860, 528, 1596, 476, 536, 504, 528, 504, 528, 500, 1604, 476, 536, 504, 536, 500, 536, 496, 544, 504, 532, 500, 532, 500, 532, 500, 532, 504, 532, 500, 1596, 480, 532, 504, 528, 504, 528, 500, 1576, 496, 1568, 504, 532, 504, 532, 500, 532, 500, 528, 504, 540, 500, 1592, 476, 532, 500, 1596, 476 };
 
void setup() {
  vw_setup(2000);
  vw_set_rx_pin(2);
  vw_rx_start(); // On peut maintenant recevoir des messages
  Serial.begin(9600);
    Serial.println("go");
    Serial.print(tlgChaud18fast[0]);
    Serial.print(" ,");
    Serial.print(tlgChaud18fast[1]);
    Serial.print(" ,");
    Serial.print(tlgChaud18fast[2]);
    Serial.print(" ,");
}
void SendIR(unsigned int ordre[]) 
{
  Serial.print("trame = ");
 
for (int i = 0; i < 3; i++)
{
   Serial.print(ordre[0]);
    Serial.print(" ,");
}
Serial.println(" ,");
//  irsend.sendRaw(ordre, sizeof(ordre) / sizeof(ordre[0]), khz); //Note the approach used to automatically calculate the size of the array
}
 
void loop() {
  byte message[VW_MAX_MESSAGE_LEN];
  byte taille_message = VW_MAX_MESSAGE_LEN;
 
 vw_wait_rx();
 
  if (vw_get_message(message, &taille_message)) {
 
    if (strcmp((char*) message, "lgChaud22fast") == 0)
    {
       SendIR(tlgChaud22fast);
    }
    else if (strcmp((char*) message, "lgChaud18fast") == 0)
    {
      SendIR(tlgChaud18fast);
    }
    else if (strcmp((char*) message, "lgSwingOn") == 0)
    {
      SendIR(tlgSwingOn);
    }
    else if (strcmp((char*) message, "lgSwingOff") == 0)
    {
      SendIR(tlgSwingOff);
    }
    else if (strcmp((char*) message, "lgFroid25fast") == 0)
    {
     SendIR(tlgFroid25fast);
    }
    else if (strcmp((char*) message, "lgFroid25auto") == 0)
    {
      SendIR(tlgFroid25auto);
    }
    else if (strcmp((char*) message, "lgFroid26auto") == 0)
    { 
      SendIR(tlgFroid26auto);
    }
    else if (strcmp((char*) message, "lgFroid26fast") == 0)
    {
      SendIR(tlgFroid26fast);
    }
    else if (strcmp((char*) message, "lgFan") == 0)
    {
     SendIR(tlgFan);
    }
    else if (strcmp((char*) message, "lgFanOff") == 0)
    {
      SendIR(tlgFanOff);
    }
  }
}
Pour contrôler mes tableau dans la fonction setup j'affiche les 3 premières valeurs de la trame lgChaud18fast
qui correpond à : 3208 ,9848 ,476

Et l'affiche de nouveau dans au départ de la fonction SendIR et le résultat est : 24934 ,29811 ,25344

J'ai essayé d'utiliser un pointeur, mais je n'ai pas assez de notions en pointeurs... D'après ce que j'ai lu je devrais appeler SendIR(&tlgChaud18fast); de cette manière ( ça ne compile pas...)
et déclaré la fonction
void SendIR(const unsigned int (*ordre)[])
et appel SendIR(tlgChaud18fast);

mais j'obtient les érreurs :


recepteurv2:38: error: parameter 'ordre' includes pointer to array of unknown bound 'const unsigned int []'

void SendIR(const unsigned int (*ordre)[])

^

recepteurv2:38: error: parameter 'ordre' includes pointer to array of unknown bound 'const unsigned int []'

void SendIR(const unsigned int (*ordre)[])

^
\recepteurv2.ino: In function 'void loop()':

recepteurv2:64: error: cannot convert 'const unsigned int (*)[69]' to 'const unsigned int (*)[]' for argument '1' to 'void SendIR(const unsigned int (*)[])'

SendIR(&tlgChaud22fast);

^

recepteurv2:68: error: cannot convert 'const unsigned int (*)[59]' to 'const unsigned int (*)[]' for argument '1' to 'void SendIR(const unsigned int (*)[])'

SendIR(&tlgChaud18fast);

^

exit status 1
parameter 'ordre' includes pointer to array of unknown bound 'const unsigned int []'


Je suis perdu j'ai essayé plusieurs autre façon de programmer le pointeurs déclaré à l'initialisation de la fonction mais rien n'y fait...

Merci d'avance ! bonne journée

EDIT : Fait complètement dingue :
si je ne laisse qu'une seule condition :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
#include <IRremote.h>
#include <avr/pgmspace.h>
#include <VirtualWire.h>
 
 
/**
 * Module de reception radio pour envoi d'ordre infra rouge à climatisation LG
 */
 
 
IRsend irsend;
int khz=38;
const unsigned int PROGMEM tlgChaud22fast[] = { 444, 14876, 104, 11372, 184, 9016, 364, 1724, 232, 30844, 3208, 9880, 500, 1576, 500, 564, 476, 540, 496, 560, 472, 1596, 476, 556, 476, 556, 472, 568, 476, 560, 476, 560, 472, 556, 476, 556, 476, 556, 476, 1588, 448, 576, 496, 556, 476, 556, 476, 1588, 476, 1584, 476, 1604, 476, 556, 472, 1588, 476, 556, 476, 556, 476, 1588, 476, 1580, 496, 1588, 476, 1588, 476 };
const unsigned int PROGMEM tlgChaud18fast[] = { 3208, 9848, 476, 1600, 504, 540, 504, 544, 496, 532, 496, 1604, 476, 540, 504, 552, 476, 532, 500, 556, 476, 556, 476, 532, 496, 540, 500, 544, 504, 1596, 476, 536, 504, 552, 476, 532, 500, 532, 500, 1588, 476, 1584, 476, 536, 504, 1588, 476, 536, 504, 532, 496, 1596, 476, 532, 500, 1584, 476, 1596, 476 };
const unsigned int PROGMEM tlgSwingOn[]     = { 3232, 9832, 496, 1584, 500, 556, 476, 556, 476, 552, 476, 1612, 476, 540, 496, 560, 472, 556, 476, 556, 476, 556, 476, 556, 476, 1600, 452, 572, 500, 556, 476, 1588, 476, 1576, 500, 564, 476, 564, 476, 556, 476, 1584, 476, 556, 476, 1588, 476, 540, 496, 556, 476, 1588, 476, 564, 452, 572, 500, 1584, 476 };
const unsigned int PROGMEM tlgSwingOff[]    = { 3204, 9848, 500, 1584, 500, 556, 476, 556, 472, 556, 480, 1584, 476, 540, 500, 556, 472, 560, 472, 556, 476, 556, 476, 556, 476, 1584, 476, 560, 472, 556, 452, 1612, 500, 1584, 476, 564, 476, 540, 500, 548, 500, 564, 472, 1604, 476, 540, 500, 556, 476, 1588, 476, 1576, 476, 1612, 500, 556, 476, 1600, 476 };
const unsigned int PROGMEM tlgFroid25fast[] = { 3208, 9848, 472, 1616, 504, 532, 500, 532, 500, 528, 504, 1568, 500, 536, 504, 536, 504, 536, 504, 524, 504, 532, 500, 532, 500, 540, 500, 532, 500, 532, 500, 528, 500, 536, 504, 1568, 504, 536, 504, 1584, 476, 532, 500, 532, 500, 1576, 504, 532, 504, 532, 500, 1612, 476, 1572, 504, 1564, 500, 540, 500 };
const unsigned int PROGMEM tlgFroid25auto[] = { 3208, 9860, 532, 1592, 480, 532, 504, 532, 500, 532, 500, 1576, 500, 544, 496, 564, 452, 568, 504, 528, 504, 528, 504, 528, 504, 536, 500, 532, 500, 532, 500, 556, 476, 536, 504, 1584, 476, 536, 504, 1592, 480, 536, 500, 532, 500, 1592, 480, 532, 500, 1584, 476, 1568, 504, 1572, 504, 1588, 476, 1600, 480 };
const unsigned int PROGMEM tlgFroid26auto[] = { 3288, 9876, 500, 1596, 504, 540, 500, 536, 504, 528, 504, 1584, 480, 528, 500, 532, 500, 532, 500, 528, 504, 532, 496, 532, 500, 536, 504, 532, 500, 532, 500, 528, 504, 528, 504, 1564, 496, 532, 500, 1576, 504, 1560, 500, 540, 500, 1576, 504, 532, 508, 1584, 476, 532, 500, 532, 500, 528, 500, 532, 500 };
const unsigned int PROGMEM tlgFroid26fast[] = { 3288, 9880, 476, 1600, 504, 536, 500, 532, 504, 528, 500, 1564, 500, 536, 504, 532, 472, 568, 504, 532, 500, 532, 500, 532, 500, 536, 504, 528, 504, 528, 500, 532, 500, 536, 504, 1584, 480, 532, 504, 1596, 476, 1568, 504, 536, 500, 1572, 500, 536, 504, 528, 504, 1584, 476, 1596, 476, 1584, 476, 1604, 476 };
const unsigned int PROGMEM tlgFan[]         = { 3368, 9860, 528, 1596, 476, 536, 504, 528, 504, 528, 500, 1604, 476, 536, 504, 536, 500, 536, 496, 544, 504, 532, 500, 532, 500, 532, 500, 532, 504, 532, 500, 1596, 480, 532, 504, 528, 504, 528, 500, 1576, 496, 1568, 504, 532, 504, 532, 500, 532, 500, 528, 504, 540, 500, 1592, 476, 532, 500, 1596, 476 };
const unsigned int PROGMEM tlgFanOff[]      = { 3368, 9860, 528, 1596, 476, 536, 504, 528, 504, 528, 500, 1604, 476, 536, 504, 536, 500, 536, 496, 544, 504, 532, 500, 532, 500, 532, 500, 532, 504, 532, 500, 1596, 480, 532, 504, 528, 504, 528, 500, 1576, 496, 1568, 504, 532, 504, 532, 500, 532, 500, 528, 504, 540, 500, 1592, 476, 532, 500, 1596, 476 };
 
void setup() {
  vw_setup(2000);
  vw_set_rx_pin(2);
  vw_rx_start(); // On peut maintenant recevoir des messages
  Serial.begin(9600);
    Serial.println("go");
    Serial.print(tlgChaud18fast[0]);
Serial.print(" ,");
Serial.print(tlgChaud18fast[1]);
Serial.print(" ,");
Serial.print(tlgChaud18fast[2]);
Serial.print(" ,");
}
void SendIR(const unsigned int ordre[]) 
{
  Serial.print("trame = ");
 
for (int i = 0; i < 3; i++)
{
   Serial.print(ordre[i]);
    Serial.print(" ,");
}
//Serial.println(" ,");
//  irsend.sendRaw(ordre, sizeof(ordre) / sizeof(ordre[0]), khz); //Note the approach used to automatically calculate the size of the array
}
 
void loop() {
  byte message[VW_MAX_MESSAGE_LEN];
  byte taille_message = VW_MAX_MESSAGE_LEN;
  // N.B. La constante VW_MAX_MESSAGE_LEN est fournie par la lib VirtualWire
 
  // On attend de recevoir un message
  vw_wait_rx();
 
  if (vw_get_message(message, &taille_message)) {
    // On copie le message, qu'il soit corrompu ou non
//    if (strcmp((char*) message, "lgChaud22fast") == 0)
//    {
//      Serial.println("c22");
//          SendIR(tlgChaud22fast);
//    }
     if (strcmp((char*) message, "lgChaud18fast") == 0)
    {
      SendIR(tlgChaud18fast);
    }
//    else if (strcmp((char*) message, "lgSwingOn") == 0)
//    {
//      SendIR(tlgSwingOn);
//    }
//    else if (strcmp((char*) message, "lgSwingOff") == 0)
//    {
//      SendIR(tlgSwingOff);
//    }
//    else if (strcmp((char*) message, "lgFroid25fast") == 0)
//    {
//     SendIR(tlgFroid25fast);
//    }
//    else if (strcmp((char*) message, "lgFroid25auto") == 0)
//    {
//      SendIR(tlgFroid25auto);
//    }
//    else if (strcmp((char*) message, "lgFroid26auto") == 0)
//    { 
//      SendIR(tlgFroid26auto);
//    }
//    else if (strcmp((char*) message, "lgFroid26fast") == 0)
//    {
//      SendIR(tlgFroid26fast);
//    }
//    else if (strcmp((char*) message, "lgFan") == 0)
//    {
//     SendIR(tlgFan);
//    }
//    else if (strcmp((char*) message, "lgFanOff") == 0)
//    {
//      SendIR(tlgFanOff);
//    }
  }
}
la variable ordre me retourne les bonnes valeurs...... J'ai utilisé PROGMEM pour ne pas encombré la mémoire... un problème de stabilité ?
une fois compilé j'ai :

Le croquis utilise 3684 octets (11%) de l'espace de stockage de programmes. Le maximum est de 30720 octets.
Les variables globales utilisent 556 octets (27%) de mémoire dynamique, ce qui laisse 1492 octets pour les variables locales. Le maximum est de 2048 octets.

Donc il a de la marge pour tourner correctement..

Merci !!