Go Down

Topic: Error when compiling for atmega1284 but not atmega2560 (Read 58 times) previous topic - next topic

archimedes

I get the following error when I compile for my standalone atmega 1284 chip :

"invalid conversion from 'char*' to 'xref2u1_t {aka unsigned char*}' [-fpermissive]" (full error message below)

for the same code which worked at my Atmega 2560 board.

The related portion of the code is as follows: (and the full code is below)

Code: [Select]

static char gps_lat[20]={"\0"};
LMIC_setTxData2(1, gps_lat, sizeof(gps_lat)-1, 0);


I tried char*, unsigned char*, and other variants instead of char, but these gave some other errors.

I have superficial knowledge of c++ and just trying to make already available examples work in coherence.

full error message :

Code: [Select]


In function 'void do_send(osjob_t*)':

error: invalid conversion from 'char*' to 'xref2u1_t {aka unsigned char*}' [-fpermissive]

LMIC_setTxData2(1, gps_lat, sizeof(gps_lat)-1, 0);

                                                         ^
In file included from lmic.h:5:0,

note: initializing argument 2 of 'int LMIC_setTxData2(u1_t, xref2u1_t, u1_t, u1_t)'

 int   LMIC_setTxData2   (u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed);



full related portions of code :

Code: [Select]

#include <lmic.h>
#include <TinyGPS.h>

   String datastring="";
   String datastring1="";
   char gps_lon[20]={"\0"};
   static char gps_lat[20]={"\0"};

void do_send(osjob_t* j){
        // Prepare upstream data transmission at the next possible time.
        LMIC_setTxData2(1, gps_lat, sizeof(gps_lat)-1, 0);
    }

void getGPS () {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;         
    flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;
    // Once the GPS fixed,send the data to the server.
    datastring +=dtostrf(flat, 0, 6, gps_lat);
    datastring1 +=dtostrf(flon, 0, 6, gps_lon);
    Serial.println(strcat(strcat(gps_lon,","),gps_lat));
    strcpy(gps_lat,gps_lon);
    senddata ();
    }

void senddata(){
  while (txcompletion)
  {
    os_runloop_once();
     delay(1000);
  }
  txcompletion = true;
}


void loop() {
getGPS ();
}



I didn't include the setup intentionally beca─▒se I thought it wan't related, if necessary I can include it and other parts.

DrAzzy

Full sketch, no snippets, and links to the two libraries you're using (preferably nice github links so we can view the code easily).

What core were you using when it worked with the atmega1284?

This is not a normal compatibility problem (ex, registers that don't exist on one chip or something) - it's some difference between the cores being used, as far as I can tell - but you need to give us more info.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

archimedes

Here is the link to lmic : https://github.com/tftelkamp/arduino-lmic-v1.5/blob/master/src/lmic/lmic.h

and the tinyGPS should be this : https://github.com/mikalhart/TinyGPS/blob/master/TinyGPS.h

Here is the hardware library I used for Atmega 1284 : https://github.com/MCUdude/MightyCore

And the Atmega 2560 core is the original one that comes with Arduino IDE.

(It WORKED with Atmega 2560, not 1284)

And the full sketch :

Code: [Select]

#include <Wire.h>
#include <RTClibExtended.h>
#include <LowPower.h>
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>

int rtcpin = 5;
int gpspin = 4;

 
#define wakePin 3    //use interrupt 0 (pin 2) and run function wakeUp when pin 2 gets LOW
#define ledPin 13
//#define alarmingPin 7

volatile bool txcompletion = true; // helps send just once

static const PROGMEM u1_t NWKSKEY[16] = { 0xDB, 0x64, 0xF6, 0xCF, 0x4D, 0x5A, 0xAB, 0x96, 0xFC, 0xF5, 0xFF, 0x45, 0xF8, 0x35, 0xCF, 0xBC };
static const u1_t PROGMEM APPSKEY[16] = { 0x23, 0xB4, 0x10, 0x60, 0x8E, 0x41, 0xBE, 0x84, 0x41, 0x9B, 0x36, 0xE4, 0x69, 0xA5, 0x54, 0xD0 };
static const u4_t DEVADDR = 0x26011EEB;

void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }

RTC_DS3231 RTC;      //we are using the DS3231 RTC
TinyGPS gps;
//SoftwareSerial ss(8, 7); //Arduino RX, TX
SoftwareSerial ss(13, 12);
   String datastring="";
   String datastring1="";
   char gps_lon[20]={""};
   static char gps_lat[20]={""}; //

   const unsigned TX_INTERVAL = 0; //20 idi

static osjob_t initjob,sendjob,blinkjob;

const lmic_pinmap lmic_pins = {
    .nss = 11, //changed from 10 not to coincide int0
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 9,
    .dio = {2, 22, 23}, // changed from 6 ve 7 to open space for miso mosi
};

void do_send(osjob_t* j){
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println("OP_TXRXPEND, not sending");
    } else {
        // Prepare upstream data transmission at the next possible time.
        LMIC_setTxData2(1, gps_lat, sizeof(gps_lat)-1, 0); //gps_lat, changed with dataoutgoing
        Serial.print("data=");
        Serial.println(gps_lat);
        Serial.println("Packet queued");
        Serial.println(LMIC.freq);
        delay(15000);
    }
    }

    void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    Serial.println(ev);
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println("EV_SCAN_TIMEOUT");
            break;
        case EV_BEACON_FOUND:
            Serial.println("EV_BEACON_FOUND");
            break;
        case EV_BEACON_MISSED:
            Serial.println("EV_BEACON_MISSED");
            break;
        case EV_BEACON_TRACKED:
            Serial.println("EV_BEACON_TRACKED");
            break;
        case EV_JOINING:
            Serial.println("EV_JOINING");
            break;
        case EV_JOINED:
            Serial.println("EV_JOINED");
            break;
        case EV_RFU1:
            Serial.println("EV_RFU1");
            break;
        case EV_JOIN_FAILED:
            Serial.println("EV_JOIN_FAILED");
            break;
        case EV_REJOIN_FAILED:
            Serial.println("EV_REJOIN_FAILED");
            break;
        case EV_TXCOMPLETE:
            Serial.println("EV_TXCOMPLETE (includes waiting for RX windows)");
            txcompletion = false;
            if(LMIC.dataLen) {
                // data received in rx slot after tx
                Serial.print("Data Received: ");
                Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
                Serial.println(); //the rest of the code is a later addition
                Serial.print(F("Received "));
            Serial.print(LMIC.dataLen);
            Serial.print(F(" bytes for downlink: 0x"));
            for (int i = 0; i < LMIC.dataLen; i++) {
                if (LMIC.frame[LMIC.dataBeg + i] < 0x10) {
                    Serial.print(F("0"));
                }
                Serial.print(LMIC.frame[LMIC.dataBeg + i], HEX);
            }
            Serial.println();
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println("EV_LOST_TSYNC");
            break;
        case EV_RESET:
            Serial.println("EV_RESET");
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println("EV_RXCOMPLETE");
            break;
        case EV_LINK_DEAD:
            Serial.println("EV_LINK_DEAD");
            break;
        case EV_LINK_ALIVE:
            Serial.println("EV_LINK_ALIVE");
            break;
         default:
            Serial.println("Unknown event");
            break;
    }
}

    
void telltime()  
{
    char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    DateTime now = RTC.now();
  }


//-------------------------------------------------
void wakeUp()        // here the interrupt is handled after wakeup
{
  Serial.println("wakeup worked");
}

void getGPS () {
   bool newData = false;
   bool checkdata = true;
  unsigned long chars;
  unsigned short sentences, failed;

   for (unsigned long gpscheck = millis(); millis() - gpscheck < 600000;)
   {
    if (checkdata)
    {
   delay(1000);
   Serial.println("gps searching");
  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read(); //changed with serial
     // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
      {newData = true;
      delay(100);
      Serial.println("new data true");// for debugging
      }
    }
  }

  if (newData)
  {
    checkdata = false;
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;          
    flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;
    // Once the GPS fixed,send the data to the server.
    datastring +=dtostrf(flat, 0, 6, gps_lat);
    datastring1 +=dtostrf(flon, 0, 6, gps_lon);
    Serial.println(strcat(strcat(gps_lon,","),gps_lat));
    strcpy(gps_lat,gps_lon);
    Serial.println(gps_lat); //Print gps_lon and gps_lat;
    telltime ();
    senddata ();
  }
    }
    else
    break;
   }
}

  void alarmset() {
    RTC.alarmInterrupt(1, true);
    attachInterrupt(digitalPinToInterrupt(10), wakeUp, LOW);                       //use interrupt 0 (pin 2) and run function wakeUp when pin 2 gets LOW
    digitalWrite(gpspin, HIGH);
    delay(1000);
    //digitalWrite(rtcpin, LOW);
    byte savedPCICR = PCICR;
    PCICR = 0;  // Disable all pin change interrupts
    delay(1000);
    void hal_sleep (void);
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);   //arduino enters sleep mode here
    detachInterrupt(1);                                    //execution resumes from here after wake-up
    //digitalWrite(rtcpin, HIGH);
    digitalWrite(gpspin, LOW);
    telltime();
    RTC.armAlarm(1, false);
    RTC.clearAlarm(1);
    RTC.alarmInterrupt(1, false);
    PCICR = savedPCICR;  // Restore any pin change interrupts that were disabled
    getGPS ();
    delay(1000);
  }

void senddata(){
  while (txcompletion)
  {
    os_runloop_once();
     delay(1000);
  }
  txcompletion = true;
}
  

void setup() {
  Serial.begin(115200);
  ss.begin(9600);
  //Initialize communication with the clock
  Wire.begin();
  pinMode(gpspin, OUTPUT);
  RTC.begin();
  RTC.adjust(DateTime(__DATE__, __TIME__));   //set RTC date and time to COMPILE time
  //clear any pending alarms
  RTC.armAlarm(1, false);
  RTC.clearAlarm(1);
  RTC.alarmInterrupt(1, false);
  RTC.armAlarm(2, false);
  RTC.clearAlarm(2);
  RTC.alarmInterrupt(2, false);
  RTC.writeSqwPinMode(DS3231_OFF);

  telltime ();
  while(!Serial);
  Serial.println("Starting");

}

//------------------------------------------------------------

void loop() {

    
               RTC.setAlarm(ALM1_MATCH_HOURS, 31, 18, 0);   //set your wake-up time here
    telltime ();
    alarmset ();


         RTC.setAlarm(ALM1_MATCH_HOURS, 53, 19, 0);   //set your wake-up time here
    telltime ();
    alarmset ();


}




srnet

The 1284 core has the -permissive flag disabled as I recall.

The 2560 core probably has it enabled.
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

Go Up