LOCODUINO

Forum de discussion
Dépôt GIT Locoduino
Flux RSS

samedi 24 octobre 2020

57 visiteurs en ce moment

Bibliothèque DCCpp

Encore un DCC++ ? Mais à quoi ça sert ?

. Par : Thierry

Pourquoi une bibliothèque ? Nous sommes devant le cas typique d’un projet dont une bonne partie du code doit pouvoir être ré-utilisée dans d’autres projets. C’est le but d’une bibliothèque, et c’est ce que j’ai décidé de faire après avoir vu tout le monde ici s’en servir, et l’avoir moi-même utilisé dans au moins deux projets différents : Bibliothèque (...)

Retourner à l'article

Vous répondez à :

Bibliothèque DCCpp 17 février 16:59, par CLB89

Bonjour
J’ai toujours beaucoup de problèmes dans la mise en oeuvre de DCCpp. Je suis passé à une connexion Ethernet. Mon croquis est le suivant :

  1. /*************************************************************
  2. project: <Dc/Dcc Controller>
  3. author: <Thierry PARIS>
  4. description: <Dcc Ethernet Controller sample>
  5. *************************************************************/
  6.  
  7. #include "DCCpp.h"
  8.  
  9. #if !defined(USE_TEXTCOMMAND) || !defined(USE_ETHERNET)
  10. #error To be able to compile this sample,the lines #define USE_TEXTCOMMAND and #define USE_ETHERNET must be uncommented in DCCpp.h
  11. #endif
  12.  
  13. // the media access control (ethernet hardware) address for the shield:
  14. uint8_t mac[] = { 0xA8, 0x61, 0x0A, 0xAE, 0x76, 0xB6 };
  15. //the IP address for the shield:
  16. uint8_t ip[] = { 192, 168, 1, 14 };
  17.  
  18. EthernetServer DCCPP_INTERFACE(2560); // Create and instance of an EthernetServer
  19.  
  20. void setup()
  21. {
  22. pinMode(53, OUTPUT);
  23. digitalWrite(53, HIGH);
  24. pinMode(4, OUTPUT);
  25. digitalWrite(4, HIGH);
  26.  
  27. Serial.begin(9600);
  28.  
  29. DCCpp::begin();
  30. // Configuration for my LMD18200. See the page 'Configuration lines' in the documentation for other samples.
  31. // DCCpp::beginMain(UNDEFINED_PIN, DCC_SIGNAL_PIN_MAIN, 3, A0);
  32. DCCpp::beginEthernet(mac, ip, EthernetProtocol::TCP);
  33. Serial.print("DCCpp démarre et Internet est supposé lancé");
  34. Serial.println();
  35. }
  36.  
  37. void loop()
  38. {
  39. DCCpp::loop();
  40. }

Je reçois le message suivant à la compilation :

Arduino : 1.8.13 Hourly Build 2020/02/14 03:33 (Windows 10), Carte : "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:30:6: error: 'Output' has not been declared

void Output::begin(int id, int pin, int iFlag) {

     ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: In function 'void begin(int, int, int)':

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:37:6: error: 'firstOutput' was not declared in this scope

 if (firstOutput == NULL) {

     ^~~~~~~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:38:17: error: invalid use of 'this' in non-member function

  firstOutput = this;

                ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:40:12: error: 'get' was not declared in this scope

 else if ((get(id)) == NULL) {

           ^~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:40:12: note: suggested alternative: 'gets'

 else if ((get(id)) == NULL) {

           ^~~

           gets

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:41:3: error: 'Output' was not declared in this scope

  Output *tt = firstOutput;

  ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:41:3: note: suggested alternative: 'Outputs_h'

  Output *tt = firstOutput;

  ^~~~~~

  Outputs_h

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:41:11: error: 'tt' was not declared in this scope

  Output *tt = firstOutput;

          ^~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:44:20: error: invalid use of 'this' in non-member function

  tt->nextOutput = this;

                   ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:48:2: error: invalid use of 'this' in non-member function

 this->set(id, pin, iFlag);

 ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: At global scope:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:60:6: error: 'Output' has not been declared

void Output::set(int id, int pin, int iFlag) {

     ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: In function 'void set(int, int, int)':

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:61:2: error: invalid use of 'this' in non-member function

 this->data.id = id;

 ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:62:2: error: invalid use of 'this' in non-member function

 this->data.pin = pin;

 ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:63:2: error: invalid use of 'this' in non-member function

 this->data.iFlag = iFlag;

 ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:64:2: error: invalid use of 'this' in non-member function

 this->data.oStatus = 0;

 ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:67:2: error: invalid use of 'this' in non-member function

 this->data.oStatus = bitRead(this->data.iFlag, 1) ? bitRead(this->data.iFlag, 2) : 0;

 ^~~~

In file included from C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:9:0:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:67:31: error: invalid use of 'this' in non-member function

 this->data.oStatus = bitRead(this->data.iFlag, 1) ? bitRead(this->data.iFlag, 2) : 0;

                              ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:111:32: note: in definition of macro 'bitRead'

#define bitRead(value, bit) (((value) >> (bit)) & 0x01)

                               ^~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:67:62: error: invalid use of 'this' in non-member function

 this->data.oStatus = bitRead(this->data.iFlag, 1) ? bitRead(this->data.iFlag, 2) : 0;

                                                             ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:111:32: note: in definition of macro 'bitRead'

#define bitRead(value, bit) (((value) >> (bit)) & 0x01)

                               ^~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:71:15: error: invalid use of 'this' in non-member function

 digitalWrite(this->data.pin, this->data.oStatus ^ bitRead(this->data.iFlag, 0));

              ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:71:31: error: invalid use of 'this' in non-member function

 digitalWrite(this->data.pin, this->data.oStatus ^ bitRead(this->data.iFlag, 0));

                              ^~~~

In file included from C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:9:0:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:71:60: error: invalid use of 'this' in non-member function

 digitalWrite(this->data.pin, this->data.oStatus ^ bitRead(this->data.iFlag, 0));

                                                           ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:111:32: note: in definition of macro 'bitRead'

#define bitRead(value, bit) (((value) >> (bit)) & 0x01)

                               ^~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:75:10: error: invalid use of 'this' in non-member function

 pinMode(this->data.pin, OUTPUT);

         ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: At global scope:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:80:6: error: 'Output' has not been declared

void Output::activate(int s){

     ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: In function 'void activate(int)':

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:81:3: error: 'data' was not declared in this scope

  data.oStatus=(s>0);                                               // if s>0, set status to active, else inactive

  ^~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:81:3: note: suggested alternative: 'atan'

  data.oStatus=(s>0);                                               // if s>0, set status to active, else inactive

  ^~~~

  atan

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: At global scope:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:107:1: error: 'Output' does not name a type; did you mean 'Outputs_h'?

Output* Output::get(int n){

^~~~~~

Outputs_h

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:114:6: error: 'Output' has not been declared

void Output::remove(int n){

     ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: In function 'void remove(int)':

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:115:3: error: 'Output' was not declared in this scope

  Output *tt,*pp;

  ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:115:3: note: suggested alternative: 'Outputs_h'

  Output *tt,*pp;

  ^~~~~~

  Outputs_h

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:115:11: error: 'tt' was not declared in this scope

  Output *tt,*pp;

          ^~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:115:15: error: 'pp' was not declared in this scope

  Output *tt,*pp;

              ^~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:117:10: error: 'firstOutput' was not declared in this scope

  for(tt=firstOutput, pp = NULL;tt!=NULL && tt->data.id!=n;pp=tt,tt=tt->nextOutput);

         ^~~~~~~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:129:10: error: 'firstOutput' was not declared in this scope

  if(tt==firstOutput)

         ^~~~~~~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: At global scope:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:146:5: error: 'Output' has not been declared

int Output::count() {

    ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: In function 'int count()':

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:148:2: error: 'Output' was not declared in this scope

 Output *tt;

 ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:148:2: note: suggested alternative: 'Outputs_h'

 Output *tt;

 ^~~~~~

 Outputs_h

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:148:10: error: 'tt' was not declared in this scope

 Output *tt;

         ^~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:149:12: error: 'firstOutput' was not declared in this scope

 for (tt = firstOutput; tt != NULL; tt = tt->nextOutput)

           ^~~~~~~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: At global scope:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:220:6: error: 'Output' has not been declared

void Output::parse(char *c){

     ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: In function 'void parse(char*)':

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:222:3: error: 'Output' was not declared in this scope

  Output *t;

  ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:222:3: note: suggested alternative: 'Outputs_h'

  Output *t;

  ^~~~~~

  Outputs_h

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:222:11: error: 't' was not declared in this scope

  Output *t;

          ^

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:227:9: error: 'get' was not declared in this scope

      t=get(n);

        ^~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:227:9: note: suggested alternative: 'set'

      t=get(n);

        ^~~

        set

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:240:7: error: 'create' was not declared in this scope

      create(n,s,m);

      ^~~~~~

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:240:7: note: suggested alternative: 'rename'

      create(n,s,m);

      ^~~~~~

      rename

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp: At global scope:

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:257:1: error: 'Output' does not name a type; did you mean 'Outputs_h'?

Output *Output::create(int id, int pin, int iFlag){

^~~~~~

Outputs_h

C:\Users\claud\OneDrive\Documents\Arduino\libraries\DCCpp\src\Outputs.cpp:312:1: error: 'Output' does not name a type; did you mean 'Outputs_h'?

Output *Output::firstOutput=NULL;

^~~~~~

Outputs_h

exit status 1
Erreur de compilation pour la carte Arduino Mega or Mega 2560

Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.

J’ai sorti "les résultats détaillés de la compilation", mais cela 39 KO de texte ! Je peux les rendre disponibles si nécessaire.
Ma sélection DCCpp.h est la suivante :

  1. // Inclusion area
  2. //
  3.  
  4. #define USE_TURNOUT
  5. //#define USE_EEPROM
  6. //#define USE_OUTPUT
  7. #define USE_SENSOR
  8. #define USE_TEXTCOMMAND
  9. //#define USE_ETHERNET_WIZNET_5100
  10. #define USE_ETHERNET_WIZNET_5500
  11. //#define USE_ETHERNET_WIZNET_5200
  12. //#define USE_ETHERNET_ENC28J60»

Merci par avance de votre assistance
Claude

Qui êtes-vous ?
Votre message

Pour créer des paragraphes, laissez simplement des lignes vides.

Lien hypertexte

(Si votre message se réfère à un article publié sur le Web, ou à une page fournissant plus d’informations, vous pouvez indiquer ci-après le titre de la page et son adresse.)

93 Messages

Rubrique Bibliothèques

La bibliothèque Servo

Bibliothèque SoftWare Serial

Bibliothèque Serial

Bibliothèque EEPROM

Bibliothèque Wire : I2C

Bibliothèque LCD

La bibliothèque ScheduleTable

Bibliothèque MemoryUsage

Bibliothèque EEPROMextent

La bibliothèque SlowMotionServo

Bibliothèque Commanders

Bibliothèque DCCpp

Bibliothèque DcDccNanoController

La bibliothèque ACAN (1)

La bibliothèque ACAN (2)

Bibliothèque LightEffect

Bibliothèque Accessories (1)

Bibliothèque Accessories (2)

Un décodeur d’accessoires universel (1)

Un décodeur d’accessoires universel (2)

Un décodeur d’accessoires universel (3)

Bibliothèque LcdUi (1)

Bibliothèque LcdUi (2)

Les derniers articles

Bibliothèque LightEffect


Christian

La bibliothèque ACAN (2)


Jean-Luc

La bibliothèque ACAN (1)


Jean-Luc

La bibliothèque SlowMotionServo


Jean-Luc

Bibliothèque DCCpp


Thierry

Bibliothèque DcDccNanoController


Thierry

Bibliothèque LcdUi (2)


Thierry

Bibliothèque LcdUi (1)


Thierry

Bibliothèque Accessories (2)


Thierry

Bibliothèque Accessories (1)


Thierry

Les articles les plus lus

Bibliothèque Wire : I2C

Bibliothèque MemoryUsage

La bibliothèque Servo

Bibliothèque LightEffect

Bibliothèque SoftWare Serial

Bibliothèque DcDccNanoController

Bibliothèque DCCpp

Un décodeur d’accessoires universel (1)

La bibliothèque SlowMotionServo

Bibliothèque Commanders