From e0721771371349ec103d7c4194bf297afda20f87 Mon Sep 17 00:00:00 2001 From: Takashi Matsuoka Date: Tue, 8 Nov 2022 11:59:03 +0900 Subject: [PATCH] Do not set atcai2c.bus = 1 when bus is specified --- python/examples/config.py | 5 +++-- python/examples/create_csr.py | 5 +++-- python/examples/ecdh.py | 5 +++-- python/examples/info.py | 5 +++-- python/examples/key_attestation.py | 5 +++-- python/examples/read_write.py | 5 +++-- python/examples/sign_verify.py | 5 +++-- python/examples/tng_certs.py | 5 +++-- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/python/examples/config.py b/python/examples/config.py index 450b2bc..c7005c6 100644 --- a/python/examples/config.py +++ b/python/examples/config.py @@ -80,8 +80,9 @@ def configure_device(iface='hid', device='ecc', i2c_addr=None, keygen=True, **kw setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/create_csr.py b/python/examples/create_csr.py index 8c68113..f78eb0e 100644 --- a/python/examples/create_csr.py +++ b/python/examples/create_csr.py @@ -101,8 +101,9 @@ def info(iface='hid', device='ecc', **kwargs): setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/ecdh.py b/python/examples/ecdh.py index 11b8d29..d4b20b8 100644 --- a/python/examples/ecdh.py +++ b/python/examples/ecdh.py @@ -48,8 +48,9 @@ def ECDH(slot, iface='hid', **kwargs): # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/info.py b/python/examples/info.py index b900b7b..d989e6d 100644 --- a/python/examples/info.py +++ b/python/examples/info.py @@ -38,8 +38,9 @@ def info(iface='hid', device='ecc', **kwargs): setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/key_attestation.py b/python/examples/key_attestation.py index 35994dd..a21284d 100644 --- a/python/examples/key_attestation.py +++ b/python/examples/key_attestation.py @@ -58,8 +58,9 @@ def init_device(iface='hid', **kwargs): setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/read_write.py b/python/examples/read_write.py index 8e6485f..c42cb20 100644 --- a/python/examples/read_write.py +++ b/python/examples/read_write.py @@ -57,8 +57,9 @@ def read_write(iface='hid', device='ecc', **kwargs): setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/sign_verify.py b/python/examples/sign_verify.py index 573f68a..ed539ef 100644 --- a/python/examples/sign_verify.py +++ b/python/examples/sign_verify.py @@ -50,8 +50,9 @@ def init_device(iface='hid', slot=0, **kwargs): setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS diff --git a/python/examples/tng_certs.py b/python/examples/tng_certs.py index 78d3a53..4350432 100644 --- a/python/examples/tng_certs.py +++ b/python/examples/tng_certs.py @@ -52,8 +52,9 @@ def init_device(iface='hid', **kwargs): setattr(icfg, k, int(v, 16)) # Basic Raspberry Pi I2C check - if 'i2c' == iface and check_if_rpi(): - cfg.cfg.atcai2c.bus = 1 + if 'bus' not in kwargs: + if 'i2c' == iface and check_if_rpi(): + cfg.cfg.atcai2c.bus = 1 # Initialize the stack assert atcab_init(cfg) == ATCA_SUCCESS