kareemwaheed
Posts: 31
Joined: Mon Feb 25, 2019 11:47 am

Compiling a library

Sun Sep 29, 2019 1:54 pm

Hi, sorry for this Noob question

but i have this library
https://github.com/wrobell/librpims5x

i need to use it to get readings from the sensor but i'm struggle in using i'm could any one give me an idea with steps how to work with these libraries as i only used python on rasbian and linux overall

Thanks

kareemwaheed
Posts: 31
Joined: Mon Feb 25, 2019 11:47 am

Re: Compiling a library

Sun Sep 29, 2019 2:43 pm

could anyone help

DirkS
Posts: 10398
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Compiling a library

Sun Sep 29, 2019 2:50 pm

kareemwaheed wrote:
Sun Sep 29, 2019 2:43 pm
could anyone help
It's the weekend and almost everyone here is a volunteer.
You really should wait at least a day before bumping...

User avatar
B.Goode
Posts: 10448
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Compiling a library

Sun Sep 29, 2019 5:54 pm

kareemwaheed wrote:
Sun Sep 29, 2019 1:54 pm
Hi, sorry for this Noob question

but i have this library
https://github.com/wrobell/librpims5x

i need to use it to get readings from the sensor but i'm struggle in using i'm could any one give me an idea with steps how to work with these libraries as i only used python on rasbian and linux overall

Thanks

From the documentation you cited:
The librpims5x project provides C library (with Python 3 bindings) for
various pressure sensors produced by Measurement Specialties

So if you want to use Python, you can.


and
The interface is pretty straightforward, see examples directory.

In the examples directory is a file rpims5x-read.py

That python script has about 12 active lines that demonstrate how to read and display the temperature and pressure from your sensor.

What else do you need to know?


But note that the library in that GitHub repository has not been updated for many years. That might mean it is very stable and reliable, or maybe it has been abandoned...

fbe
Posts: 645
Joined: Thu Aug 17, 2017 9:08 pm

Re: Compiling a library

Sun Sep 29, 2019 7:20 pm

I would also recommend to search for a more actively maintained library

In ibrpims5x/rpims5x/glue.py I found:

Code: Select all

...
class Sensor(object):
    """
    Pressure sensor communication interface.
    """
    def __init__(self):
        """
        Create pressure sensor communication interface.
        """
        self._lib = ct.CDLL('librpims5x.so.0')
        self._lib.rpims5x_init()
        self._p_value = ct.c_ushort()
        self._t_value = ct.c_ushort()
...
I don't know much about Python but I guess you need to build and install librpims5x.so.0 first to use the python library.

In librpims5x/src/rpims5x.c you could add

Code: Select all

#include <unistd.h>
at the beginning to avoid compiler warnings about implicite function declarations and you could add a return statement to the rpims5x_read_avg function (just compare with the rpims5x_read).

You must change the line

Code: Select all

#define BCM2708_PERI_BASE  0x20000000
if you want to use the library with Raspberry Pi3 or later... Otherwise it will crash when running. See https://www.raspberrypi.org/documentati ... dresses.md

You can compile and install the library with

Code: Select all

gcc -c -Wall rpims5x.c -o rpims5x.o
gcc -shared -Wall rpims5x.o -o rpims5x.so.0
sudo install -m644 -oroot -groot rpims5x.so.0 /usr/local/lib
sudo ldconfig
If you want to write C programs, install the header

Code: Select all

sudo install -m644 -oroot -groot rpims5x.h /usr/local/include
I can't help you with the python installation.

kareemwaheed
Posts: 31
Joined: Mon Feb 25, 2019 11:47 am

Re: Compiling a library

Mon Sep 30, 2019 8:27 am

Thank you all, i found a solution using Arduino nano then i'll connect it with Rpi via USB

Return to “Beginners”