From cf93a5901b7e13d86aa51b81a067e31d713fb733 Mon Sep 17 00:00:00 2001 From: sjpark608 Date: Thu, 29 Dec 2022 16:41:05 -0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit f80eefc0873a0016f9f3ff73f9347741747968ef Author: bot-edgepi Date: Fri Dec 30 00:14:58 2022 +0000 Bump version: 1.1.16 → 1.1.17 commit f81e27eb686b2951df3c96876ec86386f258fa67 Merge: bff88db bf8304c Author: sjpark608 Date: Thu Dec 29 16:14:08 2022 -0800 Merge branch 'dev' into staging commit bf8304c7b1b7c6e9256bff2c01dc18040b80fe60 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Dec 29 16:13:17 2022 -0800 Digital out integration test (#228) * creating integration test * Update test_digital_out.py want to test state not direction * Update test_digital_out.py lint fix commit bff88db446af57362bbca761ca737d1f64e80886 Merge: ac309d8 d51186d Author: sjpark608 Date: Thu Dec 29 15:54:53 2022 -0800 Merge branch 'dev' into staging commit d51186da8e7be63a0fa23012b1619e376da59560 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Dec 29 15:53:43 2022 -0800 Update .bumpversion.cfg (#227) bump version config with quotation causes an issue when fetching the updated version of dev after the staging is merged. The config file is changed to remove the quotation. commit feae067061d5497f4f9ed4f766220a5b19e19f10 Author: bot-edgepi Date: Thu Dec 29 23:33:29 2022 +0000 Bump version: 1.1.15 → 1.1.16 commit ac309d8840188fab8b643f5fe11c511172d26929 Author: bot-edgepi Date: Thu Dec 29 23:33:29 2022 +0000 Bump version: 1.1.15 → 1.1.16 commit 7586072dfede6203f9478303074eac9a96f82bf2 Merge: d504342 f777fca Author: sjpark608 Date: Thu Dec 29 15:31:58 2022 -0800 Merge branch 'dev' into staging commit f777fca324989be696245333faffd0745efcd7d9 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Dec 29 15:22:56 2022 -0800 Digital_output module issue fix (#225) * Update edgepi_gpio_expander.py print statement * re-name gpio close function * Update gpio_configs.py #224 * Readme edit #222 commit e79fa2d7e65725ad4b84201427b858b2ca0c7802 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Dec 22 10:45:34 2022 -0800 Eeprom todo added (#208) * todos * handling todos * Protobuf mapping class created to convert the data class into a regular class * Update test_edgepi_dac.py DAC unittest passing * added updated pb file - added serialized pb for testing - added hw component in tc and rtd - added diff calib for adc - changed pb mapping dataclass to a standalone class - modified edgepi_dac to accommodate the importing - edgepi_adc to accommodate the importing * fixed no-name-in-module * added link to the issue related to protobuf and pylint, added more logging * fix linting * Update edgepi_eeprom.py linting fix commit 1adb982afc5b61ffa44459ffb2f3efc3f8cf7bb5 Author: bot-edgepi Date: Sat Dec 17 01:51:58 2022 +0000 Bump version: 1.1.14 → 1.1.15 commit d5043423902ad84f50d4d14434b5460c7a24ec10 Author: bot-edgepi Date: Sat Dec 17 01:51:58 2022 +0000 Bump version: 1.1.14 → 1.1.15 commit 473d6f613a679977b7cd5c41e35ecbadb0c39a06 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:51:16 2022 -0800 Single Staging Job (#218) * Update Dev Package Version (#201) * enable workflow * bump version for next staging run * Update README.md (#203) * refactor merge to dev workflow (#205) * Cherry Pick Bump Commit (#210) * add test cherry pick workflow * re-remove merge action (#212) * refactor staging workflow (#213) * fix syntax error (#215) * Bump version: 1.1.13 → 1.1.14 * refactor to single job (#217) * refactor to single job * rename job Co-authored-by: bot-edgepi commit f162a17063f714942f210fcd39f033a97038c9c5 Merge: 8545e00 231b313 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:50:09 2022 -0800 Merge branch 'staging' into dev commit 8545e009def9a952c3e016aae79ec7a987b87177 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:46:22 2022 -0800 refactor to single job (#217) * refactor to single job * rename job commit 2520c06b0fb2c704c9252316091fd812be6f85b1 Author: bot-edgepi Date: Sat Dec 17 01:23:55 2022 +0000 Bump version: 1.1.13 → 1.1.14 commit 231b313b7eb7bcf0198aff74cd06420bb4f3a2a2 Author: bot-edgepi Date: Sat Dec 17 01:23:55 2022 +0000 Bump version: 1.1.13 → 1.1.14 commit 07ecf0d9fa64c49db12b349165397395dddd0831 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:23:35 2022 -0800 Fix Workflow Syntax (#216) * Update Dev Package Version (#201) * enable workflow * bump version for next staging run * Update README.md (#203) * refactor merge to dev workflow (#205) * Cherry Pick Bump Commit (#210) * add test cherry pick workflow * re-remove merge action (#212) * refactor staging workflow (#213) * fix syntax error (#215) commit 3b4fca9c06486f3708fb623a3464e5613fad8903 Merge: 620ba08 355b9f5 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:22:00 2022 -0800 Merge branch 'staging' into dev commit 620ba084c27752ff468b2c81a0ac66f0a472f0db Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:19:14 2022 -0800 fix syntax error (#215) commit 355b9f5008bca1bfcdbd5b18d25b12375aa97efe Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 17:00:15 2022 -0800 Refactor Staging Workflow (#214) * Update Dev Package Version (#201) * enable workflow * bump version for next staging run * Update README.md (#203) * refactor merge to dev workflow (#205) * Cherry Pick Bump Commit (#210) * add test cherry pick workflow * re-remove merge action (#212) * refactor staging workflow (#213) commit 89c4f1429eee51764e97c76317ab094ae83a7131 Merge: cb2dc70 0c9d509 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 16:58:30 2022 -0800 Merge branch 'staging' into dev commit cb2dc7056e2fb7f7298471ae3661728b06b2641a Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 16:55:28 2022 -0800 refactor staging workflow (#213) commit 0c9d5094250b4d367a5ff113e1fe518251f82e82 Author: bot-edgepi Date: Sat Dec 17 00:19:02 2022 +0000 Bump version: 1.1.12 → 1.1.13 commit 0c7a0d364dc40078a58fcef8440979c58de2933e Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 16:18:08 2022 -0800 Cherry Pick Bump Commit (#211) * Cherry Pick Bump Commit (#210) commit 475eb5dbb40628fcff74a093f6a62e6ff6655134 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 16:16:25 2022 -0800 re-remove merge action (#212) commit 197a29fe3a13604565e5c4bdaab35212274e197c Merge: 6080e59 157cf13 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 16:04:39 2022 -0800 Merge branch 'staging' into dev commit 6080e59fddaafc95beed0f857b7d77b8969d339a Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 16:02:41 2022 -0800 Cherry Pick Bump Commit (#210) * add test cherry pick workflow commit 157cf130fc80f52bd0f6169563394055b8a3790e Author: bot-edgepi Date: Fri Dec 16 20:40:57 2022 +0000 Bump version: 1.1.11 → 1.1.12 commit 68fa696b957f14bd268a0c4ce2b5db9d99dd276b Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 12:40:07 2022 -0800 Refactor Merge to Dev Workflow (#206) * refactor merge to dev workflow (#205) commit f36d91a5eccc80ef080f31f23c099158c6be29b0 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 12:37:29 2022 -0800 refactor merge to dev workflow (#205) commit 812fb04e178b5ce4f72d1e40461db9844ee5c628 Author: bot-edgepi Date: Fri Dec 16 19:48:26 2022 +0000 Bump version: 1.1.10 → 1.1.11 commit 2e8e22a5f24293ec4f24e7f232b800479afb037c Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 11:47:44 2022 -0800 Merge Staging to Dev Workflow (#204) * Update Dev Package Version (#201) * enable workflow * bump version for next staging run * Update README.md (#203) commit 653782b023a78afb19451fd472690280cd1ee5ba Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 11:17:21 2022 -0800 Update README.md (#203) commit 3ca3dadf2630e63eb69e2e78a86f4dd27547e957 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 16 10:42:02 2022 -0800 Update Dev Package Version (#201) * enable workflow * bump version for next staging run commit 8f13aef6680180cef8afa2b80859061e56127726 Author: bot-edgepi Date: Thu Dec 15 23:22:09 2022 +0000 Bump version: 1.1.9 → 1.1.10 commit 1ba5f5606e07db62c53bcd4b46cc914be97a479a Merge: b9f816e 9700835 Author: flavius Date: Thu Dec 15 15:20:47 2022 -0800 Merge branch 'dev' into staging commit 970083563304a1b444aaa2dbf9b058c55f3275dd Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Dec 15 15:17:57 2022 -0800 remove integration test workflow (#197) * remove integration test workflow * bump versions due to failed staging run commit b9f816e831225f36bc9015e90fe4b285e3b8ec88 Author: bot-edgepi Date: Thu Dec 15 23:08:00 2022 +0000 Bump version: 1.1.8 → 1.1.9 commit d4f9b30c5ebc7b89669a34d24bdb54f332ef16a6 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Dec 15 15:07:06 2022 -0800 Publishing Workflow Fixes (#196) * Fix Publishing Workflows (#192) * new auto bump method * add release workflow * re-add package build dependencies (#193) * Disable Integration Test Workflow (#195) * change python to python3 * update test path * disable integration test workflow Co-authored-by: bot-edgepi commit 7a444d8993e276356e0f51e00a45e175df5fd2de Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Dec 15 15:01:36 2022 -0800 Disable Integration Test Workflow (#195) * change python to python3 * update test path * disable integration test workflow commit 8e3307220f6472f0ac1f970ae198917b2dc7acaf Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Dec 15 15:00:03 2022 -0800 re-add package build dependencies (#193) commit 5112119c88cc64e16ac3b36cc977c0e65d84ab2d Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Dec 15 14:12:49 2022 -0800 Fix Publishing Workflows (#192) * new auto bump method * add release workflow Co-authored-by: bot-edgepi commit 823931c1efdaa942c28ff67fcdcacea42db9f1eb Merge: 79b70d3 6fc38f4 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 18:10:55 2022 -0800 Merge branch 'main' into staging commit 79b70d301f92338aed4c5484ace96725350fccc9 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 18:08:49 2022 -0800 Fix README (#187) * update README * remove install info from tc readme * TC merge for housekeeping (#44) * add fault status reading * add fault mask configuration * tc module restructuring * update documentation * update decimal bit constants * Tc dev fixes (#36) * refactor fault reading * add human readable Fault printing * add option for less verbose fault reading * filter out normal status Faults * refactor fault masking to set individual masks * Gpio merge for house keeping (#42) * gpio periphery being added * gpio periphery being added * rebase gpio branch * created gpio folder and files and tests * Feature branch git action added, gpio command and constants are added * github action yml changed * testing GPIO * gpio bias keyword takenout * path typeError troubleshooting * gpio in progress #20 * disable push test until fixing the bug * Update gpio.py add all keyword args * Update gpio.py passing arguments without keyword * Update gpio.py * gpio test issue resolved #20 * working on constants * Adc rebased and merge to dev (#43) * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * added workflow for CI, #17 * modifying linting requirements * testing * changed global user and email * user name testing * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * modifying linting requirements * testing * changed global user and email * user name testing * modified readme back to original state Co-authored-by: SJ Park * Update README module links (#45) Adding module link to ADC now that it is merged to dev, and updating other links to use relative link (so it links to folders on the same branch as top-level readme they're being accessed from) * refactor utilities to support non Enum set_config args (#47) * refactor utilities to support non Enum set_config args * added gpio_cofings.py to add configuration data class for dac #40 (#46) * added gpio_cofings.py to add configuration data class for dac #40 * changed function description * PR #46 fixes * steven can't write :( * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * Pytest fix (#57) * Update adc_commands.py updated adc_command to fix the pytest issue * Update adc_commands.py updated adc_command to fix the pytest issue * Edgepi gpio dac config (#55) * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * added mock for testing I2C * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * added mock for testing I2C * combined repetitive dataclass fixed a problem with circular dependency * fixing pytest failures Co-authored-by: flavius-t <77416463+flavius-t@users.noreply.github.com> Co-authored-by: flavius-t * TC Open Circuit (#59) * add open fault detection mode config * Fix Linting (#65) * Fix TestPyPi (#66) * TC Compute Conversion Time (#63) * add compute conversion time * refactor single_sample for time delay computation * update time conv docstrings * inflate time delays * TC Set Temperatures (#60) * add temperature setting to set_config * add cold junction temp override method * add temperature input validation * add update_registers_from_dict and test * add temperature range validation by tc type * add custom exceptions, expand tempcode testing * add convert from DecBits to float * add cold-junction overwrite error * TC Integration Tests (#70) * separate tests to unit and integration * add thermocouple integration tests * refactoring to support tc integration testing * Edgepi gpio transfer (#62) * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * Update edgepi_tc.py the __ was deleted by accident * tests not passing * testing fixed * Update test_edgepi_gpio.py fixed tests * requested changed from Farzad * Todos added * working on todos, changed pin list to be self-explanatory, need to work on __generate_default_reg_dict to be more intuitie * changed naming conventions and using dictionary instead of list for describing pins * fixing pylint * fixing linting issue * fix I2C test and pylint on linux * disabled E1101 to go work around the error from mock class * fixed lint and testing mock * Unit Test Fixes (#74) * separate peripherals testing to unit/integration * testing workflow changes * Edgepi gpio toggle (#75) * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * refactored for-loop test for __write_changed_values is not added since the function doesn't return any value and only execute the transaction * Readme added while working on the readme, i realized the order of AO_ENx pins were reversed. the order is fixed now * Update edgepi_gpio.py for loop replaced with a write change value method * Add Test Coverage (#79) * add code coverage to unit test workflow * add workflow status badges * DAC Interface (#77) * add set channel power mode * add set_gain_mode * add software reset * add readback * add code to voltage * integrate with gpio module * Dac calibration (#84) * refactoring calibration parameter dataclass #9 * changed test fixture for dac_command * calibration parameter refactored * dac calibration refactored * Update test_edgepi_dac.py linter fix * added and edited suggested comments * Calibration module (#92) * #83 creating files * adding unittest * Update test_access_eeprom.py * added unittest & i2c transfer return change * adding calibration mapping and class * Update edgepi_calibration.py todo notes added * pylint fix * code review suggestions * Requested PR fixes - Nomenclature files - Reg address name change -> mem_addr - Device address is a constant now - EEPROM class * ADC Interface (#97) * Adding functions to calibration class (#98) * adding helper class for calibration process * adding functions to generate necessary dictionaries * pylint fixes * Update test_adc_state.py (#100) #99 * Get/Set Individual Pin States (#105) * LED Module (#106) * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * Issue102 dac (#109) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * adding get_state() dac #102 dac get_state is being added * fixed voltage_to_code and code_to_voltage calculation * passing pytest * changed the key from string name to number * changed get_state function #102 osensa/edgepi-device-manager/issues/3 * pylint fix * Issue103 adc (#110) * adc testing being added * added test * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * added todo and fixed pylint * used enums for pin names * Update edgepi_adc.py removed clear exapnder to avoid resetting of Ground reference when a new object is instantiated * Update edgepi_adc.py (#115) * Update edgepi_adc.py To Do added * Update edgepi_adc.py have a ruler set for pylint, and still fails on line-too-long :( * Gpio delete set default (#116) * deleting obsolete function * added unit tests for functions changed gpio pin ordering of DAC module * Loading DAC related Calibration parameter from the EEPROM (#114) * dummy functions added for calibration added logger added generate calib dictionary functions , logics to be implemented * unpacking packing added unpacking: from list of parameter that read from eeprom to a single value packing : from a value to a list of bytes to load to the eeprom * calib dictionary generation for dac * loading calib param added and tested * Update test_edgepi_calibration.py updated the unit test for get_calibration_dict. Other module test cases are deleted for now * PR#114 fix - added a dictionary of functions - added more description to the address constants * Remove ADC Init Configs (#119) * remove configs from adc init * rename to private method * Calibration dac (#120) * Update edgepi_dac.py adding calibration classes, need to check dictionary structure. implement DAC_GAIN parameter maybe needed * DAC calibration updated #111 - loading of calibration parameter from eeprom - generation and get calibration dictionary - check dac_gain state before code2voltage or voltage 2code conversion - conversion formula edited to accommodate the calibration param and dac gain state * set/clear internal DAC gain #76 * Update edgepi_dac.py PR #120 suggested fix * constant name change PR #120 suggested fix * ADC Differential Reads, RTD Mode (#118) * remove unused duplicate channel assignment code * fix pytest discovery error * add SPI debugging logs * change rtd_enabled check logic * diff read constants * rtd property check, set diff mode * unit test validate_no_rtd_conflict * unit test select_differential * ignore local test scripts * documentation additions * opcodes for RTD mode * doc updates, pytest config * unit test IDACMUX opcodes * unit test IDACMAG opcodes * fix IDACMAG opcode bug * fix REFMUX opcode bug * expand REFMUX opcode unit tests, renaming * uncomment adc config integration tests * integration test IDACMUX opcodes * integration test IDACMAG opcodes * integration test REFMUX opcodes * integration test select_differential * add idac channel 9 * fix opcode name, failing unit test * add rtd mode enums * add rtd_mode, todos for get_state with caching * rename __get_rtd_en_status * fix rtd_mode logic, unit test * integration test rtd_mode, fix bug * Remap ADC Multiplexers (#122) * mux mapping set mux_n to AINCOM * refactor mux arg handling in __config * refactor None checking, update docstring * remove temporary test fix * remove unnecessary test cases * I2C set_msg function takes list of addresses (#128) * #127 added another type for addr parameter of set_read_msg and set_write_msg to accomodate a list of addresses * | was introduced in python 3.10 but the test automation is using python 3.9 * Calibration suggestion (#129) * Nov1 code review suggestions * refactoring eeprom access module to accomodate the hardware change * EEPROM class is refactored to accomodate the larger memory size #125 * pylint fix * Eeprom protobuf (#131) * protobuf implementation #126 #124 * test added * pylint fix and update dependencies * Update requirements_test.txt * delete Todos * suggested fixes * suggested name fix * generate_calib_param dictionary added (#134) * generate_calib_param dictionary added * pytest fix * suggested fix - calib_params nomenclature - better description for docstring * suggest fix - calib param dataclass formation done in eeprom class - removed redundant methods and tests * ADC Get State (#132) * refactor get_state to EdgePiADC * refactor ADCModes * add get_register_map * use get_register_map for internal register reads * refactor ADCState * use new ADCState for getting state internally * add get mux states * refactor state query constants to module * ADC Calibration (#138) * added eeprom reading to load calibration parameter * diff/individual voltage read calibration handling #133 Co-authored-by: sjpark608 * fixed typing issue (#136) #135 added test cases for checking the type * Add ADC2 (#139) * add adc-2 to voltage reads, set_config * dac conversion formula change (#146) * dac conversion formula change #143 #144 - added updated serialized file for testing - updated formula for voltage2code code2voltage - updated unittest - added serialized read helper file - deleted outdated dac_calibration files * pylint fix * DAC Enum Args (#152) * refactor user interface to enum channel args * GPIO refactoring in progress (#156) * gpio module refactored #153 * adding test cases fixing typos * gpio module refactor adding edgpi gpio test * fix suggestions * RTD Sampling (#160) * Hardware Tests (#162) * voltage read-write test * add test report to gitignore * custom approx comparator * move adc conversion time tests * update hardware test instructions * move integration tests to new folder * diff voltage tests * add adc_2 diff test * add rtd tests * bypass rtd validation in mux mapping * fix rtd temp calculation bug * GPIO module refactoring intermediate PR (#161) * refactoring generating pin dictionary to have generic dictionary #154 #155 * generic object instantiation #154 #155 * Update test_dac.py dict_pin changed to expander_pin_dict after refactor * lint fix * Gpio refactor 154 (#167) * added gpio exception, gpio write, need some testing on the hardware #166 #154 #155 * added set direction in out function, get direction function * edgepi gpio methods gets enum values typed string * changed function name used in different modules * fixed pytest and pylint issues * added toggle pin * deleted unused module * PR #167 suggested fix - added __pin_name_check() - added more tests * GPIO DOUT pin list re-order (#169) * Update gpio_configs.py Forgotten change * fixed LED integration test * Get State Override Cache (#175) * add override cache to get state * Fix Read Voltage Validation (#176) * fix conv mode validation in read_voltage * Digital input module (#173) * adding din module and tests * Digital input reading #170 * Added test parameters * added exception and testing * digital out module #171 (#172) * Main README Update (#181) * Update README.md * update sdk package naming * update version num * added README and re-naming module (#182) * LED Module README (#183) * Create README.md * Update README.md * Fix README (#186) Co-authored-by: sjpark608 <78987042+sjpark608@users.noreply.github.com> Co-authored-by: SJ Park Co-authored-by: sjpark608 commit dcce9d8a95f9a8d14ad7894c7f38c72aee460e24 Merge: f64498e 00b0630 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 18:07:36 2022 -0800 Merge branch 'staging' into dev commit f64498ee080cdb2c25bd9c280ec6a1b5f2832f02 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 18:05:29 2022 -0800 Fix README (#186) commit 00b063000ef39950df224b770117a2f42fa80d16 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 17:43:12 2022 -0800 Publish SDK (#184) * update README * remove install info from tc readme * TC merge for housekeeping (#44) * add fault status reading * add fault mask configuration * tc module restructuring * update documentation * update decimal bit constants * Tc dev fixes (#36) * refactor fault reading * add human readable Fault printing * add option for less verbose fault reading * filter out normal status Faults * refactor fault masking to set individual masks * Gpio merge for house keeping (#42) * gpio periphery being added * gpio periphery being added * rebase gpio branch * created gpio folder and files and tests * Feature branch git action added, gpio command and constants are added * github action yml changed * testing GPIO * gpio bias keyword takenout * path typeError troubleshooting * gpio in progress #20 * disable push test until fixing the bug * Update gpio.py add all keyword args * Update gpio.py passing arguments without keyword * Update gpio.py * gpio test issue resolved #20 * working on constants * Adc rebased and merge to dev (#43) * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * added workflow for CI, #17 * modifying linting requirements * testing * changed global user and email * user name testing * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * modifying linting requirements * testing * changed global user and email * user name testing * modified readme back to original state Co-authored-by: SJ Park * Update README module links (#45) Adding module link to ADC now that it is merged to dev, and updating other links to use relative link (so it links to folders on the same branch as top-level readme they're being accessed from) * refactor utilities to support non Enum set_config args (#47) * refactor utilities to support non Enum set_config args * added gpio_cofings.py to add configuration data class for dac #40 (#46) * added gpio_cofings.py to add configuration data class for dac #40 * changed function description * PR #46 fixes * steven can't write :( * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * Pytest fix (#57) * Update adc_commands.py updated adc_command to fix the pytest issue * Update adc_commands.py updated adc_command to fix the pytest issue * Edgepi gpio dac config (#55) * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * added mock for testing I2C * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * added mock for testing I2C * combined repetitive dataclass fixed a problem with circular dependency * fixing pytest failures Co-authored-by: flavius-t <77416463+flavius-t@users.noreply.github.com> Co-authored-by: flavius-t * TC Open Circuit (#59) * add open fault detection mode config * Fix Linting (#65) * Fix TestPyPi (#66) * TC Compute Conversion Time (#63) * add compute conversion time * refactor single_sample for time delay computation * update time conv docstrings * inflate time delays * TC Set Temperatures (#60) * add temperature setting to set_config * add cold junction temp override method * add temperature input validation * add update_registers_from_dict and test * add temperature range validation by tc type * add custom exceptions, expand tempcode testing * add convert from DecBits to float * add cold-junction overwrite error * TC Integration Tests (#70) * separate tests to unit and integration * add thermocouple integration tests * refactoring to support tc integration testing * Edgepi gpio transfer (#62) * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * Update edgepi_tc.py the __ was deleted by accident * tests not passing * testing fixed * Update test_edgepi_gpio.py fixed tests * requested changed from Farzad * Todos added * working on todos, changed pin list to be self-explanatory, need to work on __generate_default_reg_dict to be more intuitie * changed naming conventions and using dictionary instead of list for describing pins * fixing pylint * fixing linting issue * fix I2C test and pylint on linux * disabled E1101 to go work around the error from mock class * fixed lint and testing mock * Unit Test Fixes (#74) * separate peripherals testing to unit/integration * testing workflow changes * Edgepi gpio toggle (#75) * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * refactored for-loop test for __write_changed_values is not added since the function doesn't return any value and only execute the transaction * Readme added while working on the readme, i realized the order of AO_ENx pins were reversed. the order is fixed now * Update edgepi_gpio.py for loop replaced with a write change value method * Add Test Coverage (#79) * add code coverage to unit test workflow * add workflow status badges * DAC Interface (#77) * add set channel power mode * add set_gain_mode * add software reset * add readback * add code to voltage * integrate with gpio module * Dac calibration (#84) * refactoring calibration parameter dataclass #9 * changed test fixture for dac_command * calibration parameter refactored * dac calibration refactored * Update test_edgepi_dac.py linter fix * added and edited suggested comments * Calibration module (#92) * #83 creating files * adding unittest * Update test_access_eeprom.py * added unittest & i2c transfer return change * adding calibration mapping and class * Update edgepi_calibration.py todo notes added * pylint fix * code review suggestions * Requested PR fixes - Nomenclature files - Reg address name change -> mem_addr - Device address is a constant now - EEPROM class * ADC Interface (#97) * Adding functions to calibration class (#98) * adding helper class for calibration process * adding functions to generate necessary dictionaries * pylint fixes * Update test_adc_state.py (#100) #99 * Get/Set Individual Pin States (#105) * LED Module (#106) * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * Issue102 dac (#109) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * adding get_state() dac #102 dac get_state is being added * fixed voltage_to_code and code_to_voltage calculation * passing pytest * changed the key from string name to number * changed get_state function #102 osensa/edgepi-device-manager/issues/3 * pylint fix * Issue103 adc (#110) * adc testing being added * added test * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * added todo and fixed pylint * used enums for pin names * Update edgepi_adc.py removed clear exapnder to avoid resetting of Ground reference when a new object is instantiated * Update edgepi_adc.py (#115) * Update edgepi_adc.py To Do added * Update edgepi_adc.py have a ruler set for pylint, and still fails on line-too-long :( * Gpio delete set default (#116) * deleting obsolete function * added unit tests for functions changed gpio pin ordering of DAC module * Loading DAC related Calibration parameter from the EEPROM (#114) * dummy functions added for calibration added logger added generate calib dictionary functions , logics to be implemented * unpacking packing added unpacking: from list of parameter that read from eeprom to a single value packing : from a value to a list of bytes to load to the eeprom * calib dictionary generation for dac * loading calib param added and tested * Update test_edgepi_calibration.py updated the unit test for get_calibration_dict. Other module test cases are deleted for now * PR#114 fix - added a dictionary of functions - added more description to the address constants * Remove ADC Init Configs (#119) * remove configs from adc init * rename to private method * Calibration dac (#120) * Update edgepi_dac.py adding calibration classes, need to check dictionary structure. implement DAC_GAIN parameter maybe needed * DAC calibration updated #111 - loading of calibration parameter from eeprom - generation and get calibration dictionary - check dac_gain state before code2voltage or voltage 2code conversion - conversion formula edited to accommodate the calibration param and dac gain state * set/clear internal DAC gain #76 * Update edgepi_dac.py PR #120 suggested fix * constant name change PR #120 suggested fix * ADC Differential Reads, RTD Mode (#118) * remove unused duplicate channel assignment code * fix pytest discovery error * add SPI debugging logs * change rtd_enabled check logic * diff read constants * rtd property check, set diff mode * unit test validate_no_rtd_conflict * unit test select_differential * ignore local test scripts * documentation additions * opcodes for RTD mode * doc updates, pytest config * unit test IDACMUX opcodes * unit test IDACMAG opcodes * fix IDACMAG opcode bug * fix REFMUX opcode bug * expand REFMUX opcode unit tests, renaming * uncomment adc config integration tests * integration test IDACMUX opcodes * integration test IDACMAG opcodes * integration test REFMUX opcodes * integration test select_differential * add idac channel 9 * fix opcode name, failing unit test * add rtd mode enums * add rtd_mode, todos for get_state with caching * rename __get_rtd_en_status * fix rtd_mode logic, unit test * integration test rtd_mode, fix bug * Remap ADC Multiplexers (#122) * mux mapping set mux_n to AINCOM * refactor mux arg handling in __config * refactor None checking, update docstring * remove temporary test fix * remove unnecessary test cases * I2C set_msg function takes list of addresses (#128) * #127 added another type for addr parameter of set_read_msg and set_write_msg to accomodate a list of addresses * | was introduced in python 3.10 but the test automation is using python 3.9 * Calibration suggestion (#129) * Nov1 code review suggestions * refactoring eeprom access module to accomodate the hardware change * EEPROM class is refactored to accomodate the larger memory size #125 * pylint fix * Eeprom protobuf (#131) * protobuf implementation #126 #124 * test added * pylint fix and update dependencies * Update requirements_test.txt * delete Todos * suggested fixes * suggested name fix * generate_calib_param dictionary added (#134) * generate_calib_param dictionary added * pytest fix * suggested fix - calib_params nomenclature - better description for docstring * suggest fix - calib param dataclass formation done in eeprom class - removed redundant methods and tests * ADC Get State (#132) * refactor get_state to EdgePiADC * refactor ADCModes * add get_register_map * use get_register_map for internal register reads * refactor ADCState * use new ADCState for getting state internally * add get mux states * refactor state query constants to module * ADC Calibration (#138) * added eeprom reading to load calibration parameter * diff/individual voltage read calibration handling #133 Co-authored-by: sjpark608 * fixed typing issue (#136) #135 added test cases for checking the type * Add ADC2 (#139) * add adc-2 to voltage reads, set_config * dac conversion formula change (#146) * dac conversion formula change #143 #144 - added updated serialized file for testing - updated formula for voltage2code code2voltage - updated unittest - added serialized read helper file - deleted outdated dac_calibration files * pylint fix * DAC Enum Args (#152) * refactor user interface to enum channel args * GPIO refactoring in progress (#156) * gpio module refactored #153 * adding test cases fixing typos * gpio module refactor adding edgpi gpio test * fix suggestions * RTD Sampling (#160) * Hardware Tests (#162) * voltage read-write test * add test report to gitignore * custom approx comparator * move adc conversion time tests * update hardware test instructions * move integration tests to new folder * diff voltage tests * add adc_2 diff test * add rtd tests * bypass rtd validation in mux mapping * fix rtd temp calculation bug * GPIO module refactoring intermediate PR (#161) * refactoring generating pin dictionary to have generic dictionary #154 #155 * generic object instantiation #154 #155 * Update test_dac.py dict_pin changed to expander_pin_dict after refactor * lint fix * Gpio refactor 154 (#167) * added gpio exception, gpio write, need some testing on the hardware #166 #154 #155 * added set direction in out function, get direction function * edgepi gpio methods gets enum values typed string * changed function name used in different modules * fixed pytest and pylint issues * added toggle pin * deleted unused module * PR #167 suggested fix - added __pin_name_check() - added more tests * GPIO DOUT pin list re-order (#169) * Update gpio_configs.py Forgotten change * fixed LED integration test * Get State Override Cache (#175) * add override cache to get state * Fix Read Voltage Validation (#176) * fix conv mode validation in read_voltage * Digital input module (#173) * adding din module and tests * Digital input reading #170 * Added test parameters * added exception and testing * digital out module #171 (#172) * Main README Update (#181) * Update README.md * update sdk package naming * update version num * added README and re-naming module (#182) * LED Module README (#183) * Create README.md * Update README.md Co-authored-by: sjpark608 <78987042+sjpark608@users.noreply.github.com> Co-authored-by: SJ Park Co-authored-by: sjpark608 commit 8e28a18f2475c2c60b198f3868f7b5b44a342e30 Merge: 521ab5a 5e10ef2 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 17:39:10 2022 -0800 Merge branch 'staging' into dev commit 521ab5aa8195db27f9abfa4bde059fcab4c0f82c Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 17:32:54 2022 -0800 LED Module README (#183) * Create README.md * Update README.md commit 5c4521b6b018e3381ca081e011adef229a09659d Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Tue Dec 13 17:31:54 2022 -0800 added README and re-naming module (#182) commit d569548bcf4d7f0c96a1929f8a94a395b70ab520 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 15:48:29 2022 -0800 Main README Update (#181) * Update README.md * update sdk package naming * update version num commit 8abe121ec609643d52ad47739d1608f27c520edb Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Tue Dec 13 15:14:57 2022 -0800 digital out module #171 (#172) commit 7d41626b475cf37fab374819370ce885a12b0a84 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Tue Dec 13 15:14:34 2022 -0800 Digital input module (#173) * adding din module and tests * Digital input reading #170 * Added test parameters * added exception and testing commit 903d86cf40d94c633c58c04ea0d25e71d5fd1255 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Dec 13 14:50:37 2022 -0800 Fix Read Voltage Validation (#176) * fix conv mode validation in read_voltage commit 7992c80f507878b662ecabd1f71de0fbc18bbe7c Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Dec 12 13:01:38 2022 -0800 Get State Override Cache (#175) * add override cache to get state commit be9ed27582c5865240410bb3c51f207ac81b5bf7 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Dec 8 14:50:43 2022 -0800 GPIO DOUT pin list re-order (#169) * Update gpio_configs.py Forgotten change * fixed LED integration test commit 7c5cd6a6e7ed91a2c4525ae93727f2433c5c4576 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Dec 8 11:34:25 2022 -0800 Gpio refactor 154 (#167) * added gpio exception, gpio write, need some testing on the hardware #166 #154 #155 * added set direction in out function, get direction function * edgepi gpio methods gets enum values typed string * changed function name used in different modules * fixed pytest and pylint issues * added toggle pin * deleted unused module * PR #167 suggested fix - added __pin_name_check() - added more tests commit c18b9630a78a1a11e611ad406a53c2b3ced1c759 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Dec 2 17:20:40 2022 -0800 GPIO module refactoring intermediate PR (#161) * refactoring generating pin dictionary to have generic dictionary #154 #155 * generic object instantiation #154 #155 * Update test_dac.py dict_pin changed to expander_pin_dict after refactor * lint fix commit 4ac13b02a2db24b5336c3e7dc32ce9a08ae6c7a0 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Dec 2 11:29:13 2022 -0800 Hardware Tests (#162) * voltage read-write test * add test report to gitignore * custom approx comparator * move adc conversion time tests * update hardware test instructions * move integration tests to new folder * diff voltage tests * add adc_2 diff test * add rtd tests * bypass rtd validation in mux mapping * fix rtd temp calculation bug commit e2538aa44c17d931a5d30a3b4266c3c2209d3b11 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Dec 1 10:32:43 2022 -0800 RTD Sampling (#160) commit 199f8442fa76303968857737fce5e9aedee27398 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Mon Nov 28 21:14:23 2022 -0800 GPIO refactoring in progress (#156) * gpio module refactored #153 * adding test cases fixing typos * gpio module refactor adding edgpi gpio test * fix suggestions commit 7530956e70b92b6f610145f2b5226f5e165adf60 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Nov 23 11:18:18 2022 -0800 DAC Enum Args (#152) * refactor user interface to enum channel args commit 96a98f8812056e94e9aa40873a0b2193b3a885af Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Wed Nov 23 09:51:14 2022 -0800 dac conversion formula change (#146) * dac conversion formula change #143 #144 - added updated serialized file for testing - updated formula for voltage2code code2voltage - updated unittest - added serialized read helper file - deleted outdated dac_calibration files * pylint fix commit 5404dc25082f111b4dabfeb6ea7d3b5435290918 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Nov 22 12:58:14 2022 -0800 Add ADC2 (#139) * add adc-2 to voltage reads, set_config commit 6ae2a20aced1cf99401e5af27cbf09bd5ad04ebc Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Tue Nov 22 11:26:58 2022 -0800 fixed typing issue (#136) #135 added test cases for checking the type commit 880165345a7a409a03db4a53cce9194897c6461d Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Nov 22 11:25:02 2022 -0800 ADC Calibration (#138) * added eeprom reading to load calibration parameter * diff/individual voltage read calibration handling #133 Co-authored-by: sjpark608 commit ce617cadc6f599b6e707d13a9f2e34c8b8278092 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Nov 18 16:50:12 2022 -0800 ADC Get State (#132) * refactor get_state to EdgePiADC * refactor ADCModes * add get_register_map * use get_register_map for internal register reads * refactor ADCState * use new ADCState for getting state internally * add get mux states * refactor state query constants to module commit 84e38fff33996933cd65c215b97d3b93924ac9a7 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Nov 17 18:13:58 2022 -0800 generate_calib_param dictionary added (#134) * generate_calib_param dictionary added * pytest fix * suggested fix - calib_params nomenclature - better description for docstring * suggest fix - calib param dataclass formation done in eeprom class - removed redundant methods and tests commit 0cd8d59de2de19def005b57a2554d89acf314e48 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Wed Nov 16 15:21:10 2022 -0800 Eeprom protobuf (#131) * protobuf implementation #126 #124 * test added * pylint fix and update dependencies * Update requirements_test.txt * delete Todos * suggested fixes * suggested name fix commit 1864d83e6b9d5ae7d27f068481fa21ffdb69af34 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Nov 10 14:42:02 2022 -0800 Calibration suggestion (#129) * Nov1 code review suggestions * refactoring eeprom access module to accomodate the hardware change * EEPROM class is refactored to accomodate the larger memory size #125 * pylint fix commit 029d8e05e743f0dad45212e1295983314c20628a Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Nov 10 10:42:44 2022 -0800 I2C set_msg function takes list of addresses (#128) * #127 added another type for addr parameter of set_read_msg and set_write_msg to accomodate a list of addresses * | was introduced in python 3.10 but the test automation is using python 3.9 commit 53bc029d9bc49d08691fb6a2a7c9e25672912176 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Nov 8 15:44:26 2022 -0800 Remap ADC Multiplexers (#122) * mux mapping set mux_n to AINCOM * refactor mux arg handling in __config * refactor None checking, update docstring * remove temporary test fix * remove unnecessary test cases commit b494d979b77c81aeb0cff82cea7c53519dfc08ba Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Nov 7 10:05:28 2022 -0800 ADC Differential Reads, RTD Mode (#118) * remove unused duplicate channel assignment code * fix pytest discovery error * add SPI debugging logs * change rtd_enabled check logic * diff read constants * rtd property check, set diff mode * unit test validate_no_rtd_conflict * unit test select_differential * ignore local test scripts * documentation additions * opcodes for RTD mode * doc updates, pytest config * unit test IDACMUX opcodes * unit test IDACMAG opcodes * fix IDACMAG opcode bug * fix REFMUX opcode bug * expand REFMUX opcode unit tests, renaming * uncomment adc config integration tests * integration test IDACMUX opcodes * integration test IDACMAG opcodes * integration test REFMUX opcodes * integration test select_differential * add idac channel 9 * fix opcode name, failing unit test * add rtd mode enums * add rtd_mode, todos for get_state with caching * rename __get_rtd_en_status * fix rtd_mode logic, unit test * integration test rtd_mode, fix bug commit 3b7bd1425bb7e5c4a4c3af63d7e69db44f5df22a Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Nov 4 13:48:04 2022 -0700 Calibration dac (#120) * Update edgepi_dac.py adding calibration classes, need to check dictionary structure. implement DAC_GAIN parameter maybe needed * DAC calibration updated #111 - loading of calibration parameter from eeprom - generation and get calibration dictionary - check dac_gain state before code2voltage or voltage 2code conversion - conversion formula edited to accommodate the calibration param and dac gain state * set/clear internal DAC gain #76 * Update edgepi_dac.py PR #120 suggested fix * constant name change PR #120 suggested fix commit 9307713e49986d25835126c7da162d9ee10b7c29 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Nov 4 11:27:30 2022 -0700 Remove ADC Init Configs (#119) * remove configs from adc init * rename to private method commit 574f7ae7ab42b0fd83cec32559f3b6c7846ffb53 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Mon Oct 31 12:50:12 2022 -0700 Loading DAC related Calibration parameter from the EEPROM (#114) * dummy functions added for calibration added logger added generate calib dictionary functions , logics to be implemented * unpacking packing added unpacking: from list of parameter that read from eeprom to a single value packing : from a value to a list of bytes to load to the eeprom * calib dictionary generation for dac * loading calib param added and tested * Update test_edgepi_calibration.py updated the unit test for get_calibration_dict. Other module test cases are deleted for now * PR#114 fix - added a dictionary of functions - added more description to the address constants commit c8c02d7277c87746b00d86035416e02963af5ded Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Mon Oct 31 10:48:12 2022 -0700 Gpio delete set default (#116) * deleting obsolete function * added unit tests for functions changed gpio pin ordering of DAC module commit 620ff9b5bfa783e28cdd6e11ae47e6d74d4bcfb7 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Oct 28 15:46:39 2022 -0700 Update edgepi_adc.py (#115) * Update edgepi_adc.py To Do added * Update edgepi_adc.py have a ruler set for pylint, and still fails on line-too-long :( commit ec507bf1d544dcd68ced027a7ca6819fd2ccb4d9 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Oct 28 11:57:00 2022 -0700 Issue103 adc (#110) * adc testing being added * added test * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * added todo and fixed pylint * used enums for pin names * Update edgepi_adc.py removed clear exapnder to avoid resetting of Ground reference when a new object is instantiated commit 12b6d7948b2f0049dcbabd9731bbd9d952a44547 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Oct 27 11:08:43 2022 -0700 Issue102 dac (#109) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * adding get_state() dac #102 dac get_state is being added * fixed voltage_to_code and code_to_voltage calculation * passing pytest * changed the key from string name to number * changed get_state function #102 osensa/edgepi-device-manager/issues/3 * pylint fix commit 05e4f6f7184a42208bc8c436254d5770f8c40dc4 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Wed Oct 26 10:37:18 2022 -0700 Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix commit bde0f95539ded9c794f3015eaa88432e2f2b7f8f Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Oct 19 15:46:01 2022 -0700 LED Module (#106) commit f3efa759f6dee78689a74a99f11b1f96656b3709 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Oct 19 12:41:47 2022 -0700 Get/Set Individual Pin States (#105) commit 0f01e33167fcee27958159190c55428c683fbf10 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Wed Oct 5 15:38:37 2022 -0700 Update test_adc_state.py (#100) #99 commit ab02437422b6341932cdb9b778190f8b86c3e834 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Wed Oct 5 11:41:11 2022 -0700 Adding functions to calibration class (#98) * adding helper class for calibration process * adding functions to generate necessary dictionaries * pylint fixes commit 5c60766fe8d1f105d91fc00ccf800fb911425ba6 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Oct 3 14:18:03 2022 -0700 ADC Interface (#97) commit be0834dbc1d9e33ebe644e70f5d7bb87e4229796 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Sep 30 16:05:41 2022 -0700 Calibration module (#92) * #83 creating files * adding unittest * Update test_access_eeprom.py * added unittest & i2c transfer return change * adding calibration mapping and class * Update edgepi_calibration.py todo notes added * pylint fix * code review suggestions * Requested PR fixes - Nomenclature files - Reg address name change -> mem_addr - Device address is a constant now - EEPROM class commit cbdf1e3fed30f959a7a727475ebfaedf6af17c57 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Wed Aug 3 17:44:46 2022 -0700 Dac calibration (#84) * refactoring calibration parameter dataclass #9 * changed test fixture for dac_command * calibration parameter refactored * dac calibration refactored * Update test_edgepi_dac.py linter fix * added and edited suggested comments commit 0c1753f8c263082c129fbace74ffdc68460b39b9 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jul 28 17:00:14 2022 -0700 DAC Interface (#77) * add set channel power mode * add set_gain_mode * add software reset * add readback * add code to voltage * integrate with gpio module commit 669f85df5cee14eace388136f5c94e286d05a86f Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Jul 26 14:57:44 2022 -0700 Add Test Coverage (#79) * add code coverage to unit test workflow * add workflow status badges commit 38592b88647f695a79d7da5b6d30467222382d1c Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Mon Jul 25 09:14:53 2022 -0700 Edgepi gpio toggle (#75) * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * refactored for-loop test for __write_changed_values is not added since the function doesn't return any value and only execute the transaction * Readme added while working on the readme, i realized the order of AO_ENx pins were reversed. the order is fixed now * Update edgepi_gpio.py for loop replaced with a write change value method commit 6654a162a240bb43d85d627b814bb2b98bfac074 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Jul 22 14:36:30 2022 -0700 Unit Test Fixes (#74) * separate peripherals testing to unit/integration * testing workflow changes commit f4e458789d71f9bb6305083e988e5f95362b4651 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Jul 22 10:31:50 2022 -0700 Edgepi gpio transfer (#62) * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * Update edgepi_tc.py the __ was deleted by accident * tests not passing * testing fixed * Update test_edgepi_gpio.py fixed tests * requested changed from Farzad * Todos added * working on todos, changed pin list to be self-explanatory, need to work on __generate_default_reg_dict to be more intuitie * changed naming conventions and using dictionary instead of list for describing pins * fixing pylint * fixing linting issue * fix I2C test and pylint on linux * disabled E1101 to go work around the error from mock class * fixed lint and testing mock commit 413752671fc183d91ed12a3f71dcad4bc4c5d79a Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Jul 20 14:14:29 2022 -0700 TC Integration Tests (#70) * separate tests to unit and integration * add thermocouple integration tests * refactoring to support tc integration testing commit 030dedc8fca5dfc3d1f486dc502faa47239bbe74 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jul 11 16:25:14 2022 -0700 TC Set Temperatures (#60) * add temperature setting to set_config * add cold junction temp override method * add temperature input validation * add update_registers_from_dict and test * add temperature range validation by tc type * add custom exceptions, expand tempcode testing * add convert from DecBits to float * add cold-junction overwrite error commit c61240b8d36a1b7b6ec5771f951f1b39d3157eb8 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jul 11 09:51:15 2022 -0700 TC Compute Conversion Time (#63) * add compute conversion time * refactor single_sample for time delay computation * update time conv docstrings * inflate time delays commit 53716ac67a24fdad6755b2680ab821a892f7acc4 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Jul 8 17:17:42 2022 -0700 Fix TestPyPi (#66) commit c87a019af1fddfdf81efa26986eaef461b81d61d Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jul 7 15:31:40 2022 -0700 Fix Linting (#65) commit a3162e34576ecc8d92597ef1d0ebb1e01961bd93 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jun 30 10:55:51 2022 -0700 TC Open Circuit (#59) * add open fault detection mode config commit df3a8748641e4cd224c93f70b9956372678c14a8 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Tue Jun 28 09:55:25 2022 -0700 Edgepi gpio dac config (#55) * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * added mock for testing I2C * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * added mock for testing I2C * combined repetitive dataclass fixed a problem with circular dependency * fixing pytest failures Co-authored-by: flavius-t <77416463+flavius-t@users.noreply.github.com> Co-authored-by: flavius-t commit 2658848a34608600336c71bcd20151677cee3e7a Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Mon Jun 27 16:50:57 2022 -0700 Pytest fix (#57) * Update adc_commands.py updated adc_command to fix the pytest issue * Update adc_commands.py updated adc_command to fix the pytest issue commit 2214dfade2c92e1f272f5989f7788c3fcf9651d5 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jun 27 16:06:54 2022 -0700 add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow commit c1f4d7de41989ccc215778203824ae6ab669ab9b Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jun 27 15:38:50 2022 -0700 filter_dict by value (#53) commit 3aa534e4a5c529e82a9335c7d4e802108d4f0628 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Fri Jun 24 13:50:01 2022 -0700 added gpio_cofings.py to add configuration data class for dac #40 (#46) * added gpio_cofings.py to add configuration data class for dac #40 * changed function description * PR #46 fixes * steven can't write :( commit 95c81c68cd954e2aa6bb06b616a1fdd279769d23 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Jun 24 13:49:28 2022 -0700 refactor utilities to support non Enum set_config args (#47) * refactor utilities to support non Enum set_config args commit be55cbc6c2c5d829f661ee248de325bd001c37b0 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jun 23 15:24:28 2022 -0700 Update README module links (#45) Adding module link to ADC now that it is merged to dev, and updating other links to use relative link (so it links to folders on the same branch as top-level readme they're being accessed from) commit 7ef3c892a4fb93b2ba4919da646a7c9d808103b7 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Jun 23 14:12:03 2022 -0700 Adc rebased and merge to dev (#43) * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * added workflow for CI, #17 * modifying linting requirements * testing * changed global user and email * user name testing * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * modifying linting requirements * testing * changed global user and email * user name testing * modified readme back to original state Co-authored-by: SJ Park commit 9f9c874a2c1efd5e0b69967c7fabc8dc5d790e31 Author: sjpark608 <78987042+sjpark608@users.noreply.github.com> Date: Thu Jun 23 14:11:46 2022 -0700 Gpio merge for house keeping (#42) * gpio periphery being added * gpio periphery being added * rebase gpio branch * created gpio folder and files and tests * Feature branch git action added, gpio command and constants are added * github action yml changed * testing GPIO * gpio bias keyword takenout * path typeError troubleshooting * gpio in progress #20 * disable push test until fixing the bug * Update gpio.py add all keyword args * Update gpio.py passing arguments without keyword * Update gpio.py * gpio test issue resolved #20 * working on constants commit 454c8a5d1152d3b1d799de13a07470132bb81c71 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jun 23 14:11:15 2022 -0700 TC merge for housekeeping (#44) * add fault status reading * add fault mask configuration * tc module restructuring * update documentation * update decimal bit constants * Tc dev fixes (#36) * refactor fault reading * add human readable Fault printing * add option for less verbose fault reading * filter out normal status Faults * refactor fault masking to set individual masks commit 088be2c38b767141773da677bbd5feb4748d148e Merge: 0aaf792 6ee4ec6 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Jun 21 14:28:22 2022 -0700 Merge pull request #35 from osensa/readme-fixes update README commit 6ee4ec63bc705758ae84659b85bd52dc6dfb9252 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Jun 21 14:14:18 2022 -0700 remove install info from tc readme commit e13cfb360d2d0fbcc031d2fb568674adab721b3d Author: flavius-t Date: Tue Jun 21 20:41:19 2022 +0100 update README commit 5e10ef2c5a2c7627baadbf8859fa1d23b21f0c79 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jun 20 13:18:53 2022 -0700 Update README.md commit e832a847e2689ff41c5f32fc0bc4e611ba8802f5 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jun 20 13:18:27 2022 -0700 Update README.md commit 1f10130d9468e4aee869af7e790dd54f7313203d Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jun 20 13:09:04 2022 -0700 Update README.md commit ff8b06a3e4dc0aa1a20f5c9ba110e4bec003d07d Author: flavius-t Date: Mon Jun 20 19:16:50 2022 +0100 update package version commit cc3c0620b0b28735c5cba6c969ce6ea54cff4194 Author: flavius-t Date: Mon Jun 20 17:47:45 2022 +0100 update README commit 0aaf792ad417c6ca1d01b30eb137e0a12e8c190c Merge: e04099f 4ce46f7 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri Jun 17 17:47:20 2022 -0700 Merge pull request #28 from osensa/dev-fixes Dev fixes commit 4ce46f78d500aee244e5d51f6104930460cd1602 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jun 16 16:52:29 2022 -0700 Update README.md commit 110aecb22dc7e8536594b25f5511f290daff5ef2 Author: flavius-t Date: Fri Jun 17 00:48:29 2022 +0100 update requirements commit b01af9def90772ac2ab967fab4b6a1ce9b57f355 Author: flavius-t Date: Fri Jun 17 00:48:06 2022 +0100 abstract out hardware from edgepi_tc tests commit 0752a8e0783f6fddc64cc7fc2894de424325b3b8 Merge: 0f2897e e04099f Author: flavius-t Date: Thu Jun 16 20:39:31 2022 +0100 Merge branch 'dev' of github.com:osensa/edgepi-python-sdk into TC commit 0f2897e7380140270421ce1bd20bb0a7a45cf6f8 Author: flavius-t Date: Sat Jun 4 00:44:18 2022 +0100 add temperature sampling commit 0028994c25004d59aa5824a80353f074bcfd8462 Author: flavius-t Date: Fri Jun 3 18:07:12 2022 +0100 change workflows to dev branch only commit f5cefe0a5e23f16205d09a5ca832bf0b2161c472 Author: flavius-t Date: Fri Jun 3 17:41:08 2022 +0100 refactor unit testing workflow commit 9c7ab987f20c52902a10844e98b37c051c5f90fb Author: flavius-t Date: Fri Jun 3 01:00:20 2022 +0100 add update code generation for cr1 commit 2a4a4a7a3ee1adcd192a64432b2bca1a31a277e5 Author: flavius-t Date: Thu Jun 2 19:55:42 2022 +0100 refactor set_config with helper methods commit c7de215b4115cf313280536111c54f4d8cbe0b58 Author: flavius-t Date: Thu Jun 2 00:53:10 2022 +0100 refactor register reading commit 061c89bef6dad9f421489ae972ccb38ede6da640 Author: flavius-t Date: Wed Jun 1 23:41:44 2022 +0100 add gpiozero requirement until spi transfer fixed commit f7dc2abcf544aa81019cad6c324e75c5e2eb8297 Author: flavius-t Date: Wed Jun 1 23:40:11 2022 +0100 refactor mock spi transfer to library commit b4ed79d9f73772a2b0091d05a91f89ca60af75f5 Author: flavius-t Date: Wed Jun 1 23:23:38 2022 +0100 spi transfer issue debugging, and mock transfer commit a7a7f4d1251cb1c01e77d74ed5cd2fa9d953db40 Author: flavius-t Date: Mon May 30 23:52:56 2022 +0100 debug refactoring commit 90d3f48661a916b46bfd8fc0685b2c05ecc7969f Author: flavius-t Date: Mon May 30 18:46:19 2022 +0100 refactor update code generate methods commit d4bc2a08ed7b668f5fe28ea80be68b6a0b7da0a6 Author: flavius-t Date: Sat May 28 01:16:02 2022 +0100 add method for generating cr0 write command commit b5cc1ad42ddd7ee09333d3ee3d5faf583a3fe725 Author: flavius-t Date: Fri May 27 23:04:04 2022 +0100 add collective configuration method commit 1016f7e51df6d4f7c001c9ef69bfb2a32a78594c Author: flavius-t Date: Fri May 27 19:45:42 2022 +0100 add opcode to register mapping commit 78d5b33c1db58fb4eacb221e54016ad639e5aac1 Author: flavius-t Date: Fri May 27 01:00:02 2022 +0100 tc module structure update commit cccfb323d93a8b5ce76c650b9591ae06a5c5655a Author: flavius-t Date: Tue May 24 18:32:48 2022 +0100 update docstrings commit 155cdc8fc95e209276cf24943277cf5fecbea885 Author: flavius-t Date: Tue May 24 18:17:55 2022 +0100 fix lint errors commit c2189c947d61507512ee5c20686efce2483c6d23 Author: flavius-t Date: Tue May 24 18:02:35 2022 +0100 add pylint ignores commit 259d59833d169bc7f3e8f1f3fcd1e43df15bda23 Author: flavius-t Date: Tue May 24 17:59:44 2022 +0100 ignore trailing-whitespace commit 870715393ec48a9ce469e37b1c1e9543197be3d7 Author: flavius-t Date: Tue May 24 17:57:16 2022 +0100 refactor pylint workflow commit b1a96ded2b1d79d774829fc049414dc003781937 Author: flavius-t Date: Sat May 21 01:01:01 2022 +0100 initial tc module structure commit 237358192d66188b8d5323058f384b84b8642abc Author: flavius-t Date: Fri May 20 23:06:42 2022 +0100 activate virtual env commit 1651fc8c0389a812bd10e32e4748c0202aee80cb Author: flavius-t Date: Fri May 20 23:04:54 2022 +0100 fix workflow import errors commit 80c8866bb9ffa01ebcefdda397b0299ca1df8c0b Author: flavius-t Date: Fri May 20 20:02:20 2022 +0100 remove setup-python from self-hosted workflow commit 7035b89714405b1f650969f1fbb0c25ac7705029 Author: flavius-t Date: Fri May 20 19:43:52 2022 +0100 add self-hosted workflow runner commit e04099f2238d9e4353fbe63fc342d95692b92905 Merge: af3d655 b8043fd Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jun 16 11:42:30 2022 -0700 Merge pull request #23 from osensa/abstract-config Add utility module for generic register value updates commit b8043fd60c6c9995b13312fcf8396b6eaf698cd9 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Thu Jun 16 11:36:49 2022 -0700 Update README.md commit 4706d34c9dd569b5aac43bc6774f31b913108cde Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Jun 15 16:37:16 2022 -0700 Update README.md commit 6ccd7de4f279fd17bba1c70beac68a29c344804b Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Jun 15 16:32:43 2022 -0700 Update README.md commit 6abeafe2592945386daef340fd2fa1b3d7718f0d Author: flavius-t Date: Wed Jun 15 22:20:36 2022 +0100 add publishing workflows commit 82e0a65707ab50d797d4a9d918446733d72cc5ad Author: flavius-t Date: Wed Jun 15 20:19:56 2022 +0100 rename read_temps commit 6014098aba3c70d564a350f3037ab64b1aab183b Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Wed Jun 15 12:18:05 2022 -0700 Update and rename thermocouple.md to README.md commit 7810fda72d3cf702a2382fe10a33c30534f7cbe8 Author: flavius-t Date: Wed Jun 15 18:25:08 2022 +0100 move filter_dict to utilities module commit 31c4396a27f6fcef4598d0b48a618a85c3ca0473 Author: flavius-t Date: Wed Jun 15 18:09:52 2022 +0100 refactor register value map formatting commit e40e5fd1f449d5522e717a5ed49ad2fb0c4a37ef Author: flavius-t Date: Tue Jun 14 20:12:18 2022 +0100 update documentation commit f656b0d349de33980c7a48a7d85800af8c90f5e7 Author: flavius-t Date: Tue Jun 14 19:54:48 2022 +0100 closes #25 commit 360e41263e587e0d3a950d03826c77df1047c4b6 Author: flavius-t Date: Tue Jun 14 19:08:25 2022 +0100 update documentation commit 3d9791a57732be0d76450d95e9f81613f88398c8 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Tue Jun 14 11:06:14 2022 -0700 Update thermocouple.md commit 3356a414bc9aef218e74dc8efb664ec80f4b0b29 Author: flavius-t Date: Tue Jun 14 00:34:33 2022 +0100 cleanup outdated comments commit 72bdc18583f84f91082f54b75e2190bcb76241d1 Author: flavius-t Date: Mon Jun 13 23:11:17 2022 +0100 unit test negative_temp_check commit afb0d9725414fa4ba5ad2af6bfde52248101c78f Author: flavius-t Date: Mon Jun 13 22:46:39 2022 +0100 update documentation commit 6d4dc5671493e09d3b1a6288f4cb62254264e455 Author: flavius-t Date: Mon Jun 13 22:39:06 2022 +0100 unit test filter_dict commit 200f423de1c5fc81b2b7d18033d7a086f13deb52 Author: flavius-t Date: Mon Jun 13 22:28:03 2022 +0100 refactor filter utility function commit 1e228a754e23d8ce4b874c811f34b3f36e423de8 Author: flavius-t Date: Mon Jun 13 21:57:06 2022 +0100 input validation, unit testing for apply_opcodes commit 3434afa140b77d43d6bc9890f1f7e67b7afee5b1 Author: flavius-t Date: Mon Jun 13 20:20:07 2022 +0100 add_change_flags unit tests commit 1151edd2d4037f4315ad45efba9793ed2c3066c8 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Mon Jun 13 11:35:55 2022 -0700 Update thermocouple.md commit 54750d0d6879025b4e06c9f6ff9f62c814f0551c Author: flavius-t Date: Mon Jun 13 19:17:43 2022 +0100 add edge-cases to code_to_temp unit testing commit ddf69b4e5d74098bbc9aa4b9b3d285f4f2835a6b Author: flavius-t Date: Mon Jun 13 17:57:53 2022 +0100 add exceptions testing for code_to_temp commit 554f30b3d9d81357d634cbfbd66548bc2de35bd9 Author: flavius-t Date: Sat Jun 11 01:05:29 2022 +0100 add package install documentation commit 8702ba89d96ea723ed5a952c2e1797916b9f2e5c Author: flavius-t Date: Sat Jun 11 00:56:01 2022 +0100 add bitstring to package dependencies commit c41d45d31dcd3696952c88d4e25fd4daf5c39f9b Author: flavius-t Date: Sat Jun 11 00:46:46 2022 +0100 Revert "add bitstring to requirements" This reverts commit 3375cc622aad956238d5e821a3c06a08bd1fb374. commit 3375cc622aad956238d5e821a3c06a08bd1fb374 Author: flavius-t Date: Sat Jun 11 00:43:46 2022 +0100 add bitstring to requirements commit a627801e8bfe533c02cd1f871187e9d8edc4c573 Author: flavius-t Date: Fri Jun 10 23:41:17 2022 +0100 replace bitwise ops with bitstring pack commit 21aa2585f484edff6900470f02237f6657fcb9ce Author: flavius-t Date: Fri Jun 10 20:43:28 2022 +0100 pull request fixes commit 9f8e352089581b4426ff395c4fd444b4620c215a Author: flavius-t Date: Fri Jun 10 17:43:12 2022 +0100 fix incompatible mask checking bug commit 8409093d7c37e46f2d4966d183ff838470cd92df Author: flavius-t Date: Fri Jun 10 00:51:53 2022 +0100 remove redundant dictionary assignment commit 44cd3971d0414f4955f505698fccee045c5a943b Author: flavius-t Date: Fri Jun 10 00:07:52 2022 +0100 expand apply_opcode unit testing commit 83eef2456ce201b3acdc44f95259ce784778da31 Author: flavius-t Date: Thu Jun 9 22:57:05 2022 +0100 clean up comments commit f692845b1cf9e2ca1bad753c2f9c1879a7c71717 Author: flavius-t Date: Thu Jun 9 22:42:04 2022 +0100 add debug message to custom error commit 08009d2df5a34662ab48273d259b6356ad3d8135 Author: flavius-t Date: Thu Jun 9 20:55:13 2022 +0100 add unit test documentation commit 67c3e5098f3f3a69c668a60c00d89c2d1c73e76b Author: flavius-t Date: Thu Jun 9 20:32:39 2022 +0100 expand opcode unit tests commit 3503dff9bdb8dad66fc9995f813f66a99e2a561f Author: flavius-t Date: Thu Jun 9 19:59:32 2022 +0100 refactor temperature conversion commit 194214d101b309234f130eb6dcf4895779940cd9 Author: flavius-t Date: Thu Jun 9 19:18:06 2022 +0100 remove magic numbers commit 37d6dda5664d8df5d91e355ebc1fea6befa9174a Author: flavius-t Date: Thu Jun 9 19:01:50 2022 +0100 add change flags for register updates commit 1bcf9d22f60380934ecc1a664027b8be546dfe9e Author: flavius-t Date: Thu Jun 9 18:25:50 2022 +0100 add incompatible opcode mask check commit 5310cefe7e8eb1cc2f1fa73ab7b4061ac16f6b1c Author: flavius-t Date: Thu Jun 9 01:48:32 2022 +0100 unit tests, negative temperature sampling bug fix commit 0ef31b4312c3463c2c5af84b96715ebccf0a33e5 Author: flavius-t Date: Wed Jun 8 23:14:30 2022 +0100 abstract out register value updates commit ff5e7244b475e82198e62d8230404265c3abb443 Author: flavius-t Date: Sat Jun 4 00:44:18 2022 +0100 add temperature sampling commit 92e9c5e7e691e2319b643e93b304f7154189d215 Author: flavius-t Date: Fri Jun 3 18:07:12 2022 +0100 change workflows to dev branch only commit ca9601f1230edb7784e5d846c21ac3f6e39e0ff3 Author: flavius-t Date: Fri Jun 3 17:41:08 2022 +0100 refactor unit testing workflow commit eae6e3f25ab5ec2835ca566e5047eb608618b6e8 Author: flavius-t Date: Fri Jun 3 01:00:20 2022 +0100 add update code generation for cr1 commit 145ac0fdb55f6bad3c855a1999f0460bd1f722e4 Author: flavius-t Date: Thu Jun 2 19:55:42 2022 +0100 refactor set_config with helper methods commit a2a650ce41385390510e8497e9b5996237d700f2 Author: flavius-t Date: Thu Jun 2 00:53:10 2022 +0100 refactor register reading commit 986762b69c876f455ee3834144216574cc90a02b Author: flavius-t Date: Wed Jun 1 23:41:44 2022 +0100 add gpiozero requirement until spi transfer fixed commit ddfd0846c30506d230664366a1fe4ca2756dd212 Author: flavius-t Date: Wed Jun 1 23:40:11 2022 +0100 refactor mock spi transfer to library commit 16a9b1cd01d2fe0d2b2589e48eadc0f695acc5a9 Author: flavius-t Date: Wed Jun 1 23:23:38 2022 +0100 spi transfer issue debugging, and mock transfer commit 3b92b17608d4b7d98a4092c508920453c14464eb Author: flavius-t Date: Mon May 30 23:52:56 2022 +0100 debug refactoring commit 1393b3ce6530e67d8c569523e7685b2cd8a01485 Author: flavius-t Date: Mon May 30 18:46:19 2022 +0100 refactor update code generate methods commit 0af7d50b7455b3e0d29b9ce91094bd6fa077f539 Author: flavius-t Date: Sat May 28 01:16:02 2022 +0100 add method for generating cr0 write command commit 4d5b01c6bba29cd3151efd8dcfccef73ed299e86 Author: flavius-t Date: Fri May 27 23:04:04 2022 +0100 add collective configuration method commit 09a2694d359b768889a0e33e9ceae9f6c3719c40 Author: flavius-t Date: Fri May 27 19:45:42 2022 +0100 add opcode to register mapping commit af3d6553e059f1982e17ec731215f7d9498f7b8d Merge: 4440f31 b871a29 Author: flavius-t <77416463+flavius-t@users.noreply.github.com> Date: Fri May 27 10:00:44 2022 -0700 Merge pull request #19 from osensa/DAC fix update command opcodes commit b871a29eb32207424085c9745232f72df7518bbb Author: flavius-t Date: Fri May 27 17:50:28 2022 +0100 fix update command opcodes commit 3e9be2e66c438dce398fd9f7d2993e30fab43cca Author: flavius-t Date: Fri May 27 01:00:02 2022 +0100 tc module structure update commit 693c65016ce95b5c161132320067eefe0379f2ae Author: flavius-t Date: Tue May 24 18:32:48 2022 +0100 update docstrings commit 81a77a4b0ea20c9693f6f3fc64017b29e93b7741 Author: flavius-t Date: Tue May 24 18:17:55 2022 +0100 fix lint errors commit 9b177afc1c25a28d8c1802bc8124e030675c0e6f Author: flavius-t Date: Tue May 24 18:02:35 2022 +0100 add pylint ignores commit 3d8bda72ad8bc67da12276b7e2a1d8b07a990cff Author: flavius-t Date: Tue May 24 17:59:44 2022 +0100 ignore trailing-whitespace commit 35e19735bf4e3d21636bd0bc0dfc25ad2cf054fd Author: flavius-t Date: Tue May 24 17:57:16 2022 +0100 refactor pylint workflow commit c5ff8191337c70eef66caec63892e705ea03cba2 Author: flavius-t Date: Sat May 21 01:01:01 2022 +0100 initial tc module structure commit a7413d6fe354087b3afaf938d60c03b8cc39d3df Author: flavius-t Date: Fri May 20 23:06:42 2022 +0100 activate virtual env commit bec60bc370027348d4b0af7d0673115ed4db12f2 Author: flavius-t Date: Fri May 20 23:04:54 2022 +0100 fix workflow import errors commit fc1e715266e06d04120c037730171401f3a5dd19 Merge: 56fd203 e717c0f Author: flavius-t Date: Fri May 20 22:52:32 2022 +0100 Merge branch 'TC' of github.com:osensa/edgepi-python-sdk into TC commit 56fd203a7f9bf1889f8d30a6fbecd1d5e59f0515 Author: flavius-t Date: Fri May 20 22:51:52 2022 +0100 linting stringency changes commit e717c0f9ad0acf45b2e5d3b89360041d772d3d4c Author: flavius-t Date: Fri May 20 20:02:20 2022 +0100 remove setup-python from self-hosted workflow commit 4b215134ab0ce6b169e610c3af185d0427f332d5 Author: flavius-t Date: Fri May 20 19:43:52 2022 +0100 add self-hosted workflow runner commit 860adeb60a8049ea04e5e69029ea555aa5025645 Author: flavius-t Date: Thu May 19 00:53:15 2022 +0100 workflow fix commit 5afb0a24d202405c2cc70e54d8fbbdf18af1e244 Author: flavius-t Date: Thu May 19 00:02:34 2022 +0100 workflow fix commit 39c654f662abaef15d206dd447c3e4fa8fe97d21 Author: flavius-t Date: Wed May 18 23:58:57 2022 +0100 update workflow commit 8146e3f4c27ffce0be4c7bee0d568ea226431200 Author: flavius-t Date: Wed May 18 23:45:29 2022 +0100 initial tc module commit commit 1ecd1a6feab0625bafc378ba1a6fc09bf459865a Author: flavius-t Date: Wed May 18 23:01:33 2022 +0100 add venv activation between steps commit fb460d2932a7732a4ffd5585cb194c32e16c0652 Author: flavius-t Date: Wed May 18 22:56:47 2022 +0100 workflow fix commit 5cbe640430d6806f3556144b15dbd9b2cb87c9d5 Author: flavius-t Date: Wed May 18 22:51:59 2022 +0100 added linting and unit testing workflow --- .bumpversion.cfg | 4 +- setup.py | 2 +- src/edgepi/adc/edgepi_adc.py | 2 +- src/edgepi/calibration/edgepi_eeprom.py | 24 +- src/edgepi/calibration/eeprom_constants.py | 62 +--- src/edgepi/calibration/eeprom_mapping.proto | 6 +- src/edgepi/calibration/eeprom_mapping_pb2.py | 286 ++---------------- src/edgepi/calibration/protobuf_mapping.py | 80 +++++ src/edgepi/dac/edgepi_dac.py | 2 +- src/edgepi/digital_output/README.md | 57 ++-- src/edgepi/gpio/edgepi_gpio_chip.py | 8 +- src/edgepi/gpio/gpio_configs.py | 4 +- src/edgepi/peripherals/gpio.py | 2 +- src/edgepi/peripherals/i2c.py | 6 +- .../test_calibration/serializedFile | Bin 7003 -> 7174 bytes .../test_calibration/test_access_eeprom.py | 86 +++++- .../test_calibration/test_eeprom_constants.py | 53 ---- .../test_calibration/test_protobuf_mapping.py | 96 ++++++ .../unit_tests/test_dac/test_dac_commands.py | 8 +- .../unit_tests/test_dac/test_edgepi_dac.py | 37 ++- .../test_gpio/test_edgpepi_gpio_chip.py | 4 +- .../test_digital_out/__init__.py | 0 .../test_digital_out/test_digital_out.py | 36 +++ 23 files changed, 415 insertions(+), 450 deletions(-) create mode 100644 src/edgepi/calibration/protobuf_mapping.py delete mode 100644 src/test_edgepi/unit_tests/test_calibration/test_eeprom_constants.py create mode 100644 src/test_edgepi/unit_tests/test_calibration/test_protobuf_mapping.py create mode 100644 tests/integration_tests/test_digital_out/__init__.py create mode 100644 tests/integration_tests/test_digital_out/test_digital_out.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9ba19940..b47eb4ab 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,3 +1,3 @@ [bumpversion] -tag_name = "rc/v{new_version}" -current_version = 1.1.15 +tag_name = rc/v{new_version} +current_version = 1.1.17 diff --git a/setup.py b/setup.py index 3ee154ea..3678b5ff 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setuptools.setup( name="edgepi-python-sdk", - version="1.1.15", + version="1.1.17", author="S.Park", author_email="spark@osensa.com", description="EdgePi Python SDK package", diff --git a/src/edgepi/adc/edgepi_adc.py b/src/edgepi/adc/edgepi_adc.py index 1a62fe73..d4e70950 100644 --- a/src/edgepi/adc/edgepi_adc.py +++ b/src/edgepi/adc/edgepi_adc.py @@ -223,7 +223,7 @@ def __init__( # Load eeprom data and generate dictionary of calibration dataclass eeprom = EdgePiEEPROM() eeprom_data = eeprom.get_edgepi_reserved_data() - self.adc_calib_params = eeprom_data.adc_calib_parms + self.adc_calib_params = eeprom_data.adc_calib_params self.adc_ops = ADCCommands() self.gpio = EdgePiGPIO() diff --git a/src/edgepi/calibration/edgepi_eeprom.py b/src/edgepi/calibration/edgepi_eeprom.py index ff7574aa..b5a427a8 100644 --- a/src/edgepi/calibration/edgepi_eeprom.py +++ b/src/edgepi/calibration/edgepi_eeprom.py @@ -1,13 +1,17 @@ '''Helper class to access on board eeprom''' +# pylint: disable=no-name-in-module +# https://github.com/protocolbuffers/protobuf/issues/10372 + import logging import math from edgepi.calibration.eeprom_constants import ( EEPROMInfo, EdgePiMemoryInfo, - MessageFieldNumber, - EdgePiEEPROMData) + MessageFieldNumber + ) +from edgepi.calibration.protobuf_mapping import EdgePiEEPROMData from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout from edgepi.peripherals.i2c import I2CDevice @@ -20,6 +24,7 @@ class EdgePiEEPROM(I2CDevice): def __init__(self): self.log = logging.getLogger(__name__) + self.log.info("Initializing EEPROM Access") self.eeprom_layout = EepromLayout() super().__init__(self.__dev_path) @@ -98,16 +103,7 @@ def get_edgepi_reserved_data(self): """ # pylint: disable=no-member self.eeprom_layout.ParseFromString(self.__read_edgepi_reserved_memory()) - eeprom_data = EdgePiEEPROMData() - eeprom_data.dac_calib_parms=eeprom_data.message_to_dict(self.eeprom_layout.dac) - eeprom_data.adc_calib_parms=eeprom_data.message_to_dict(self.eeprom_layout.adc) - eeprom_data.rtd_calib_parms=eeprom_data.message_to_dict(self.eeprom_layout.rtd) - eeprom_data.tc_calib_parms=eeprom_data.message_to_dict(self.eeprom_layout.tc) - eeprom_data.config_key=eeprom_data.keys_to_str(self.eeprom_layout.config_key) - eeprom_data.data_key=eeprom_data.keys_to_str(self.eeprom_layout.data_key) - eeprom_data.serial= self.eeprom_layout.serial_number - eeprom_data.model= self.eeprom_layout.model - eeprom_data.client_id= self.eeprom_layout.client_id + eeprom_data = EdgePiEEPROMData(self.eeprom_layout) return eeprom_data def sequential_read(self, mem_addr: int = None, length: int = None): @@ -124,9 +120,9 @@ def sequential_read(self, mem_addr: int = None, length: int = None): page_addr, byte_addr = self.__byte_address_generation(mem_addr) mem_addr_list = self.__pack_mem_address(page_addr, byte_addr) msg = self.set_read_msg(mem_addr_list, [0x00]*length) - self.log.debug(f'Reading Address {mem_addr}, {length} bytes, {msg[1].data}') + self.log.debug(f'Reading Address {mem_addr}, {length} bytes') read_result = self.transfer(EEPROMInfo.DEV_ADDR.value, msg) - self.log.debug(f'Read data: {msg[1].data}') + self.log.debug(f'Read data: {len(msg[1].data)}') return read_result diff --git a/src/edgepi/calibration/eeprom_constants.py b/src/edgepi/calibration/eeprom_constants.py index 76c52d23..aabb9821 100644 --- a/src/edgepi/calibration/eeprom_constants.py +++ b/src/edgepi/calibration/eeprom_constants.py @@ -1,9 +1,6 @@ '''Address map of eeprom''' from enum import Enum -from dataclasses import dataclass -from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout -from edgepi.calibration.calibration_constants import CalibParam class EEPROMInfo(Enum): """ @@ -28,6 +25,8 @@ class EdgePiMemoryInfo(Enum): """ USED_SPACE = 0x00 BUFF_START = 0x02 + USER_SPACE_START = 0x100 + USER_SPACE_END = 0x1FF class MessageFieldNumber(Enum): """ @@ -43,60 +42,3 @@ class MessageFieldNumber(Enum): SERIAL=7 MODEL=8 CLIENT_ID=9 - -@dataclass -class Keys: - """ - Dataclass to store key strings - """ - certificate: str = None - private: str = None - -@dataclass -class EdgePiEEPROMData: - # pylint: disable=too-many-instance-attributes - """ - Dataclass to store edgepi reserved values - dac_calib_parms (dict): list of calibration parameters - adc_calib_parms (dict): list of calibration parameters - rtd_calib_parms (dict): list of calibration parameters - tc_calib_parms (dict): list of calibration parameters - config_key (Keys): dataclass - data_key (Keys): dataclass - serial (str) - model (str) - client_id (str) - """ - dac_calib_parms: dict = None - adc_calib_parms: dict = None - rtd_calib_parms: dict = None - tc_calib_parms: dict = None - config_key: Keys = None - data_key: Keys = None - serial: str = None - model: str = None - client_id: str = None - - def message_to_dict(self, data_to_unpack: EepromLayout = None): - """ - Function to unpack message to list - Args: - data_to_unpack: EepromLayout message modules - Returns: - calib_list: 1-D array - """ - calib_dict={} - for indx, ch in enumerate(data_to_unpack.calibs): - calib_dict[indx] = CalibParam(gain=ch.gain, - offset=ch.offset) - return calib_dict - - def keys_to_str(self, data_to_unpack: EepromLayout = None): - """ - Function to unpack message to string - Args: - data_to_unpack: EepromLayout message keys - Returns: - Keys (dataclass): keys values - """ - return Keys(certificate = data_to_unpack.certificate, private = data_to_unpack.private_key) diff --git a/src/edgepi/calibration/eeprom_mapping.proto b/src/edgepi/calibration/eeprom_mapping.proto index 3c5dd1a1..c11f4b52 100644 --- a/src/edgepi/calibration/eeprom_mapping.proto +++ b/src/edgepi/calibration/eeprom_mapping.proto @@ -2,11 +2,15 @@ syntax = "proto3"; message EepromLayout{ message ModuleCalibParams{ - message ChannelCalib { + message ChannelCalib{ optional float gain = 1; optional float offset = 2; } + message HardwareValue{ + optional float ref_resistor = 1; + } repeated ChannelCalib calibs = 1; + repeated HardwareValue hw_val = 2; } message AwsKey{ string private_key = 1; diff --git a/src/edgepi/calibration/eeprom_mapping_pb2.py b/src/edgepi/calibration/eeprom_mapping_pb2.py index f5fac852..fa74c91b 100644 --- a/src/edgepi/calibration/eeprom_mapping_pb2.py +++ b/src/edgepi/calibration/eeprom_mapping_pb2.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: eeprom_mapping.proto - +"""Generated protocol buffer code.""" # pylint: skip-file +from google.protobuf.internal import builder as _builder from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection +from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database # @@protoc_insertion_point(imports) @@ -14,271 +14,21 @@ -DESCRIPTOR = _descriptor.FileDescriptor( - name='eeprom_mapping.proto', - package='', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x14\x65\x65prom_mapping.proto\"\xa4\x04\n\x0c\x45\x65promLayout\x12,\n\x03\x64\x61\x63\x18\x01 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12,\n\x03\x61\x64\x63\x18\x02 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12,\n\x03rtd\x18\x03 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12+\n\x02tc\x18\x04 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12(\n\nconfig_key\x18\x05 \x01(\x0b\x32\x14.EepromLayout.AwsKey\x12&\n\x08\x64\x61ta_key\x18\x06 \x01(\x0b\x32\x14.EepromLayout.AwsKey\x12\x15\n\rserial_number\x18\x07 \x01(\t\x12\r\n\x05model\x18\x08 \x01(\t\x12\x11\n\tclient_id\x18\t \x01(\t\x1a\x9d\x01\n\x11ModuleCalibParams\x12<\n\x06\x63\x61libs\x18\x01 \x03(\x0b\x32,.EepromLayout.ModuleCalibParams.ChannelCalib\x1aJ\n\x0c\x43hannelCalib\x12\x11\n\x04gain\x18\x01 \x01(\x02H\x00\x88\x01\x01\x12\x13\n\x06offset\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\x07\n\x05_gainB\t\n\x07_offset\x1a\x32\n\x06\x41wsKey\x12\x13\n\x0bprivate_key\x18\x01 \x01(\t\x12\x13\n\x0b\x63\x65rtificate\x18\x02 \x01(\tb\x06proto3' -) - - - - -_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB = _descriptor.Descriptor( - name='ChannelCalib', - full_name='EepromLayout.ModuleCalibParams.ChannelCalib', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='gain', full_name='EepromLayout.ModuleCalibParams.ChannelCalib.gain', index=0, - number=1, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='offset', full_name='EepromLayout.ModuleCalibParams.ChannelCalib.offset', index=1, - number=2, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='_gain', full_name='EepromLayout.ModuleCalibParams.ChannelCalib._gain', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - _descriptor.OneofDescriptor( - name='_offset', full_name='EepromLayout.ModuleCalibParams.ChannelCalib._offset', - index=1, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=447, - serialized_end=521, -) - -_EEPROMLAYOUT_MODULECALIBPARAMS = _descriptor.Descriptor( - name='ModuleCalibParams', - full_name='EepromLayout.ModuleCalibParams', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='calibs', full_name='EepromLayout.ModuleCalibParams.calibs', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB, ], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=364, - serialized_end=521, -) - -_EEPROMLAYOUT_AWSKEY = _descriptor.Descriptor( - name='AwsKey', - full_name='EepromLayout.AwsKey', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='private_key', full_name='EepromLayout.AwsKey.private_key', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='certificate', full_name='EepromLayout.AwsKey.certificate', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=523, - serialized_end=573, -) - -_EEPROMLAYOUT = _descriptor.Descriptor( - name='EepromLayout', - full_name='EepromLayout', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='dac', full_name='EepromLayout.dac', index=0, - number=1, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='adc', full_name='EepromLayout.adc', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='rtd', full_name='EepromLayout.rtd', index=2, - number=3, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='tc', full_name='EepromLayout.tc', index=3, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='config_key', full_name='EepromLayout.config_key', index=4, - number=5, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='data_key', full_name='EepromLayout.data_key', index=5, - number=6, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='serial_number', full_name='EepromLayout.serial_number', index=6, - number=7, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='model', full_name='EepromLayout.model', index=7, - number=8, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='client_id', full_name='EepromLayout.client_id', index=8, - number=9, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[_EEPROMLAYOUT_MODULECALIBPARAMS, _EEPROMLAYOUT_AWSKEY, ], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=25, - serialized_end=573, -) - -_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.containing_type = _EEPROMLAYOUT_MODULECALIBPARAMS -_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.oneofs_by_name['_gain'].fields.append( - _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.fields_by_name['gain']) -_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.fields_by_name['gain'].containing_oneof = _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.oneofs_by_name['_gain'] -_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.oneofs_by_name['_offset'].fields.append( - _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.fields_by_name['offset']) -_EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.fields_by_name['offset'].containing_oneof = _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB.oneofs_by_name['_offset'] -_EEPROMLAYOUT_MODULECALIBPARAMS.fields_by_name['calibs'].message_type = _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB -_EEPROMLAYOUT_MODULECALIBPARAMS.containing_type = _EEPROMLAYOUT -_EEPROMLAYOUT_AWSKEY.containing_type = _EEPROMLAYOUT -_EEPROMLAYOUT.fields_by_name['dac'].message_type = _EEPROMLAYOUT_MODULECALIBPARAMS -_EEPROMLAYOUT.fields_by_name['adc'].message_type = _EEPROMLAYOUT_MODULECALIBPARAMS -_EEPROMLAYOUT.fields_by_name['rtd'].message_type = _EEPROMLAYOUT_MODULECALIBPARAMS -_EEPROMLAYOUT.fields_by_name['tc'].message_type = _EEPROMLAYOUT_MODULECALIBPARAMS -_EEPROMLAYOUT.fields_by_name['config_key'].message_type = _EEPROMLAYOUT_AWSKEY -_EEPROMLAYOUT.fields_by_name['data_key'].message_type = _EEPROMLAYOUT_AWSKEY -DESCRIPTOR.message_types_by_name['EepromLayout'] = _EEPROMLAYOUT -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -EepromLayout = _reflection.GeneratedProtocolMessageType('EepromLayout', (_message.Message,), { - - 'ModuleCalibParams' : _reflection.GeneratedProtocolMessageType('ModuleCalibParams', (_message.Message,), { - - 'ChannelCalib' : _reflection.GeneratedProtocolMessageType('ChannelCalib', (_message.Message,), { - 'DESCRIPTOR' : _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB, - '__module__' : 'eeprom_mapping_pb2' - # @@protoc_insertion_point(class_scope:EepromLayout.ModuleCalibParams.ChannelCalib) - }) - , - 'DESCRIPTOR' : _EEPROMLAYOUT_MODULECALIBPARAMS, - '__module__' : 'eeprom_mapping_pb2' - # @@protoc_insertion_point(class_scope:EepromLayout.ModuleCalibParams) - }) - , - - 'AwsKey' : _reflection.GeneratedProtocolMessageType('AwsKey', (_message.Message,), { - 'DESCRIPTOR' : _EEPROMLAYOUT_AWSKEY, - '__module__' : 'eeprom_mapping_pb2' - # @@protoc_insertion_point(class_scope:EepromLayout.AwsKey) - }) - , - 'DESCRIPTOR' : _EEPROMLAYOUT, - '__module__' : 'eeprom_mapping_pb2' - # @@protoc_insertion_point(class_scope:EepromLayout) - }) -_sym_db.RegisterMessage(EepromLayout) -_sym_db.RegisterMessage(EepromLayout.ModuleCalibParams) -_sym_db.RegisterMessage(EepromLayout.ModuleCalibParams.ChannelCalib) -_sym_db.RegisterMessage(EepromLayout.AwsKey) +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x65\x65prom_mapping.proto\"\xa0\x05\n\x0c\x45\x65promLayout\x12,\n\x03\x64\x61\x63\x18\x01 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12,\n\x03\x61\x64\x63\x18\x02 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12,\n\x03rtd\x18\x03 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12+\n\x02tc\x18\x04 \x01(\x0b\x32\x1f.EepromLayout.ModuleCalibParams\x12(\n\nconfig_key\x18\x05 \x01(\x0b\x32\x14.EepromLayout.AwsKey\x12&\n\x08\x64\x61ta_key\x18\x06 \x01(\x0b\x32\x14.EepromLayout.AwsKey\x12\x15\n\rserial_number\x18\x07 \x01(\t\x12\r\n\x05model\x18\x08 \x01(\t\x12\x11\n\tclient_id\x18\t \x01(\t\x1a\x99\x02\n\x11ModuleCalibParams\x12<\n\x06\x63\x61libs\x18\x01 \x03(\x0b\x32,.EepromLayout.ModuleCalibParams.ChannelCalib\x12=\n\x06hw_val\x18\x02 \x03(\x0b\x32-.EepromLayout.ModuleCalibParams.HardwareValue\x1aJ\n\x0c\x43hannelCalib\x12\x11\n\x04gain\x18\x01 \x01(\x02H\x00\x88\x01\x01\x12\x13\n\x06offset\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\x07\n\x05_gainB\t\n\x07_offset\x1a;\n\rHardwareValue\x12\x19\n\x0cref_resistor\x18\x01 \x01(\x02H\x00\x88\x01\x01\x42\x0f\n\r_ref_resistor\x1a\x32\n\x06\x41wsKey\x12\x13\n\x0bprivate_key\x18\x01 \x01(\t\x12\x13\n\x0b\x63\x65rtificate\x18\x02 \x01(\tb\x06proto3') +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'eeprom_mapping_pb2', globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + _EEPROMLAYOUT._serialized_start=25 + _EEPROMLAYOUT._serialized_end=697 + _EEPROMLAYOUT_MODULECALIBPARAMS._serialized_start=364 + _EEPROMLAYOUT_MODULECALIBPARAMS._serialized_end=645 + _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB._serialized_start=510 + _EEPROMLAYOUT_MODULECALIBPARAMS_CHANNELCALIB._serialized_end=584 + _EEPROMLAYOUT_MODULECALIBPARAMS_HARDWAREVALUE._serialized_start=586 + _EEPROMLAYOUT_MODULECALIBPARAMS_HARDWAREVALUE._serialized_end=645 + _EEPROMLAYOUT_AWSKEY._serialized_start=647 + _EEPROMLAYOUT_AWSKEY._serialized_end=697 # @@protoc_insertion_point(module_scope) diff --git a/src/edgepi/calibration/protobuf_mapping.py b/src/edgepi/calibration/protobuf_mapping.py new file mode 100644 index 00000000..4446cbc2 --- /dev/null +++ b/src/edgepi/calibration/protobuf_mapping.py @@ -0,0 +1,80 @@ +"""module to map protobuf data to a class""" + +# pylint: disable=no-name-in-module +# https://github.com/protocolbuffers/protobuf/issues/10372 +from dataclasses import dataclass +from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout +from edgepi.calibration.calibration_constants import CalibParam + +@dataclass +class Keys: + """ + Dataclass to store key strings + """ + certificate: str = None + private: str = None + + +class EdgePiEEPROMData: + # pylint: disable=too-many-instance-attributes + """ + Dataclass to store edgepi reserved values + dac_calib_parms (dict): list of calibration parameters + adc_calib_parms (dict): list of calibration parameters + rtd_calib_parms (dict): list of calibration parameters + tc_calib_parms (dict): list of calibration parameters + config_key (Keys): dataclass + data_key (Keys): dataclass + serial (str) + model (str) + client_id (str) + """ + def __init__(self, data_to_unpack: EepromLayout = None): + self.dac_calib_params = self.calib_message_to_dict(data_to_unpack.dac) + self.adc_calib_params = self.calib_message_to_dict(data_to_unpack.adc) + self.rtd_calib_params = self.calib_message_to_dict(data_to_unpack.rtd) + self.rtd_hw_params = self.hw_message_to_dict(data_to_unpack.rtd) + self.tc_calib_params = self.calib_message_to_dict(data_to_unpack.tc) + self.tc_hw_params = self.hw_message_to_dict(data_to_unpack.tc) + self.config_key = self.keys_to_dataclass(data_to_unpack.config_key) + self.data_key = self.keys_to_dataclass(data_to_unpack.data_key) + self.serial = data_to_unpack.serial_number + self.model = data_to_unpack.model + self.client_id = data_to_unpack.client_id + + def calib_message_to_dict(self, data_to_unpack: EepromLayout = None): + """ + Function to unpack message to list + Args: + data_to_unpack: EepromLayout message modules + Returns: + calib_dict: calib param to dictionary + """ + calib_dict={} + for indx, ch in enumerate(data_to_unpack.calibs): + calib_dict[indx] = CalibParam(gain=ch.gain, + offset=ch.offset) + return calib_dict + + def hw_message_to_dict(self, data_to_unpack: EepromLayout = None): + """ + Function to unpack message to list + Args: + data_to_unpack: EepromLayout message modules + Returns: + hw_params: hardware param to dictionary + """ + hw_dict={} + for indx, ch in enumerate(data_to_unpack.hw_val): + hw_dict[indx] = ch.ref_resistor + return hw_dict + + def keys_to_dataclass(self, data_to_unpack: EepromLayout = None): + """ + Function to unpack message and populate into Keys dataclass in string format + Args: + data_to_unpack: EepromLayout message keys + Returns: + Keys (dataclass): keys values + """ + return Keys(certificate = data_to_unpack.certificate, private = data_to_unpack.private_key) diff --git a/src/edgepi/dac/edgepi_dac.py b/src/edgepi/dac/edgepi_dac.py index 1d6c145b..4038cbda 100644 --- a/src/edgepi/dac/edgepi_dac.py +++ b/src/edgepi/dac/edgepi_dac.py @@ -44,7 +44,7 @@ def __init__(self): # Read edgepi reserved data and generate calibration parameter dictionary eeprom = EdgePiEEPROM() eeprom_data = eeprom.get_edgepi_reserved_data() - dac_calib_params = eeprom_data.dac_calib_parms + dac_calib_params = eeprom_data.dac_calib_params self.dac_ops = DACCommands(dac_calib_params) self.gpio = EdgePiGPIO() diff --git a/src/edgepi/digital_output/README.md b/src/edgepi/digital_output/README.md index 0ef0e533..de67a40f 100644 --- a/src/edgepi/digital_output/README.md +++ b/src/edgepi/digital_output/README.md @@ -11,24 +11,35 @@ from edgepi.digital_output.edgepi_digital_output import EdgePiDigitalOutput digital_output = EdgePiDigitalOutput() -pin_1_state = digital_output.digital_output_direction(GpioPins.DIN1, True) -pin_2_state = digital_output.digital_output_direction(GpioPins.DIN2, True) -pin_3_state = digital_output.digital_output_direction(GpioPins.DIN3, True) -pin_4_state = digital_output.digital_output_direction(GpioPins.DIN4, True) -pin_5_state = digital_output.digital_output_direction(GpioPins.DIN5, True) -pin_6_state = digital_output.digital_output_direction(GpioPins.DIN6, True) -pin_7_state = digital_output.digital_output_direction(GpioPins.DIN7, True) -pin_8_state = digital_output.digital_output_direction(GpioPins.DIN8, True) - -pin_1_state = digital_output.digital_output_state(GpioPins.DIN1, True) -pin_2_state = digital_output.digital_output_state(GpioPins.DIN2, True) -pin_3_state = digital_output.digital_output_state(GpioPins.DIN3, True) -pin_4_state = digital_output.digital_output_state(GpioPins.DIN4, True) -pin_5_state = digital_output.digital_output_state(GpioPins.DIN5, True) -pin_6_state = digital_output.digital_output_state(GpioPins.DIN6, True) -pin_7_state = digital_output.digital_output_state(GpioPins.DIN7, True) -pin_8_state = digital_output.digital_output_state(GpioPins.DIN8, True) +# setting corresponding GpioPin to Output direction +digital_output.digital_output_direction(GpioPins.DOUT1, False) +digital_output.digital_output_direction(GpioPins.DOUT2, False) +digital_output.digital_output_direction(GpioPins.DOUT3, False) +digital_output.digital_output_direction(GpioPins.DOUT4, False) +digital_output.digital_output_direction(GpioPins.DOUT5, False) +digital_output.digital_output_direction(GpioPins.DOUT6, False) +digital_output.digital_output_direction(GpioPins.DOUT7, False) +digital_output.digital_output_direction(GpioPins.DOUT8, False) +# setting corresponding GpioPin to output High/On +digital_output.digital_output_state(GpioPins.DOUT1, True) +digital_output.digital_output_state(GpioPins.DOUT2, True) +digital_output.digital_output_state(GpioPins.DOUT3, True) +digital_output.digital_output_state(GpioPins.DOUT4, True) +digital_output.digital_output_state(GpioPins.DOUT5, True) +digital_output.digital_output_state(GpioPins.DOUT6, True) +digital_output.digital_output_state(GpioPins.DOUT7, True) +digital_output.digital_output_state(GpioPins.DOUT8, True) + +# setting corresponding GpioPin to output Low/Off +digital_output.digital_output_state(GpioPins.DOUT1, False) +digital_output.digital_output_state(GpioPins.DOUT2, False) +digital_output.digital_output_state(GpioPins.DOUT3, False) +digital_output.digital_output_state(GpioPins.DOUT4, False) +digital_output.digital_output_state(GpioPins.DOUT5, False) +digital_output.digital_output_state(GpioPins.DOUT6, False) +digital_output.digital_output_state(GpioPins.DOUT7, False) +digital_output.digital_output_state(GpioPins.DOUT8, False) ``` @@ -36,10 +47,22 @@ pin_8_state = digital_output.digital_output_state(GpioPins.DIN8, True) ```python def digital_output_state(self, pin_name: GpioPins = None, state: bool = None) + """ + change the output state of the pin to the state passed as argument + Args: + pin_name (GpioPins): GpioPin enums + state (bool): True = output high, False, output low + """ ``` Take `pin_name` and `state` as a parameter and sets the output state of the corresponding pin with the state passed. ```python def digital_output_direction(self, pin_name: GpioPins = None, direction: bool = None): + """ + change the output state of the pin to the state passed as argument + Args: + pin_name (GpioPins): GpioPin enums + state (bool): True = direction input, False = direction output + """ ``` Take `pin_name` and `direction` as a parameter and sets the direction of the corresponding pin with the state passed. diff --git a/src/edgepi/gpio/edgepi_gpio_chip.py b/src/edgepi/gpio/edgepi_gpio_chip.py index b010d27d..c99771d7 100644 --- a/src/edgepi/gpio/edgepi_gpio_chip.py +++ b/src/edgepi/gpio/edgepi_gpio_chip.py @@ -44,7 +44,7 @@ def read_gpio_pin_state(self, pin_name: str = None): pin_dir=self.gpiochip_pins_dict[pin_name].dir, pin_bias=self.gpiochip_pins_dict[pin_name].bias) state = self.read_state() - self.close() + self.close_gpio() return state def write_gpio_pin_state(self, pin_name: str = None, state: bool = None): @@ -61,7 +61,7 @@ def write_gpio_pin_state(self, pin_name: str = None, state: bool = None): pin_bias=self.gpiochip_pins_dict[pin_name].bias) self.write_state(state) read_back = self.read_state() - self.close() + self.close_gpio() return read_back def set_gpio_pin_dir(self, pin_name: str = None, direction: bool = None): @@ -74,7 +74,7 @@ def set_gpio_pin_dir(self, pin_name: str = None, direction: bool = None): self.open_gpio(pin_num=self.__pin_name_dict[pin_name], pin_dir="in" if direction else "out", pin_bias=self.gpiochip_pins_dict[pin_name].bias) - self.close() + self.close_gpio() def toggle_gpio_pin_state(self, pin_name: str = None): """ @@ -92,4 +92,4 @@ def toggle_gpio_pin_state(self, pin_name: str = None): self.write_state(False) else: self.write_state(True) - self.close() + self.close_gpio() diff --git a/src/edgepi/gpio/gpio_configs.py b/src/edgepi/gpio/gpio_configs.py index be0ab4a1..94b3bdee 100644 --- a/src/edgepi/gpio/gpio_configs.py +++ b/src/edgepi/gpio/gpio_configs.py @@ -232,6 +232,7 @@ class DOUTPins(Enum): ] _list_of_DOUT_expander_gpios =[ + None, None, DOUTPins.DOUT8.value, DOUTPins.DOUT7.value, DOUTPins.DOUT6.value, DOUTPins.DOUT5.value, DOUTPins.DOUT4.value, DOUTPins.DOUT3.value] @@ -349,7 +350,8 @@ def _generate_DOUT_expander_pins(): #pylint: disable=C0103 pin_dict = {} for pin, set_code, clear_code, dir_out_code, dir_in_code in \ zip(_list_of_DOUT_expander_gpios,GpioAOutputSet,GpioAOutputClear,GpioAPinDirOut,GpioAPinDirIn): - + if pin is None: + continue pin_dict.update({pin : I2cPinInfo(set_code.value, clear_code.value, dir_out_code.value, diff --git a/src/edgepi/peripherals/gpio.py b/src/edgepi/peripherals/gpio.py index 6038f330..65d01e66 100644 --- a/src/edgepi/peripherals/gpio.py +++ b/src/edgepi/peripherals/gpio.py @@ -43,6 +43,6 @@ def write_state(self, state: bool = None): """ self.gpio.write(state) - def close(self): + def close_gpio(self): """Close GPIO connection""" self.gpio.close() diff --git a/src/edgepi/peripherals/i2c.py b/src/edgepi/peripherals/i2c.py index 3b2b1450..e3b77887 100644 --- a/src/edgepi/peripherals/i2c.py +++ b/src/edgepi/peripherals/i2c.py @@ -4,17 +4,21 @@ Classes: I2CDevice """ +import logging from typing import Union from periphery import I2C +_logger = logging.getLogger(__name__) + class I2CDevice(): ''' I2C Device class ''' def __init__(self, fd: str = None): self.fd = fd - self.i2cdev = I2C(fd) + _logger.debug(f"Initialized I2C device with path '{self.fd}'") + self.i2cdev = I2C(devpath=fd) def set_read_msg(self, addr:Union[int,list] = None, msg:list = None): ''' diff --git a/src/test_edgepi/unit_tests/test_calibration/serializedFile b/src/test_edgepi/unit_tests/test_calibration/serializedFile index 492c80d22268a40835889aecde8784f16aac9ed9..95e386893ba8a1ee0d69a6b764fdd1234a9101e8 100644 GIT binary patch delta 963 zcmca@)@D)9mB7WtE6m$$FUs?yZ4Z#G`liWV)H`A}h}{(q6fYO90kQw91KI1Prh?cL zqk-()h{+)Ks$w8}rcpPDeNz|6KGd`T#ICvkG$+||@*bfHj6m*_nf3Of>2|`lK(@d_ zAba9wCLp_>SH8W$Uew=Ac`s1nEE`Z_`=St#q6k5tIK!J#Yam^LwvA51;~lZsp*@e9l#Qji5ia!Y_nA28VqCeMLMeo2sc z0GONzCLM%9B8^~Dmlwp&1C#4{ErD!)X*m{NE}=p1NOoQ>qtU>mQj7!RT~}HU0L>fj A#sB~S delta 686 zcmZp(xNTO?mB7WtE0Eh{FY4;uxChAo^AO0cINS$f8~*~b^N!B~v2$C2Y%kqf5PRZ9 zAUkk>H(1SlAiK%E6U6=z2U5dW0%CLK1KCR$O7;kWY^eNMZ!gMe;$Z`1H(#!^7yY;F zBuG`-995u1pqnR%!`%gBGZ_A~2C}Wnf$V=5Cxh5woelP)(}Ne=0@*D8ftnRAfSp&b z2voBn&}okp4^SpSy4hZ|(rDTqB@~|45-G0!$rsrbCi{yzPM!$FCm9_lb2B+k_66d8 zAifC12RI!k$BR2oUI@fDnH?ufvp7zU1>*TY{1AvQa63-Umvo%G5r|*1I!@MRbDW$D m#Os0hBM?8}b(~x;Z8>>8yBsr@5MAwK<1!lVUYvYGS`Pr0hU?k@ diff --git a/src/test_edgepi/unit_tests/test_calibration/test_access_eeprom.py b/src/test_edgepi/unit_tests/test_calibration/test_access_eeprom.py index 44cbbbc9..f4058cad 100644 --- a/src/test_edgepi/unit_tests/test_calibration/test_access_eeprom.py +++ b/src/test_edgepi/unit_tests/test_calibration/test_access_eeprom.py @@ -1,7 +1,8 @@ '''unit test for access eeprom''' # pylint: disable=C0413 - +# pylint: disable=no-name-in-module +# https://github.com/protocolbuffers/protobuf/issues/10372 from unittest import mock import os @@ -12,6 +13,7 @@ import pytest from edgepi.calibration.eeprom_constants import MessageFieldNumber from edgepi.calibration.edgepi_eeprom import EdgePiEEPROM +from edgepi.calibration.calibration_constants import CalibParam from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout @pytest.fixture(name="eeprom") @@ -107,6 +109,54 @@ def test_get_message_of_interest(mocker, msg, eeprom): msg_of_interest = eeprom.get_message_of_interest(msg) assert msg_of_interest == memory_contents.ListFields()[msg.value -1][1] + +dac_dict_calib = {0:CalibParam(gain = 1.02383653, offset=-0.0164757), + 1:CalibParam(gain = 1.02283154, offset=-0.018963), + 2:CalibParam(gain = 1.02610898, offset=-0.0153855), + 3:CalibParam(gain = 1.02465811, offset=-0.0182012), + 4:CalibParam(gain = 1.02623188, offset=-0.0179865), + 5:CalibParam(gain = 1.02696733, offset=-0.0169919), + 6:CalibParam(gain = 1.0248366, offset=-0.0195936), + 7:CalibParam(gain = 1.02198715, offset=-0.0179717)} + +adc_dict_calib = {0:CalibParam(gain = 0.998441907, offset=0.035948182), + 1:CalibParam(gain = 0.998551392, offset=0.03190953), + 2:CalibParam(gain = 1.004123580, offset=-0.039846713), + 3:CalibParam(gain = 0.996197528, offset=0.05191299), + 4:CalibParam(gain = 1.000529260, offset=0.00375247), + 5:CalibParam(gain = 0.995760365, offset=0.05806301), + 6:CalibParam(gain = 0.993060022, offset=0.09193925), + 7:CalibParam(gain = 0.997010247, offset=0.04080028), + 8:CalibParam(gain = 0.998583581, offset=-0.004391864), + 9:CalibParam(gain = 0.996344494, offset=0.09228059), + 10:CalibParam(gain = 0.995856966, offset=0.05618589), + 11:CalibParam(gain = 0.997157199, offset=-0.049672102)} + +rtd_dict_calib = {0:CalibParam(gain = 1, offset=0)} +rtd_dict_hw= {0:1985.60} +tc_dict_calib = {0:CalibParam(gain = 1.024272873, offset=-0.018334615)} +tc_dict_hw = {0:1} + + +KEYS = '-----BEGIN RSA PRIVATE KEY-----\r\nMIIEpQIBAAKCAQEAnwu+S/OI3Hl0BCNQASv0HU5Jc4KUT2X4/tLykG+T\ +mZQcd6pE\r\nv7fji6ZoW/dl8dKwwdi/cfSS/J5Iv+5FwQU4KGNBbhVAnmJeLd+PMUT4bQTf9rVF\r\nHsDoIPoQLDH7jmBu8ai\ +7jQ0hY5SqPbynPGELFrk/vEpHwg/8fO4lbw1YxwgGc0SR\r\n8k1tFdi4On7NymBiv88HOsrrziAPGCd7Hc07s+SdFQF+nDPidy\ +M1pMqvUC25c5Sk\r\ncsrBlMgmcSRY8y6MJFPObg0ahLsI/YT+jT2G6AioQOz9ZJ89DSzjEfoFK9KlIzq1\r\n46THPR8Tdc9qu\ +chsqfX1zvxKdrQPbdtC7ZnMhQIDAQABAoIBAQCccv3PUpGXZzVz\r\neJUTgfwQ89iW8qUXcVS8vh7za35CvYo/QFN+T9JapefU\ +R4mVlk5fcOnpm88XBlDD\r\n1AvzskGqoPBU7DzzUAoaj+YYbiL9gqUY1vlWJiZxgep0vvoX9M5Nk1BikL7+aNgK\r\nANB1OXS\ +h9ro2as8pm3YgIlbaZcOli7doqtDM4kzxpKOhSAwtQqAS15GwMsKyhs1q\r\nvN6BqTBQE7XjdO5k1GCT4+vWEnptKMlLxi/zj1\ +uAXuAmujKHf3FcNqnrmNQ2v5+g\r\nNmuFCiknrtK5p5va67g6JgWqy45EG5CJLupIpM31xmewFXtlsfh3/fYSzkZqK9jX\r\nH\ +g/Wq7ShAoGBAMqzZTr2kjxtP0UjN4S5L0da7k4UX+4GEJRrQgG6RUgrL5eq4tfc\r\nT4DU7mp7SAb7FVwZmJ5kXZ33aQBF6UYR\ +uIpzUWRT+QOfzeTeJSQGAR8Ng/STNaUt\r\nD9XalRJSYn49LMGTgFebKJakIUC7lZ0ZZxpP1yFZbmYtJN1xFB/jhfGdAoGBAMj\ +d\r\nwuzc5VPJV5fQte6lTcnTzkqnPXnSvpf4sK+22i/1xGi0kbdimQiXHPj2xnwQmygN\r\n3a+l2ysChimOx2qqVdeFQbAveK\ +wYYSk41R10PmsQE14CgREN3r1XcXGz4mqXpL8l\r\n7Ry2HOIDQjTRVye2YdRO0zu3+egdFz4UTnxE8yYJAoGBAIM5+MNfdfTg1\ +SExV3P5\r\nX35WhAjQb/psurcbaTQtH0VFkB4kZ49P9bh2IZOWFF9Qldd2SrPgTitCTRv8JrVS\r\nK6KWXY8SPhf2kRkmJ+1W\ +ZctwuIjR9Nzme2X7iJ6/7zvC5wK7N0+AB5rezxhVWNrH\r\n41PJdIEGoM5NU5x45IpwhfqRAoGANpYdbOUy5SwoQ7eSWYJOu3R\ +18U+1oy+kYART\r\nb80PSk1NzO6VUvLWh8EZPIdDtV+F6sKp5hv6jZun/g8xHkmf/mvWSBz+fDY74Uny\r\nkIiQlePOf5PKo2\ +nTiD0FNVMfSrxfJxsVbuIGw10DVvs05jPoLhwlx2rd3ThaoqI+\r\nGgNa2JECgYEAwEEEq7dxGXYmlIhTs5IiEleLjBydQ9B1P\ +8zIIApLJdHuu50K7ifq\r\nVYWC0QMrAr4lWmJ3ZAmewtrgDh4/6JBWKdpKfX6qm88MpID0arS+jJkQBuMNIafI\r\nGqnLR1sn\ +5N91UjPItE3NPhYX5LvQMjIuHt8AiyNepTxS32VzVTx2z+A=\r\n-----END RSA PRIVATE KEY-----\r\n' + def test_get_edgepi_reserved_data(mocker, eeprom): # pylint: disable=protected-access mocker.patch( @@ -114,13 +164,27 @@ def test_get_edgepi_reserved_data(mocker, eeprom): return_value = read_binfile()) memory_contents = EepromLayout() memory_contents.ParseFromString(read_binfile()) - edgepi_eeprom_dataclass = eeprom.get_edgepi_reserved_data() - assert edgepi_eeprom_dataclass.dac_calib_parms is not None - assert edgepi_eeprom_dataclass.adc_calib_parms is not None - assert edgepi_eeprom_dataclass.rtd_calib_parms is not None - assert edgepi_eeprom_dataclass.tc_calib_parms is not None - assert edgepi_eeprom_dataclass.config_key is not None - assert edgepi_eeprom_dataclass.data_key is not None - assert edgepi_eeprom_dataclass.serial is not None - assert edgepi_eeprom_dataclass.model is not None - assert edgepi_eeprom_dataclass.client_id is not None + eeprom_data = eeprom.get_edgepi_reserved_data() + for key, value in eeprom_data.dac_calib_params.items(): + assert value.gain == pytest.approx(dac_dict_calib[key].gain) + assert value.offset == pytest.approx(dac_dict_calib[key].offset) + for key, value in eeprom_data.adc_calib_params.items(): + assert value.gain == pytest.approx(adc_dict_calib[key].gain) + assert value.offset == pytest.approx(adc_dict_calib[key].offset) + for key, value in eeprom_data.tc_calib_params.items(): + assert value.gain == pytest.approx(tc_dict_calib[key].gain) + assert value.offset == pytest.approx(tc_dict_calib[key].offset) + for key, value in eeprom_data.tc_hw_params.items(): + assert value == pytest.approx(tc_dict_hw[key]) + for key, value in eeprom_data.rtd_calib_params.items(): + assert value.gain == pytest.approx(rtd_dict_calib[key].gain) + assert value.offset == pytest.approx(rtd_dict_calib[key].offset) + for key, value in eeprom_data.rtd_hw_params.items(): + assert value == pytest.approx(rtd_dict_hw[key]) + assert eeprom_data.serial == '20221110-021' + assert eeprom_data.model == 'EdgePi-Bearbone' + assert eeprom_data.client_id == 'SO-2022-1023' + assert eeprom_data.config_key.certificate == KEYS + assert eeprom_data.config_key.private == KEYS + assert eeprom_data.data_key.certificate == KEYS + assert eeprom_data.data_key.certificate == KEYS diff --git a/src/test_edgepi/unit_tests/test_calibration/test_eeprom_constants.py b/src/test_edgepi/unit_tests/test_calibration/test_eeprom_constants.py deleted file mode 100644 index 3d693060..00000000 --- a/src/test_edgepi/unit_tests/test_calibration/test_eeprom_constants.py +++ /dev/null @@ -1,53 +0,0 @@ -'''unit test for access eeprom''' -# pylint: disable=C0413 -# pylint: disable=no-member -from unittest import mock -import os -PATH = os.path.dirname(os.path.abspath(__file__)) -import sys -sys.modules['periphery'] = mock.MagicMock() - -from edgepi.calibration.eeprom_constants import EdgePiEEPROMData, Keys -from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout - -def read_binfile(): - """Read the dummy serializedFile and return byte string""" - with open(PATH+"/serializedFile","rb") as fd: - b_string = fd.read() - return b_string - -def test_edgepi_eeprom_data(): - memory_map = EepromLayout() - memory_map.ParseFromString(read_binfile()) - eeprom_data = EdgePiEEPROMData() - eeprom_data.dac_calib_parms=eeprom_data.message_to_dict(memory_map.dac) - eeprom_data.adc_calib_parms=eeprom_data.message_to_dict(memory_map.adc) - eeprom_data.rtd_calib_parms=eeprom_data.message_to_dict(memory_map.rtd) - eeprom_data.tc_calib_parms=eeprom_data.message_to_dict(memory_map.tc) - eeprom_data.config_key=eeprom_data.keys_to_str(memory_map.config_key) - eeprom_data.data_key=eeprom_data.keys_to_str(memory_map.data_key) - eeprom_data.serial=memory_map.serial_number - eeprom_data.model=memory_map.model - eeprom_data.client_id=memory_map.client_id - assert isinstance(eeprom_data.dac_calib_parms, dict) - assert isinstance(eeprom_data.adc_calib_parms, dict) - assert isinstance(eeprom_data.rtd_calib_parms, dict) - assert isinstance(eeprom_data.tc_calib_parms, dict) - assert isinstance(eeprom_data.config_key, Keys) - assert isinstance(eeprom_data.config_key, Keys) - assert isinstance(eeprom_data.data_key, Keys) - assert isinstance(eeprom_data.data_key, Keys) - assert isinstance(eeprom_data.serial, str) - assert isinstance(eeprom_data.model, str) - assert isinstance(eeprom_data.client_id, str) - assert eeprom_data.dac_calib_parms == eeprom_data.message_to_dict(memory_map.dac) - assert eeprom_data.adc_calib_parms==eeprom_data.message_to_dict(memory_map.adc) - assert eeprom_data.rtd_calib_parms==eeprom_data.message_to_dict(memory_map.rtd) - assert eeprom_data.tc_calib_parms==eeprom_data.message_to_dict(memory_map.tc) - assert eeprom_data.config_key.certificate == memory_map.config_key.certificate - assert eeprom_data.config_key.private == memory_map.config_key.private_key - assert eeprom_data.data_key.certificate == memory_map.data_key.certificate - assert eeprom_data.data_key.private == memory_map.data_key.private_key - assert eeprom_data.serial == memory_map.serial_number - assert eeprom_data.model == memory_map.model - assert eeprom_data.client_id == memory_map.client_id diff --git a/src/test_edgepi/unit_tests/test_calibration/test_protobuf_mapping.py b/src/test_edgepi/unit_tests/test_calibration/test_protobuf_mapping.py new file mode 100644 index 00000000..8a0d7d52 --- /dev/null +++ b/src/test_edgepi/unit_tests/test_calibration/test_protobuf_mapping.py @@ -0,0 +1,96 @@ +'''unit test for access eeprom''' +# pylint: disable=C0413 +# pylint: disable=no-member +# pylint: disable=no-name-in-module +# https://github.com/protocolbuffers/protobuf/issues/10372 +from unittest import mock +import os +PATH = os.path.dirname(os.path.abspath(__file__)) +import sys +sys.modules['periphery'] = mock.MagicMock() + +import pytest +from edgepi.calibration.protobuf_mapping import EdgePiEEPROMData +from edgepi.calibration.calibration_constants import CalibParam +from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout + +def read_binfile(): + """Read the dummy serializedFile and return byte string""" + with open(PATH+"/serializedFile","rb") as fd: + b_string = fd.read() + return b_string + +dac_dict_calib = {0:CalibParam(gain = 1.02383653, offset=-0.0164757), + 1:CalibParam(gain = 1.02283154, offset=-0.018963), + 2:CalibParam(gain = 1.02610898, offset=-0.0153855), + 3:CalibParam(gain = 1.02465811, offset=-0.0182012), + 4:CalibParam(gain = 1.02623188, offset=-0.0179865), + 5:CalibParam(gain = 1.02696733, offset=-0.0169919), + 6:CalibParam(gain = 1.0248366, offset=-0.0195936), + 7:CalibParam(gain = 1.02198715, offset=-0.0179717)} + +adc_dict_calib = {0:CalibParam(gain = 0.998441907, offset=0.035948182), + 1:CalibParam(gain = 0.998551392, offset=0.03190953), + 2:CalibParam(gain = 1.004123580, offset=-0.039846713), + 3:CalibParam(gain = 0.996197528, offset=0.05191299), + 4:CalibParam(gain = 1.000529260, offset=0.00375247), + 5:CalibParam(gain = 0.995760365, offset=0.05806301), + 6:CalibParam(gain = 0.993060022, offset=0.09193925), + 7:CalibParam(gain = 0.997010247, offset=0.04080028), + 8:CalibParam(gain = 0.998583581, offset=-0.004391864), + 9:CalibParam(gain = 0.996344494, offset=0.09228059), + 10:CalibParam(gain = 0.995856966, offset=0.05618589), + 11:CalibParam(gain = 0.997157199, offset=-0.049672102)} + +rtd_dict_calib = {0:CalibParam(gain = 1, offset=0)} +rtd_dict_hw= {0:1985.60} +tc_dict_calib = {0:CalibParam(gain = 1.024272873, offset=-0.018334615)} +tc_dict_hw = {0:1} + + +KEYS = '-----BEGIN RSA PRIVATE KEY-----\r\nMIIEpQIBAAKCAQEAnwu+S/OI3Hl0BCNQASv0HU5Jc4KUT2X4/tLykG+T\ +mZQcd6pE\r\nv7fji6ZoW/dl8dKwwdi/cfSS/J5Iv+5FwQU4KGNBbhVAnmJeLd+PMUT4bQTf9rVF\r\nHsDoIPoQLDH7jmBu8ai\ +7jQ0hY5SqPbynPGELFrk/vEpHwg/8fO4lbw1YxwgGc0SR\r\n8k1tFdi4On7NymBiv88HOsrrziAPGCd7Hc07s+SdFQF+nDPidy\ +M1pMqvUC25c5Sk\r\ncsrBlMgmcSRY8y6MJFPObg0ahLsI/YT+jT2G6AioQOz9ZJ89DSzjEfoFK9KlIzq1\r\n46THPR8Tdc9qu\ +chsqfX1zvxKdrQPbdtC7ZnMhQIDAQABAoIBAQCccv3PUpGXZzVz\r\neJUTgfwQ89iW8qUXcVS8vh7za35CvYo/QFN+T9JapefU\ +R4mVlk5fcOnpm88XBlDD\r\n1AvzskGqoPBU7DzzUAoaj+YYbiL9gqUY1vlWJiZxgep0vvoX9M5Nk1BikL7+aNgK\r\nANB1OXS\ +h9ro2as8pm3YgIlbaZcOli7doqtDM4kzxpKOhSAwtQqAS15GwMsKyhs1q\r\nvN6BqTBQE7XjdO5k1GCT4+vWEnptKMlLxi/zj1\ +uAXuAmujKHf3FcNqnrmNQ2v5+g\r\nNmuFCiknrtK5p5va67g6JgWqy45EG5CJLupIpM31xmewFXtlsfh3/fYSzkZqK9jX\r\nH\ +g/Wq7ShAoGBAMqzZTr2kjxtP0UjN4S5L0da7k4UX+4GEJRrQgG6RUgrL5eq4tfc\r\nT4DU7mp7SAb7FVwZmJ5kXZ33aQBF6UYR\ +uIpzUWRT+QOfzeTeJSQGAR8Ng/STNaUt\r\nD9XalRJSYn49LMGTgFebKJakIUC7lZ0ZZxpP1yFZbmYtJN1xFB/jhfGdAoGBAMj\ +d\r\nwuzc5VPJV5fQte6lTcnTzkqnPXnSvpf4sK+22i/1xGi0kbdimQiXHPj2xnwQmygN\r\n3a+l2ysChimOx2qqVdeFQbAveK\ +wYYSk41R10PmsQE14CgREN3r1XcXGz4mqXpL8l\r\n7Ry2HOIDQjTRVye2YdRO0zu3+egdFz4UTnxE8yYJAoGBAIM5+MNfdfTg1\ +SExV3P5\r\nX35WhAjQb/psurcbaTQtH0VFkB4kZ49P9bh2IZOWFF9Qldd2SrPgTitCTRv8JrVS\r\nK6KWXY8SPhf2kRkmJ+1W\ +ZctwuIjR9Nzme2X7iJ6/7zvC5wK7N0+AB5rezxhVWNrH\r\n41PJdIEGoM5NU5x45IpwhfqRAoGANpYdbOUy5SwoQ7eSWYJOu3R\ +18U+1oy+kYART\r\nb80PSk1NzO6VUvLWh8EZPIdDtV+F6sKp5hv6jZun/g8xHkmf/mvWSBz+fDY74Uny\r\nkIiQlePOf5PKo2\ +nTiD0FNVMfSrxfJxsVbuIGw10DVvs05jPoLhwlx2rd3ThaoqI+\r\nGgNa2JECgYEAwEEEq7dxGXYmlIhTs5IiEleLjBydQ9B1P\ +8zIIApLJdHuu50K7ifq\r\nVYWC0QMrAr4lWmJ3ZAmewtrgDh4/6JBWKdpKfX6qm88MpID0arS+jJkQBuMNIafI\r\nGqnLR1sn\ +5N91UjPItE3NPhYX5LvQMjIuHt8AiyNepTxS32VzVTx2z+A=\r\n-----END RSA PRIVATE KEY-----\r\n' + +def test_edgepi_eeprom_data(): + memory_map = EepromLayout() + memory_map.ParseFromString(read_binfile()) + eeprom_data = EdgePiEEPROMData(memory_map) + for key, value in eeprom_data.dac_calib_params.items(): + assert value.gain == pytest.approx(dac_dict_calib[key].gain) + assert value.offset == pytest.approx(dac_dict_calib[key].offset) + for key, value in eeprom_data.adc_calib_params.items(): + assert value.gain == pytest.approx(adc_dict_calib[key].gain) + assert value.offset == pytest.approx(adc_dict_calib[key].offset) + for key, value in eeprom_data.tc_calib_params.items(): + assert value.gain == pytest.approx(tc_dict_calib[key].gain) + assert value.offset == pytest.approx(tc_dict_calib[key].offset) + for key, value in eeprom_data.tc_hw_params.items(): + assert value == pytest.approx(tc_dict_hw[key]) + for key, value in eeprom_data.rtd_calib_params.items(): + assert value.gain == pytest.approx(rtd_dict_calib[key].gain) + assert value.offset == pytest.approx(rtd_dict_calib[key].offset) + for key, value in eeprom_data.rtd_hw_params.items(): + assert value == pytest.approx(rtd_dict_hw[key]) + assert eeprom_data.serial == '20221110-021' + assert eeprom_data.model == 'EdgePi-Bearbone' + assert eeprom_data.client_id == 'SO-2022-1023' + assert eeprom_data.config_key.certificate == KEYS + assert eeprom_data.config_key.private == KEYS + assert eeprom_data.data_key.certificate == KEYS + assert eeprom_data.data_key.certificate == KEYS diff --git a/src/test_edgepi/unit_tests/test_dac/test_dac_commands.py b/src/test_edgepi/unit_tests/test_dac/test_dac_commands.py index 54cc0e1a..3703839a 100644 --- a/src/test_edgepi/unit_tests/test_dac/test_dac_commands.py +++ b/src/test_edgepi/unit_tests/test_dac/test_dac_commands.py @@ -19,7 +19,7 @@ def fixture_test_dac_ops(mocker): return_value = read_binfile()) eeprom = EdgePiEEPROM() eeprom_data = eeprom.get_edgepi_reserved_data() - dac_calib_params = eeprom_data.dac_calib_parms + dac_calib_params = eeprom_data.dac_calib_params dac_ops = DACCommands(dac_calib_params) return dac_ops @@ -109,7 +109,7 @@ def test_dac_generate_write_and_update_command(a, b, c, dac_ops): @pytest.mark.parametrize("ch, expected, dac_gain, result", - [(1, 2.345, 1, 30282), (0, 2.345, 2, 15285), (3, 2.345, 1, 30341)]) + [(1, 2.345, 1, 30293), (0, 2.345, 2, 15221), (3, 2.345, 1, 30229)]) def test_dac_voltage_to_code(ch, expected, dac_gain, result, dac_ops): assert dac_ops.voltage_to_code(ch, expected, dac_gain) == result @@ -118,8 +118,8 @@ def test_dac_voltage_to_code(ch, expected, dac_gain, result, dac_ops): "ch, code, dac_gain, result", [ (1, 33798, 1, 2.619), - (0, 33798, 2, 5.239), - (3, 33798, 1, 2.614), + (0, 33798, 2, 5.263), + (3, 33798, 1, 2.624), ], ) def test_dac_code_to_voltage(ch, code, dac_gain, result, dac_ops): diff --git a/src/test_edgepi/unit_tests/test_dac/test_edgepi_dac.py b/src/test_edgepi/unit_tests/test_dac/test_edgepi_dac.py index b7ba2e0d..7fa795ac 100644 --- a/src/test_edgepi/unit_tests/test_dac/test_edgepi_dac.py +++ b/src/test_edgepi/unit_tests/test_dac/test_edgepi_dac.py @@ -8,6 +8,8 @@ sys.modules['periphery'] = mock.MagicMock() # pylint: disable=wrong-import-position +# pylint: disable=no-name-in-module +# https://github.com/protocolbuffers/protobuf/issues/10372 # pylint: disable=protected-access import pytest @@ -19,8 +21,10 @@ EdgePiDacCom as COM, ) from edgepi.dac.edgepi_dac import EdgePiDAC -from edgepi.calibration.eeprom_constants import EdgePiEEPROMData from edgepi.calibration.calibration_constants import CalibParam +from edgepi.calibration.protobuf_mapping import EdgePiEEPROMData +from edgepi.calibration.eeprom_mapping_pb2 import EepromLayout +from test_edgepi.unit_tests.test_calibration.read_serialized import read_binfile dummy_calib_param_dict = {0:CalibParam(gain=1,offset=0), 1:CalibParam(gain=1,offset=0), @@ -35,17 +39,25 @@ def fixture_test_dac(mocker): mocker.patch("edgepi.peripherals.spi.SPI") mocker.patch("edgepi.dac.edgepi_dac.EdgePiGPIO") + eelayout= EepromLayout() + eelayout.ParseFromString(read_binfile()) mocker.patch("edgepi.dac.edgepi_dac.EdgePiEEPROM.get_edgepi_reserved_data", - return_value = EdgePiEEPROMData(dac_calib_parms=dummy_calib_param_dict)) - yield EdgePiDAC() + return_value = EdgePiEEPROMData(eelayout)) + dac = EdgePiDAC() + dac.dac_ops.dict_calib_param = dummy_calib_param_dict + yield dac @pytest.fixture(name="dac_mock_periph") def fixture_test_dac_write_voltage(mocker): mocker.patch("edgepi.peripherals.spi.SPI") mocker.patch("edgepi.peripherals.i2c.I2C") + eelayout= EepromLayout() + eelayout.ParseFromString(read_binfile()) mocker.patch("edgepi.dac.edgepi_dac.EdgePiEEPROM.get_edgepi_reserved_data", - return_value = EdgePiEEPROMData(dac_calib_parms=dummy_calib_param_dict)) - yield EdgePiDAC() + return_value = EdgePiEEPROMData(eelayout)) + dac = EdgePiDAC() + dac.dac_ops.dict_calib_param = dummy_calib_param_dict + yield dac _default_power_modes = { @@ -178,9 +190,12 @@ def test_dac_send_to_gpio_pins(mocker, analog_out, pin_name, voltage, mock_name) mocker.patch("edgepi.gpio.edgepi_gpio_expander.I2CDevice") mock_set = mocker.patch("edgepi.dac.edgepi_dac.EdgePiGPIO.set_expander_pin") mock_clear = mocker.patch("edgepi.dac.edgepi_dac.EdgePiGPIO.clear_expander_pin") + eelayout= EepromLayout() + eelayout.ParseFromString(read_binfile()) mocker.patch("edgepi.dac.edgepi_dac.EdgePiEEPROM.get_edgepi_reserved_data", - return_value = EdgePiEEPROMData(dac_calib_parms=dummy_calib_param_dict)) + return_value = EdgePiEEPROMData(eelayout)) dac = EdgePiDAC() + dac.dac_ops.dict_calib_param = dummy_calib_param_dict dac._EdgePiDAC__send_to_gpio_pins(analog_out, voltage) # check correct clause is entered depending on voltage written if voltage > 0: @@ -237,9 +252,12 @@ def test_enable_dac_gain(mocker, enable, result, mocker_values): return_value = (mocker_values[0], mocker_values[1], mocker_values[2])) set_dac_gain = mocker.patch("edgepi.dac.edgepi_dac.EdgePiGPIO.set_expander_pin") clear_dac_gain = mocker.patch("edgepi.dac.edgepi_dac.EdgePiGPIO.clear_expander_pin") + eelayout= EepromLayout() + eelayout.ParseFromString(read_binfile()) mocker.patch("edgepi.dac.edgepi_dac.EdgePiEEPROM.get_edgepi_reserved_data", - return_value = EdgePiEEPROMData(dac_calib_parms=dummy_calib_param_dict)) + return_value = EdgePiEEPROMData(eelayout)) dac = EdgePiDAC() + dac.dac_ops.dict_calib_param = dummy_calib_param_dict # pylint: disable=expression-not-assigned assert dac.enable_dac_gain(enable) == result set_dac_gain.assert_called_once_with("DAC_GAIN") if enable \ @@ -260,9 +278,12 @@ def test_get_state(mocker, analog_out, code, voltage, gain, result, mock_val): mocker.patch("edgepi.gpio.edgepi_gpio_expander.I2CDevice") mocker.patch("edgepi.dac.edgepi_dac.EdgePiGPIO.get_pin_direction", return_value = mock_val[3]) mocker.patch("edgepi.peripherals.spi.SpiDevice.transfer", return_value=mock_val[0:3]) + eelayout= EepromLayout() + eelayout.ParseFromString(read_binfile()) mocker.patch("edgepi.dac.edgepi_dac.EdgePiEEPROM.get_edgepi_reserved_data", - return_value = EdgePiEEPROMData(dac_calib_parms=dummy_calib_param_dict)) + return_value = EdgePiEEPROMData(eelayout)) dac = EdgePiDAC() + dac.dac_ops.dict_calib_param = dummy_calib_param_dict code_val, voltage_val, gain_state = dac.get_state(analog_out, code, voltage, gain) assert code_val == result[0] assert pytest.approx(voltage_val, 1e-3) == voltage_val diff --git a/src/test_edgepi/unit_tests/test_gpio/test_edgpepi_gpio_chip.py b/src/test_edgepi/unit_tests/test_gpio/test_edgpepi_gpio_chip.py index d710789a..866fdc1a 100644 --- a/src/test_edgepi/unit_tests/test_gpio/test_edgpepi_gpio_chip.py +++ b/src/test_edgepi/unit_tests/test_gpio/test_edgpepi_gpio_chip.py @@ -24,7 +24,7 @@ def test_edgepi_gpio_init(): @pytest.mark.parametrize("pin_name, mock_value, result", [("DIN1",[True], True)]) def test_read_gpio_pin_state(mocker, pin_name, mock_value, result): mocker.patch("edgepi.peripherals.gpio.GpioDevice.open_gpio") - mocker.patch("edgepi.peripherals.gpio.GpioDevice.close") + mocker.patch("edgepi.peripherals.gpio.GpioDevice.close_gpio") mocker.patch("edgepi.peripherals.gpio.GpioDevice.read_state", return_value = mock_value[0]) gpio = EdgePiGPIOChip() assert gpio.read_gpio_pin_state(pin_name) == result @@ -33,7 +33,7 @@ def test_read_gpio_pin_state(mocker, pin_name, mock_value, result): ("DIN1",[False], False)]) def test_write_gpio_pin_state(mocker, pin_name, mock_value, result): mocker.patch("edgepi.peripherals.gpio.GpioDevice.open_gpio") - mocker.patch("edgepi.peripherals.gpio.GpioDevice.close") + mocker.patch("edgepi.peripherals.gpio.GpioDevice.close_gpio") mocker.patch("edgepi.peripherals.gpio.GpioDevice.write_state") mocker.patch("edgepi.peripherals.gpio.GpioDevice.read_state", return_value = mock_value[0]) gpio = EdgePiGPIOChip() diff --git a/tests/integration_tests/test_digital_out/__init__.py b/tests/integration_tests/test_digital_out/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration_tests/test_digital_out/test_digital_out.py b/tests/integration_tests/test_digital_out/test_digital_out.py new file mode 100644 index 00000000..f1989b4d --- /dev/null +++ b/tests/integration_tests/test_digital_out/test_digital_out.py @@ -0,0 +1,36 @@ +'''Integration tests for edgepi_digital_output.py module''' + +import time +import pytest +from edgepi.digital_output.edgepi_digital_output import EdgePiDigitalOutput +from edgepi.gpio.gpio_constants import GpioPins + +@pytest.mark.parametrize("pin_name", [ + (GpioPins.DOUT1), + (GpioPins.DOUT2), + (GpioPins.DOUT3), + (GpioPins.DOUT4), + (GpioPins.DOUT5), + (GpioPins.DOUT6), + (GpioPins.DOUT7), + (GpioPins.DOUT8), +]) +def test_output_high(pin_name): + dout=EdgePiDigitalOutput() + dout.digital_output_state(pin_name, True) + time.sleep(1) + +@pytest.mark.parametrize("pin_name", [ + (GpioPins.DOUT1), + (GpioPins.DOUT2), + (GpioPins.DOUT3), + (GpioPins.DOUT4), + (GpioPins.DOUT5), + (GpioPins.DOUT6), + (GpioPins.DOUT7), + (GpioPins.DOUT8), +]) +def test_output_low(pin_name): + dout=EdgePiDigitalOutput() + dout.digital_output_state(pin_name, False) + time.sleep(1)