Hello,
I am currently using the XBee-Arduino library for a program I’m trying to develop. I have to admit that the limited number of errors shown directly in the Arduino IDE is quite annoying, but that’s not the goal of my post.
In fact, when compiling the following program (listed below) I get the infamous “undefined reference to `__cxa_pure_virtual’” error. The full exact error the following:
hardware/libraries/XBee-Arduino/XBee.o: In function `ZBTxStatusResponse::isSuccess()’:
/home/noxon/softs/arduino-0016/hardware/libraries/libXBee/XBee.cpp:125: undefined reference to `__cxa_pure_virtual’
Couldn’t determine program size: avr-size: ‘/tmp/build4375060936986498125.tmp/ModulesBordel.hex’: No such file
By the way, I am using Arduino 0016 which was released just a week ago.
I am really pulling out my hair on this one some any help is greatly appreciated.
Thanks in advance!
P.S.: how can I compile my code my-self (with the libraries etc.) instead of using the Arduino IDE which is quite challenging for me (I’m used to Eclipse…)?
Here’s my “ModulesBordel.pde” code:
#include <XBee.h>
#include <avr/sleep.h>
#include <inttypes.h>
#define SLEEPTIMER 3// définition des pins
const int ledInternal = 13;
const int luxPin = 1;
const int tempPin = 2;
const int supPin1 = 3;
const int supPin2 = 4;
// définition des valeurs
int luxVal = 0;
int tempVal = 0;
int supVal1 = 0;
int supVal2 = 0;// variable bool pour endormir
bool isAsleep = false;
// variable int permettant de compter le nombre de boucles dans loop()
int count = 0;// prototypes
void pwm();
void prepareSleepMode();
void wakeUp();
void sleepMode();
const int statusLed = 13; // led interne au microcontrolleur
const int errorLed = 0; // led externe.XBee xbee = XBee();
XBeeAddress64 xbAddr = XBeeAddress64(0x0013a200, 0x4008ebef);
uint8_t rxOption = 0;
uint8_t rxData = {0,0};
uint8_t txOption = 0;
uint8_t txData = {0,0};XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
ModemStatusResponse msr = ModemStatusResponse();ZBTxRequest tx = ZBTxRequest(xbAddr, txData, sizeof(txData));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();void setup() {
xbee.begin(9600);
Serial.begin(9600);
attachInterrupt(1, wakeUp, LOW);
pinMode(luxPin, INPUT);
pinMode(tempPin, INPUT);
pinMode(supPin1, INPUT);
pinMode(supPin2, INPUT);
digitalWrite(ledInternal, HIGH);
}void loop() {
if (isAsleep)
sleepMode();
luxVal = 0;
tempVal = 0;
supVal1 = 0;
supVal2 = 0;
luxVal += analogRead(luxPin);
luxVal /= 2;
tempVal += analogRead(tempPin);
tempVal /= 2;
supVal1 += analogRead(supPin1);
supVal1 /= 2;
supVal2 += analogRead(supPin2);
supVal2 /= 2;if (count >= SLEEPTIMER) {
Serial.print("luxVal = "); Serial.println(luxVal);
Serial.print("tempVal = "); Serial.println(tempVal);
Serial.print("supVal1 = "); Serial.println(supVal1);
Serial.print("supVal2 = "); Serial.println(supVal2);
Serial.println(“Going to sleep…”);
delay(100);
count = 0;
prepareSleepMode();
}
count++;
if(!isAsleep) delay(333);
}void readXBee() {
xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
xbee.getResponse().getZBRxResponse(rx);
if (rx.getOption() == ZB_PACKET_ACKNOWLEDGED) {
flash(statusLed, 1, 10);
} else {
flash(errorLed, 2, 20);
}
rxData[0] = rx.getData(0); rxData[1] = rx.getData(1);
} else if (xbee.getResponse().getApiId() == MODEM_STATUS_RESPONSE) {
xbee.getResponse().getModemStatusResponse(msr);
if (msr.getStatus() == ASSOCIATED) {
flash(statusLed, 10, 10);
} else if (msr.getStatus() == DISASSOCIATED) {
flash(errorLed, 10, 10);
} else {
flash(statusLed, 5, 10);
}
} else {
flash(errorLed, 1, 25);
}
}
}void sendXB() {
xbee.send(tx);
if (xbee.readPacket(500)) {
if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
xbee.getResponse().getZBTxStatusResponse(txStatus);
if (txStatus.getDeliveryStatus() == SUCCESS) {
flash(statusLed, 5, 50);
} else {
flash(errorLed, 3, 500);
}
}
} else {
flash(errorLed, 2, 50);
}
}void sendBroadcast() {
XBeeAddress64 bcAddr = XBeeAddress64(0x0, 0xfff);
tx = ZBTxRequest(bcAddr, txData, sizeof(txData));
sendXB();
tx = ZBTxRequest(xbAddr, txData, sizeof(txData));
}void setXBAddr(uint32_t msb, uint32_t lsb) {
xbAddr.setMsb(msb);
xbAddr.setLsb(lsb);
}void setTxData(uint8_t newdata[2]) {
txData[0] = newdata[0];
txData[1] = newdata[1];
}uint8_t* getRxdata() {
return rxData;
}void initMPXBCnx() {
}
void prepareSleepMode() {
isAsleep = true;
}void wakeUp() {
digitalWrite(ledInternal, HIGH);
}void sleepMode() {
delay(20);
flash(13,4,100);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachInterrupt(1, wakeUp, LOW);
sleep_mode();
sleep_disable();
isAsleep=false;
detachInterrupt(0);
Serial.println(“Woke up!”);
}void pwm(int pin, int start, int stop) {
int val;
if (start < stop) {
for (val=start; val < stop; val+=5) {
analogWrite(pin, val);
delay(25);
}
} else {
for (val=start; val > stop; val-=5) {
analogWrite(pin, val);
delay(25);
}
}
}void flash(int led, int times, int wait) {
int it;
bool state=true;
for (it=times*2; it > 0; it–) {
digitalWrite(led, (state)?HIGH:LOW);
state = !state;
}
}