Почему инструкция задержки вызывает ошибку компилятора? - PullRequest
0 голосов
/ 08 июля 2019

Компилятор выдает ошибку, когда я добавил delay(timer) в код, таймер - это целое число const, определенное в начале кода.

Когда я закомментирую строку задержки, компилятор завершится успешно.

4-я строка снизу

// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library 
#include <SPI.h> 

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

const int BLUE = 3;     // the number of the pushbutton pin
const int GREEN = 4;      // the number of the LED pin
const int RED = 5;      // the number of the LED pin
const int thisPin = 4;
const int timer = 100;


// the setup function runs once when you press reset or power the board
void setup() {
  // Initialize ASK Object
  rf_driver.init();
  Serial.begin(9600);
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    int mesg = 0;
    // Set buffer to size of expected message
    uint8_t buf[8];
    uint8_t buflen = sizeof(buf);
    if (rf_driver.recv(buf, &buflen)) {
      // Message received with valid checksum
      Serial.print("Message Received: ");
      Serial.println((char*)buf);     
      mesg = 1;
    }
    if (mesg == 1) {
      mesg = 0;
      digitalWrite(thisPin, HIGH);
      //delay(timer);
      digitalWrite(thisPin, LOW);
    }
}

Ниже приведено сообщение об ошибке:

C:\Users\Swee-Chuan Khoo\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp: In member function 'setModeIdle.constprop':

C:\Users\Swee-Chuan Khoo\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:421:1: internal compiler error: Segmentation fault

 }

 ^

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Nano.

1 Ответ

0 голосов
/ 10 июля 2019

Понизьте ядро ​​AVR до 1.6.21, как предложено Juraj.Теперь все работает правильно.

Теперь я могу продолжить проект.

Спасибо всем за помощь, datafiddler, Juraj и MR

...