All modifications that have been made in april 2026 tu compile upm

with latest version of cmake, C++, C,  python3 and last java version. It has
not been possible to reach a successfull compilation with node and cordova.

Most of the modifications are workarouds because the software requires an
heavy revision from a tue dev whom I am not.

 Modifications qui seront validées :
	modifié :         CMakeLists.txt
	modifié :         cmake/modules/FindNode.cmake
	modifié :         cmake/modules/FindNpm.cmake
	modifié :         cmake/modules/OpenCVDetectPython.cmake
	nouveau fichier : cmake/modules/OpenCVDetectPython.oldcmake
	modifié :         include/upm_types.h
	modifié :         src/CMakeLists.txt
	modifié :         src/ehr/ehr.cxx
	supprimé :        src/hp20x/CMakeLists.txt
	supprimé :        src/hp20x/hp20x.cxx
	supprimé :        src/hp20x/hp20x.hpp
	supprimé :        src/hp20x/hp20x.json
This commit is contained in:
2026-04-21 09:55:31 +02:00
parent 23c137467d
commit b4f87037ac
12 changed files with 276 additions and 808 deletions

View File

@@ -210,7 +210,7 @@ function (_print_target_summary)
endfunction (_print_target_summary)
function (_get_target_dependency_interface_include_dirs target varIncludeDirs)
set (${varIncludeDirs} "")
set (${varIncludeDirs} "/usr/include/python3.13")
# For each LINK_LIBRARIES of target
get_property(_targets TARGET ${target} PROPERTY LINK_LIBRARIES)
@@ -323,7 +323,7 @@ macro(_upm_swig_python)
# Set current python binary dir
set (CMAKE_CURRENT_PYTHON_BINARY_DIR
${CMAKE_CURRENT_BINARY_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
${CMAKE_CURRENT_BINARY_DIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
# Make sure swig places wrapper/.py collateral under python2/3 directory
# Save the original BINARY_DIR, set a new BINARY_DIR, then restore at
@@ -333,7 +333,7 @@ macro(_upm_swig_python)
set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_PYTHON_BINARY_DIR})
# Swig module name (example: pyupm_a110x-python2)
set (python_wrapper_name pyupm_${libname}-python${PYTHON_VERSION_MAJOR})
set (python_wrapper_name pyupm_${libname}-python${Python3_VERSION_MAJOR})
if (CMAKE_VERSION VERSION_LESS "3.8")
swig_add_module (${python_wrapper_name} python ${SWIG_CURRENT_DOT_I_FILE})
else ()
@@ -343,7 +343,9 @@ macro(_upm_swig_python)
set (python_wrapper_target ${SWIG_MODULE_${python_wrapper_name}_REAL_NAME})
if(module_iface)
add_dependencies(${python_wrapper_target} _pyupm_interfaces-python${PYTHON_VERSION_MAJOR})
#message(STATUS "python version major : " ${Python3_VERSION_MAJOR})
#add_dependencies(${python_wrapper_target} _pyupm_interfaces-python${Python3_VERSION_MAJOR})
add_dependencies(${python_wrapper_target} pyupm_interfaces-python${Python3_VERSION_MAJOR})
endif()
add_dependencies(${python_wrapper_target} ${libname})
@@ -381,12 +383,12 @@ macro(_upm_swig_python)
# Install .py's to python packages directory/upm
install (FILES ${swig_extra_generated_files}
DESTINATION ${PYTHON_PACKAGES_PATH}/upm
COMPONENT ${CMAKE_PROJECT_NAME}-python${PYTHON_VERSION_MAJOR})
COMPONENT ${CMAKE_PROJECT_NAME}-python${Python3_VERSION_MAJOR})
# Install python wrapper module library
install (TARGETS ${python_wrapper_target}
DESTINATION ${PYTHON_PACKAGES_PATH}/upm
COMPONENT ${CMAKE_PROJECT_NAME}-python${PYTHON_VERSION_MAJOR})
COMPONENT ${CMAKE_PROJECT_NAME}-python${Python3_VERSION_MAJOR})
# Restore CMAKE_CURRENT_BINARY_DIR
set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR_SAVED})
@@ -412,19 +414,19 @@ function(upm_swig_python)
endif (PYTHON2LIBS_FOUND)
# Generate python3 module if python3 libs are available
if (PYTHON3LIBS_FOUND)
set(PYTHON_INCLUDE_DIRS ${PYTHON3_INCLUDE_DIRS})
set(PYTHON_INCLUDE_PATH ${PYTHON3_INCLUDE_PATH})
set(PYTHON_LIBRARIES ${PYTHON3_LIBRARIES})
set(PYTHON_VERSION_MAJOR ${PYTHON3_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${PYTHON3_VERSION_MINOR})
set(PYTHON_PACKAGES_PATH ${PYTHON3_PACKAGES_PATH})
if (Python3_FOUND)
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIR})
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
set(PYTHON_PACKAGES_PATH ${Python3_PACKAGES_PATH})
_upm_swig_python()
# Keep track of all Python3 targets
set(UPM_TARGETS_PYTHON3 ${UPM_TARGETS_PYTHON3} ${python_wrapper_target}
CACHE INTERNAL "List of Python target names")
endif (PYTHON3LIBS_FOUND)
endif (Python3_FOUND)
endif (NOT ";${PYTHONSWIG_BLACKLIST};" MATCHES ";${libname};")
endfunction(upm_swig_python)

View File

@@ -114,7 +114,7 @@ uint32_t EHR::beatCounter()
void EHR::beatISR(void *ctx)
{
upm::EHR *This = (upm::EHR *)ctx;
This->m_beatCounter++;
This->m_beatCounter = This->m_beatCounter + 1;
}
int EHR::heartRate()

View File

@@ -1,6 +0,0 @@
set (libname "hp20x")
set (libdescription "High-accuracy Barometer")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
set (module_iface iPressure.hpp iTemperature.hpp)
upm_module_init(mraa)

View File

@@ -1,275 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
#include <unistd.h>
#include <math.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include "hp20x.hpp"
using namespace upm;
using namespace std;
HP20X::HP20X(int bus, uint8_t address):
m_i2c(bus)
{
m_addr = address;
mraa::Result rv;
if ( (rv = m_i2c.address(m_addr)) != mraa::SUCCESS)
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": I2c.address() failed");
return;
}
}
HP20X::~HP20X()
{
}
bool HP20X::init(DSR_BITS_T dsr)
{
// wait for the device to report ready
waitforDeviceReady();
m_dsr = dsr;
// enable compensation? Datasheet says yes, but a register readback
// says no. Data does seem stable, so....
compensationEnable(true);
return true;
}
bool HP20X::isReady()
{
uint8_t intsrc = readReg(REG_INT_SRC);
if (intsrc & INT_SRC_DEV_RDY)
return true;
return false;
}
bool HP20X::waitforDeviceReady()
{
const int maxRetries = 20;
int retries = 0;
while (retries < maxRetries)
{
if (isReady())
return true;
usleep(20000);
retries++;
}
throw std::runtime_error(std::string(__FUNCTION__) +
": timeout waiting for device to become ready");
return false;
}
bool HP20X::writeCmd(uint8_t cmd)
{
mraa::Result rv;
if ((rv = m_i2c.writeByte(cmd)) != mraa::SUCCESS)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.writeByte() failed");
return false;
}
return true;
}
bool HP20X::writeReg(HP20X_REG_T reg, uint8_t data)
{
waitforDeviceReady();
uint8_t r = CMD_WRITE_REG | reg;
mraa::Result rv;
if ((rv = m_i2c.writeReg(r, data)) != mraa::SUCCESS)
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.writeReg() failed");
return false;
}
return true;
}
uint8_t HP20X::readReg(HP20X_REG_T reg)
{
uint8_t r = CMD_READ_REG | reg;
return m_i2c.readReg(r);
}
int HP20X::readData()
{
uint8_t buf[3] = {0};
if (!m_i2c.read(buf, 3))
{
throw std::runtime_error(std::string(__FUNCTION__) +
": I2c.read() failed");
return 0;
}
// handle 24bit sign extension
int minus = 1;
if (buf[0] & 0x80)
{
// negative
buf[0] &= 0x3f;
minus = -1;
}
return ( minus * ((buf[0] << 16) | (buf[1] << 8) | buf[2]) );
}
float HP20X::getTemperature()
{
// wait for the device to report ready
waitforDeviceReady();
// start conversion, T only
uint8_t cmd = CMD_ADC_CVT | (CHNL_T << CHNL_SHIFT) | (m_dsr << DSR_SHIFT);
writeCmd(cmd);
// wait for the device to report ready
waitforDeviceReady();
// now read the temperature
writeCmd(CMD_READ_T);
return ((float)readData() / 100.0);
}
float HP20X::getPressure()
{
// wait for the device to report ready
waitforDeviceReady();
// start conversion, PT only
uint8_t cmd = CMD_ADC_CVT | (CHNL_PT << CHNL_SHIFT) | (m_dsr << DSR_SHIFT);
writeCmd(cmd);
// wait for the device to report ready
waitforDeviceReady();
// now read the pressure
writeCmd(CMD_READ_P);
// Return result in Pa, not milibars.
return (float)readData();
}
float HP20X::getAltitude()
{
// wait for the device to report ready
waitforDeviceReady();
// start conversion, PT only
uint8_t cmd = CMD_ADC_CVT | (CHNL_PT << CHNL_SHIFT) | (m_dsr << DSR_SHIFT);
writeCmd(cmd);
// wait for the device to report ready
waitforDeviceReady();
// now read the pressure
writeCmd(CMD_READ_A);
return ((float)readData() / 100.0);
}
void HP20X::compensationEnable(bool enable)
{
if (enable)
writeReg(REG_PARA, PARA_CMPS_EN);
else
writeReg(REG_PARA, 0);
}
bool HP20X::setInterruptEnable(uint8_t bits)
{
return writeReg(REG_INT_EN, bits);
}
bool HP20X::setInterruptConfig(uint8_t bits)
{
return writeReg(REG_INT_CFG, bits);
}
uint8_t HP20X::getInterruptSource()
{
return readReg(REG_INT_SRC);
}
void HP20X::setDSR(DSR_BITS_T dsr)
{
m_dsr = dsr;
}
void HP20X::recalibrateInternal()
{
waitforDeviceReady();
writeCmd(CMD_ANA_CAL);
}
void HP20X::softReset()
{
waitforDeviceReady();
writeCmd(CMD_SOFT_RST);
waitforDeviceReady();
}
void HP20X::setAltitudeOffset(int16_t off)
{
writeReg(REG_ALT_OFF_LSB, (off & 0xff));
writeReg(REG_ALT_OFF_MSB, ((off >> 8) & 0xff));
}
void HP20X::setPAThreshholds(int16_t low, int16_t med, int16_t high)
{
// low
writeReg(REG_PA_L_TH_LSB, (low & 0xff));
writeReg(REG_PA_L_TH_MSB, ((low >> 8) & 0xff));
// medium
writeReg(REG_PA_M_TH_LSB, (med & 0xff));
writeReg(REG_PA_M_TH_MSB, ((med >> 8) & 0xff));
// high
writeReg(REG_PA_H_TH_LSB, (high & 0xff));
writeReg(REG_PA_H_TH_MSB, ((high >> 8) & 0xff));
}
void HP20X::setTemperatureThreshholds(int8_t low, int8_t med, int8_t high)
{
// low
writeReg(REG_T_L_TH, low);
// medium
writeReg(REG_T_M_TH, med);
// high
writeReg(REG_T_H_TH, high);
}

View File

@@ -1,374 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <string>
#include <mraa/common.hpp>
#include <mraa/i2c.hpp>
#include <interfaces/iPressure.hpp>
#include <interfaces/iTemperature.hpp>
#define HP20X_I2C_BUS 0
#define HP20X_DEFAULT_I2C_ADDR 0x76
namespace upm {
/**
* @brief HP20X I2C Barometer (High-Accuracy)
* @defgroup hp20x libupm-hp20x
* @ingroup seeed i2c pressure
*/
/**
* @library hp20x
* @sensor hp20x
* @comname High-accuracy Barometer
* @altname HP20X Barometer (High-Accuracy)
* @type pressure
* @man seeed
* @web http://www.seeedstudio.com/depot/Grove-Barometer-HighAccuracy-p-1865.html
* @con i2c
*
* @brief API for the HP20X-based Grove Barometer (High-Accuracy)
*
* This is a high-accuracy barometer providing pressure, altitude,
* and temperature data. It can be calibrated for a given altitude
* offset, and a wide range of interrupt generating capabilities are
* supported. As usual, see the HP20X datasheet for more details.
*
* This module was developed using a Grove Barometer (High-Accuracy)
* based on an HP206C chip.
*
* @image html hp20x.jpg
* @snippet hp20x.cxx Interesting
*/
class HP20X : virtual public iPressure, virtual public iTemperature {
public:
/**
* HP20X commands
*/
typedef enum {
CMD_SOFT_RST = 0x06,
CMD_ADC_CVT = 0x40, // mask - ANDed with DSR and CHNL bits
CMD_READ_PT = 0x10, // read pressure/temp
CMD_READ_AT = 0x11, // read alt/temp
CMD_READ_P = 0x30, // read pressure only
CMD_READ_A = 0x31, // read alt only
CMD_READ_T = 0x32, // read temp only
CMD_ANA_CAL = 0x28, // recalibrate internal analog blocks
CMD_READ_REG = 0x80, // mask - ANDed with reg addr
CMD_WRITE_REG = 0xc0 // mask - ANDed with reg addr
} HP20X_CMD_T;
/**
* CHNL bits
*/
typedef enum {
CHNL_PT = 0x00, // pressure and temperature
CHNL_T = 0x02, // temperature
CHNL_SHIFT = 0 // don't use, indicates position in REG
} CHNL_BITS_T;
/**
* DSR bits
*/
typedef enum {
DSR_4096 = 0x00, // decimation rate of digital filter
DSR_2048 = 0x01,
DSR_1024 = 0x02,
DSR_512 = 0x03,
DSR_256 = 0x04,
DSR_128 = 0x05,
DSR_SHIFT = 2 // don't use, indicates position in REG
} DSR_BITS_T;
/**
* HP20X registers
*/
typedef enum {
REG_ALT_OFF_LSB = 0x00,
REG_ALT_OFF_MSB = 0x01,
REG_PA_H_TH_LSB = 0x02, // Pres/Alt high threshold
REG_PA_H_TH_MSB = 0x03,
REG_PA_M_TH_LSB = 0x04, // Pres/Alt medium threshold
REG_PA_M_TH_MSB = 0x05,
REG_PA_L_TH_LSB = 0x06, // Pres/Alt low threshold
REG_PA_L_TH_MSB = 0x07,
REG_T_H_TH = 0x08, // temperature high threshold
REG_T_M_TH = 0x09,
REG_T_L_TH = 0x0a,
REG_INT_EN = 0x0b, // interrupt enables
REG_INT_CFG = 0x0c, // interrupt configuration
REG_INT_SRC = 0x0d, // interrupt sources
REG_PARA = 0x0e // parameters config
} HP20X_REG_T;
/**
* INT_EN bits
*/
typedef enum {
INT_EN_T_WIN_EN = 0x01,
INT_EN_PA_WIN_EN = 0x02,
INT_EN_T_TRAV_EN = 0x04,
INT_EN_PA_TRAV_EN = 0x08,
INT_EN_T_RDY_EN = 0x10,
INT_EN_PA_RDY_EN = 0x20
// 0x40, 0x80 reserved
} INT_EN_BITS_T;
/**
* INT_CFG bits
*/
typedef enum {
INT_CFG_T_WIN_CFG = 0x01,
INT_CFG_PA_WIN_CFG = 0x02,
INT_CFG_T_TRAV_CFG = 0x04,
INT_CFG_PA_TRAV_CFG = 0x08,
INT_CFG_T_RDY_CFG = 0x10,
INT_CFG_PA_RDY_CFG = 0x20,
INT_CFG_PA_MODE = 0x40
// 0x80 reserved
} INT_CFG_BITS_T;
/**
* INT_SRC bits
*/
typedef enum {
INT_SRC_T_WIN = 0x01,
INT_SRC_PA_WIN = 0x02,
INT_SRC_T_TRAV = 0x04,
INT_SRC_PA_TRAV = 0x08,
INT_SRC_T_RDY = 0x10,
INT_SRC_PA_RDY = 0x20,
INT_SRC_DEV_RDY = 0x40, // device is ready
INT_SRC_TH_ERR = 0x80 // threshold error
} INT_SRC_BITS_T;
/**
* PARA bits
*/
typedef enum {
// 0x01-0x40 reserved
PARA_CMPS_EN = 0x80 // compensation enable
} PARA_BITS_T;
/**
* HP20X constructor
*
* @param bus I2C bus to use
* @param address Address for this device
*/
HP20X(int bus=HP20X_I2C_BUS, uint8_t address=HP20X_DEFAULT_I2C_ADDR);
/**
* HP20X destructor
*/
~HP20X();
/**
* Sets up initial values and starts operation
*
* @param dsr Data sampling rate; one of the DSR_BITS_T values
* @return True if successful
*/
bool init(DSR_BITS_T dsr=DSR_4096);
/**
* Sends a command to the device
*
* @param cmd Command to send; usually, one of the HP20X_CMD_T values
* @return True if successful
*/
bool writeCmd(uint8_t cmd);
/**
* Writes a value to a register
*
* @param reg Register to write to; one of the HP20X_REG_T values
* @param data Value to write
* @return True if successful
*/
bool writeReg(HP20X_REG_T reg, uint8_t data);
/**
* Reads a register and returns its value
*
* @param reg Register to read; one of the HP20X_REG_T values
* @return Value of a specified register
*/
uint8_t readReg(HP20X_REG_T reg);
/**
* Reads 3 bytes of data in response to a conversion request, and
* converts it to an integer
*
* @return Value read back (temperature, pressure, etc.)
*/
int readData();
/**
* Checks to see if the DR_RDY bit is set, indicating the device
* can accept commands
*
* @return True if the device is ready, false otherwise
*/
bool isReady();
/**
* Checks to see if the device is ready, and sleeps/retries if not.
* Returns once the device indicates it's ready.
*
* @return True if the device is ready; false if retries are exhausted
*/
bool waitforDeviceReady();
/**
* Returns the temperature in Celsius
*
* @return Temperature
*/
virtual float getTemperature();
/**
* Returns the pressure in pascal
*
* @return Pressure
*/
virtual float getPressure();
/**
* Returns the computed altitude in meters
*
* @return Altitude
*/
float getAltitude();
/**
* Enables or disables the on-chip compensator. This allows the
* chip to filter and clean up the output data.
*
* @param enable True to enable, false otherwise
*/
void compensationEnable(bool enable);
/**
* Sets up the interrupt enable register. This register defines
* which events can cause a hardware interrupt pin to be pulled high
* (active).
*
* @param bits One or more of the INT_EN_BITS_T bits
* @return True if successful, false otherwise
*/
bool setInterruptEnable(uint8_t bits);
/**
* Sets up the interrupt configuration register. This register
* defines which events can cause an interrupt to be indicated.
*
* @param bits One or more of the INT_EN_BITS_T bits
* @return True if successful, false otherwise
*/
bool setInterruptConfig(uint8_t bits);
/**
* Gets the interrupt source register. This register indicates
* which interrupts have been triggered. In addition, it
* indicates when certain operations have been completed.
*
* @return One of more of the INT_SRC_BITS_T values
*/
uint8_t getInterruptSource();
/**
* Sets the data sampling rate. Higher rates are more precise, but
* take more time per measurement.
*
* @param dsr One of the DSR_BITS_T values
*/
void setDSR(DSR_BITS_T dsr);
/**
* Starts an internal recalibration of analog blocks. This is
* faster than a soft reset.
*/
void recalibrateInternal();
/**
* Executes a soft reset. All register values are reset to power-on
* defaults. This function returns when the reset is
* complete and the device reports it is ready.
*/
void softReset();
/**
* Sets the altitude offset for your region. See the datasheet for
* more details. Setting this correctly for your region is
* required for accurate altitude data.
*
* @param off Offset
*/
void setAltitudeOffset(int16_t off);
/**
* Sets pressure/altitude thresholds for interrupt generation
*
* @param low Low threshold to generate an interrupt
* @param med Medium threshold to generate an interrupt
* @param high High threshold to generate an interrupt
*/
void setPAThreshholds(int16_t low, int16_t med, int16_t high);
/**
* Sets temperature thresholds for interrupt generation
*
* @param low Low threshold to generate an interrupt
* @param med Medium threshold to generate an interrupt
* @param high High threshold to generate an interrupt
*/
void setTemperatureThreshholds(int8_t low, int8_t med, int8_t high);
protected:
mraa::I2c m_i2c;
private:
uint8_t m_addr;
uint8_t m_dsr;
};
}

View File

@@ -1,40 +0,0 @@
{
"Library": "hp20x",
"Description": "API for the HP20X-based Grove Barometer (High-Accuracy)",
"Sensor Class":
{
"HP20X":
{
"Name": "HP20X Barometer (High-Accuracy)",
"Description": "This is a high-accuracy barometer providing pressure, altitude, and temperature data. It can be calibrated for a given altitude offset, and a wide range of interrupt generating capabilities are supported. As usual, see the HP20X datasheet for more details. This module was developed using a Grove Barometer (High-Accuracy) based on an HP206C chip.",
"Aliases": ["hp20x"],
"Categories": ["pressure"],
"Connections": ["i2c"],
"Project Type": ["environmental", "prototyping"],
"Manufacturers": ["seeed"],
"Kits": [],
"Image": "hp20x.jpg",
"Examples":
{
"Java": ["HP20x_Example.java"],
"Python": ["hp20x.py"],
"Node.js": ["hp20x.js"],
"C++": ["hp20x.cxx"],
"C": []
},
"Specifications":
{
"Operating Voltage": {"unit": "V", "low": 3.3, "high": 5.5},
"Operating Current": {"unit": "mA", "low": 0.635, "high": 1.1},
"Measurement Range": {"unit": "hPa", "low": 300, "high": 1200}
},
"Urls" :
{
"Product Pages": ["https://www.seeedstudio.com/Grove-Barometer-HighAccuracy-p-1865.html"],
"Datasheets": ["http://www.seeedstudio.com/wiki/File:HP206C_Datasheet.pdf"],
"Schematics": []
}
}
}
}