encodings: Added check for non-8bit encodings in src tree.

This commit sanitizes source files for unicode encodings which
cause failures in downstream flows (docgen, python2 module loading,
etc...).

    * Removed explicit encodings from src files
    * Replaced 2 byte character encodings with ascii encodies:
        ± -> +/-
        ° -> deg
        “ -> "
        etc...
    * Added ctest to check src tree files for non-8bit encodings

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-10-05 13:36:56 -07:00
parent 131947dc74
commit edd8df4c50
46 changed files with 5721 additions and 5660 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* Author: Marc Graham <marc@m2ag.net>
* Copyright (c) 2015 Intel Corporation.
*
@ -71,12 +71,12 @@ namespace upm {
* Data is transferred via an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1013/4/5
* operate from a single power supply ranging from 2.0V to 5.5V.
* The ADS1013/4/5 can perform conversions at rates up to 3300 samples per second (SPS). An onboard PGA is available
* on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as ±256mV, allowing both large and small
* on the ADS1014 and ADS1015 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small
* signals to be measured with high resolution. The ADS1015 also features an input multiplexer (MUX) that provides two
* differential or four single-ended inputs.
* The ADS1013/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down
* after a conversion and greatly reduces current consumption during idle periods. The ADS1013/4/5 are specified from
* 40°C to +125°C.
* -40 deg C to +125 deg C.
*
* Tested with Adafriut ADS1015 board: https://www.adafruit.com/products/1083
*

View File

@ -1,4 +1,4 @@
/*
/*
* Author: Marc Graham <marc@m2ag.net>
* Copyright (c) 2015 Intel Corporation.
*
@ -71,11 +71,11 @@ namespace upm {
* an I2C-compatible serial interface; four I2C slave addresses can be selected. The ADS1113/4/5 operate from a single power
* supply ranging from 2.0V to 5.5V.
* The ADS1113/4/5 can perform conversions at rates up to 860 samples per second (SPS). An onboard PGA is available on
* the ADS1114 and ADS1115 that offers input ranges from the supply to as low as ±256mV, allowing both large and small
* the ADS1114 and ADS1115 that offers input ranges from the supply to as low as +/- 256mV, allowing both large and small
* signals to be measured with high resolution. The ADS1115 also features an input multiplexer (MUX) that provides two
* differential or four single-ended inputs.
* The ADS1113/4/5 operate either in continuous conversion mode or a single-shot mode that automatically powers down after
* a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from 40°C to +125°C.
* a conversion and greatly reduces current consumption during idle periods. The ADS1113/4/5 are specified from -40 deg C to +125 deg C.
*
* Tested with DIYMall ADS1115 board. Also available from Adafruit: https://www.adafruit.com/products/1085
*

View File

@ -48,7 +48,7 @@ namespace upm {
*
* ADXL345 is a 3-axis digital accelerometer.
* (http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf)
* The sensor has configurable resolutions to measure ±2g, ±4g, ±8g, or ±16g.
* The sensor has configurable resolutions to measure +/- 2g, +/- 4g, +/- 8g, or +/- 16g.
* Note: The Grove* version of the sensor is incompatible with and not detected
* on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V
* (3V works fine).

View File

@ -54,7 +54,7 @@ namespace upm {
* The BME280 is as combined digital humidity, pressure and
* temperature sensor based on proven sensing principles. The sensor
* module is housed in an extremely compact metal-lid LGA package
* with a footprint of only 2.5 × 2.5 mm2 with a height of 0.93
* with a footprint of only 2.5 * 2.5 mm2 with a height of 0.93
* mm. Its small dimensions and its low power consumption allow the
* implementation in battery driven devices such as handsets, GPS
* modules or watches. The BME280 is register and performance

View File

@ -538,7 +538,7 @@ void BMP280::csOff()
// These functions come from the BMP280 datasheet, section 3.11.3
// Returns temperature in DegC, resolution is 0.01 DegC. Output value
// of “5123” equals 51.23 DegC. t_fine carries fine temperature as
// of "5123" equals 51.23 DegC. t_fine carries fine temperature as
// global value
int32_t BMP280::bmp280_compensate_T_int32(int32_t adc_T)
{

View File

@ -58,8 +58,8 @@ namespace upm {
* The BMP280 is an absolute barometric pressure sensor especially
* designed for mobile applications. The sensor module is housed in
* an extremely compact 8-pin metal-lid LGA package with a footprint
* of only 2.0 × 2.5 mm2 and 0.95 mm package height. Its small
* dimensions and its low power consumption of 2.7 μA @1Hz allow the
* of only 2.0 * 2.5 mm2 and 0.95 mm package height. Its small
* dimensions and its low power consumption of 2.7 uA @1Hz allow the
* implementation in battery driven devices such as mobile phones,
* GPS modules or watches.
*

View File

@ -45,7 +45,7 @@ namespace upm {
* detection of movements and rotations in 6 degrees of freedom
* (6DoF). It reflects the full functionality of a triaxial, low-g
* acceleration sensor and at the same time it is capable to measure
* angular rates. Both acceleration and angular rate in three
* angular rates. Both - acceleration and angular rate - in three
* perpendicular room dimensions, the x-, y- and z-axis.
*
* The BMI055 is essentially 2 separate devices in one: the BMA250E

View File

@ -48,7 +48,7 @@ namespace upm {
*
* The BMM150 is a standalone geomagnetic sensor for consumer market
* applications. It allows measurements of the magnetic field in
* three perpendicular axes. Based on Boschs proprietary FlipCore
* three perpendicular axes. Based on Bosch's proprietary FlipCore
* technology, performance and features of BMM150 are carefully
* tuned and perfectly match the demanding requirements of all
* 3-axis mobile applications such as electronic compass, navigation

View File

@ -51,7 +51,7 @@ namespace upm {
*
* The BNO055 is a System in Package (SiP), integrating a triaxial
* 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of
* ±2000 degrees per second, a triaxial geomagnetic sensor and a
* +/- 2000 degrees per second, a triaxial geomagnetic sensor and a
* 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor
* fusion software, in a single package.
*

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "ds1808lc")
set (libdescription “DS1808 lighting controller”)
set (libdescription "DS1808 lighting controller")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -54,7 +54,7 @@ namespace upm {
*
* @brief API for the DS2413 1-Wire Dual Channel Addressable Switch
*
* The DS2413 is a dual-channel programmable I/O 1-Wire® chip. The
* The DS2413 is a dual-channel programmable I/O 1-Wire(r) chip. The
* PIO outputs are configured as open-drain and provide up to 20mA
* continuous sink capability and off-state operating voltage up
* to 28V. Control and sensing of the PIO pins is performed with

View File

@ -82,7 +82,7 @@ namespace upm {
typedef enum {
FORMAT_VGA = 7, // 640x480
FORMAT_CIF = 5, // 352×288
FORMAT_CIF = 5, // 352*288
FORMAT_OCIF = 3 // ??? (maybe they meant QCIF?)
} PIC_FORMATS_T;

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "hlg150h")
set (libdescription “Lighting power supply”)
set (libdescription "Lighting power supply")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -47,7 +47,7 @@ const uint8_t DISPLAY_CMD_SET_NORMAL_1308 = 0xA6;
* @brief API for SSD1308 I2C-controlled OLED displays
*
* SSD1308 is a 128x64 dot-matrix OLED/PLED segment driver with a
* controller. This implementation was tested using the Grove LED 128×64
* controller. This implementation was tested using the Grove LED 128*64
* Display module, which is an OLED monochrome display.
*
* @image html ssd1308.jpeg

View File

@ -47,7 +47,7 @@ const uint8_t DISPLAY_CMD_SET_NORMAL = 0xA4;
* @brief API for SSD1327 I2C-controlled OLED displays
*
* SSD1327 is a 96x96 dot-matrix OLED/PLED segment driver with a controller.
* This implementation was tested using the Grove LED 96×96 Display module,
* This implementation was tested using the Grove LED 96*96 Display module,
* which is an OLED monochrome display.
*
* @image html ssd1327.jpeg

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "lp8860")
set (libdescription “LED lighting controller”)
set (libdescription "LED lighting controller")
set (module_src ${libname}.cxx mraa-utils.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -1,5 +1,5 @@
set (libname "lpd8806")
set (libdescription “Digital RGB LED strip”)
set (libdescription "Digital RGB LED strip")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -91,7 +91,7 @@ namespace upm {
*
* The Maxim Integrated
* [MAX44009](http://datasheets.maximintegrated.com/en/ds/MAX44009.pdf)
* is Industrys Lowest-Power Ambient Light Sensor with ADC.
* is Industry's Lowest-Power Ambient Light Sensor with ADC.
*
* @library max44009
* @sensor max44009

View File

@ -59,8 +59,8 @@ namespace upm {
*
* @brief API for MCP9808 precision temprature sensor
*
* The MCP9808 digital temperature sensor converts temperatures between -20°C and +100°C
* to a digital word with ±0.5°C (max.) accuracy. The MCP9808 comes with user-programmable
* The MCP9808 digital temperature sensor converts temperatures between -20 deg C and +100 deg C
* to a digital word with +/- 0.5 deg C (max.) accuracy. The MCP9808 comes with user-programmable
* registers that provide flexibility for temperature sensing applications. The registers
* allow user-selectable settings such as Shutdown or low-power modes and the specification
* of temperature Event and Critical output boundaries. When the temperature changes beyond
@ -133,10 +133,10 @@ namespace upm {
* @var MCP9808_CONFIG::ALERTMODE - Alert Output Mode bit
* 0 = Comparator output (power-up default)
* 1 = Interrupt output
* @var MCP9808_CONFIG::HYST_0 : 0°C
* @var MCP9808_CONFIG::HYST_1_5 : +1.5°C
* @var MCP9808_CONFIG::HYST_3_0 : +3.0°C
* @var MCP9808_CONFIG::HYST_6_0 : +6.0°C
* @var MCP9808_CONFIG::HYST_0 : 0 deg C
* @var MCP9808_CONFIG::HYST_1_5 : +1.5 deg C
* @var MCP9808_CONFIG::HYST_3_0 : +3.0 deg C
* @var MCP9808_CONFIG::HYST_6_0 : +6.0 deg C
*/
typedef enum
{

View File

@ -44,7 +44,7 @@ namespace upm {
*
* @brief API for the MPU60X0 3-axis Gyroscope and 3-axis Accelerometer
*
* The MPU60X0 devices provide the worlds first integrated 6-axis
* The MPU60X0 devices provide the world's first integrated 6-axis
* motion processor solution that eliminates the package-level
* gyroscope and accelerometer cross-axis misalignment associated
* with discrete solutions. The devices combine a 3-axis gyroscope
@ -401,7 +401,7 @@ namespace upm {
*
* MST_DLY is not enumerated in the register map. It configures
* the reduced access rate of i2c slaves relative to the sample
* rate. When a slaves access rate is decreased relative to the
* rate. When a slave's access rate is decreased relative to the
* Sample Rate, the slave is accessed every
* 1 / (1 + I2C_MST_DLY) samples
*/

View File

@ -1,6 +1,6 @@
include_directories(..)
set (libname "ms5611")
set (libdescription “Pressure and temperature sensor”)
set (libdescription "Pressure and temperature sensor")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -83,7 +83,7 @@ namespace upm {
typedef enum {
FORMAT_VGA = 7, // 640x480
FORMAT_CIF = 5, // 352×288
FORMAT_CIF = 5, // 352*288
FORMAT_OCIF = 3 // ??? (maybe they meant QCIF?)
} PIC_FORMATS_T;

View File

@ -57,9 +57,9 @@ namespace upm {
* The TB7200 Series PI thermostats are designed for zoning
* applications, and the TB7300 Series PI thermostats are designed
* for fan coil control. Both Series are communicating thermostats
* with models available in BACnet® MS/TP protocol and can be easily
* with models available in BACnet(r) MS/TP protocol and can be easily
* integrated into a WEBs-AX building automation system based on the
* NiagaraAX® platform.
* NiagaraAX(r) platform.
*
* TB7200 and TB7300 Series thermostats are compatible with the
* Honeywell Occupancy Sensor Cover. Thermostats equipped with an

View File

@ -2,6 +2,13 @@ add_test (NAME check_consistency COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_consistency.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Check file encodings in src tree
if (PYTHON2INTERP_FOUND)
add_test (NAME check_file_encoding COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_file_encoding.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src)
endif (PYTHON2INTERP_FOUND)
if (BUILDSWIGJAVA)
add_test (NAME check_autoloadlibrary COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_autoloadlibrary.py

54
tests/check_file_encoding.py Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/python
import unittest
import os
import chardet
target_exts = ['.h', '.hpp', '.hxx', '.txt']
valid_encodings = ['ascii', 'utf-8']
class EncodingTests(unittest.TestCase):
'''Non-ascii/utf-8 encodings can cause failures on downstream tools
such as documentation-generation and python2 module loading. This
class helps find those files which could cause an encoding problem'''
def test_headers_ascii(self):
'''Assert/print list of:
file:linenumber offending line
for all lines of matching files which are not in valid_encodings'''
# Keep a map of files with alternate encodes to report
invalid_files = {}
# Recusively search cwd for files with target_exts
for root, dirs, files in os.walk(os.curdir):
# Work on full paths
for file in files:
file = os.path.join(root, file)
# Skip any files not ending with target_exts
if not any(file.lower().endswith(x) for x in target_exts):
continue
# Check each with chardet
with open(file, 'r') as f:
for ndx, line in enumerate(f):
result = chardet.detect(line)
if not result['encoding'] in valid_encodings:
if not invalid_files.has_key(file):
invalid_files[file] = []
invalid_files[file].append([ndx,line])
# Sort the failures by filename
skeys = list(invalid_files.keys())
skeys.sort()
invalid_lines = ''
for fn in skeys:
for line in invalid_files[fn]:
invalid_lines += '%s:%d %s' % (fn, line[0], line[1])
self.assertEqual( len(invalid_files), 0,
"\nThe following modules have alternate encodings:\n" + \
invalid_lines)
if __name__ == '__main__':
unittest.main()