Cooking Hacks Forum
https://www.cooking-hacks.com/forum/

BG96 4G shield + Cooking Hacks Bridge + ArduPi library
https://www.cooking-hacks.com/forum/viewtopic.php?f=43&t=21149
Page 1 of 1

Author:  MisGeo [ Thu Dec 19, 2019 4:49 pm ]
Post subject:  BG96 4G shield + Cooking Hacks Bridge + ArduPi library

Hi,
I recently owned a raspberry Pi 4 and i want to connect on it a 4G module (more accurate a BG96 4G arduino compatible shield).
In order to do that I managed to purchase a Raspberry Pi to Arduino Shield Connection Bridge

according to the tutorial https://www.cooking-hacks.com/documentation/tutorials/raspberry-pi-to-arduino-shields-connection-bridge
the code works fine for arduino uno, but when trying to compile the arduPi library from cooking hacks it seemed to be corrupted . The following error occurred when trying to manually compile the arduPi.cpp (arduPi.o file doesn't exists after successful installation of the libraries):

Code:
[color=#FF0000]misiakoulis@misiakoulis:~/Desktop/cooking/arduPi$ g++ -c arduPi.cpp -o arduPi.o
arduPi.cpp: In constructor ‘SPIPi::SPIPi()’:
arduPi.cpp:920:20: error: cast from ‘uint8_t* {aka unsigned char*}’ to ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive]
     if (((uint32_t)mapaddr % PAGESIZE) != 0)
                    ^
arduPi.cpp:921:42: error: cast from ‘uint8_t* {aka unsigned char*}’ to ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive]
         mapaddr += PAGESIZE - ((uint32_t)mapaddr % PAGESIZE) ;
                                          ^
arduPi.cpp:925:18: error: cast from ‘void*’ to ‘int32_t {aka int}’ loses precision [-fpermissive]
     if ((int32_t)spi0 < 0){[/color]


When I edit the ArduPi.cpp file in order to delete the SPIPi() constructor, where it seems to be the problem, the code compiled successfully.
My problem is that now when I am trying to compile my arduino code with the arduPi library a whole bunch of errors appeared. The arduino code runs successfully in arduino uno with the Bg96 4g shield.

According to the following template.cpp in the section /*Your arduino code here*/, it supposed to be pretty simple. If I understand correctly you have to copy your working arduino code in this section and compile the code with
Code:
g++ -lrt -lpthread MY_PROGRAM.cpp arduPi.o -o MY_PROGRAM


Code:
[color=#FF0000]//Include arduPi library
   #include "arduPi.h"

   /*********************************************************
    *  IF YOUR ARDUINO CODE HAS OTHER FUNCTIONS APART FROM  *
    *  setup() AND loop() YOU MUST DECLARE THEM HERE        *
    * *******************************************************/

   /**************************
    * YOUR ARDUINO CODE HERE *
    * ************************/

   int main (){
      setup();
      while(1){
         loop();
      }
      return (0);
   }[/color]


But when I am trying to compile my code a lot of errors appeared. I will attached the initial code and the errors in the end of this post.
I even try to compile an empty sketch like the above mentioned template.cpp. Again I am falling into errors:
Code:
[color=#FF0000]g++ -lrt -lpthread test.cpp arduPi.o -o arduino

/usr/bin/ld: arduPi.o: in function `attachInterrupt(int, void (*)(), Digivalue)':
arduPi.cpp:(.text+0x418c): undefined reference to `pthread_create'
/usr/bin/ld: arduPi.cpp:(.text+0x419c): undefined reference to `pthread_cancel'
/usr/bin/ld: arduPi.cpp:(.text+0x41b4): undefined reference to `pthread_create'
/usr/bin/ld: arduPi.o: in function `detachInterrupt(int)':
arduPi.cpp:(.text+0x4278): undefined reference to `pthread_cancel'
collect2: error: ld returned 1 exit status[/color]


It seems to me that there might be a problem with the arduPi library.
Can you please provide me with some help, in order to understand what might be the problem.

Author:  libelium-dev [ Thu Dec 26, 2019 2:30 pm ]
Post subject:  Re: BG96 4G shield + Cooking Hacks Bridge + ArduPi library

Hi,

We are sorry but we haven't tested the arduPi libraries using a Raspberry Pi 4 so we aren't sure if they are compatible.

Did you follow the step of the 3.2 Enabling Interfaces section before installing the libraries?

Did you download the library using this command?
Code:
wget http://www.cooking-hacks.com/media/cooking/images/documentation/raspberry_arduino_shield/raspberrypi2.zip && unzip raspberrypi2.zip && cd cooking/arduPi && chmod +x install_arduPi && ./install_arduPi && rm install_arduPi && cd ../..


Regards

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/