From 2a575bf9b5a4942f60e979161764b9e942699e1e Mon Sep 17 00:00:00 2001 From: Lars Amsel Date: Fri, 4 Jun 2021 08:27:50 +0200 Subject: uhd: Add support for the USRP X410 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lars Amsel Co-authored-by: Michael Auchter Co-authored-by: Martin Braun Co-authored-by: Paul Butler Co-authored-by: Cristina Fuentes Co-authored-by: Humberto Jimenez Co-authored-by: Virendra Kakade Co-authored-by: Lane Kolbly Co-authored-by: Max Köhler Co-authored-by: Andrew Lynch Co-authored-by: Grant Meyerhoff Co-authored-by: Ciro Nishiguchi Co-authored-by: Thomas Vogel --- mpm/lib/i2c/i2cdev_iface.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'mpm/lib/i2c/i2cdev_iface.cpp') diff --git a/mpm/lib/i2c/i2cdev_iface.cpp b/mpm/lib/i2c/i2cdev_iface.cpp index 9d2c6b4b2..b723dea06 100644 --- a/mpm/lib/i2c/i2cdev_iface.cpp +++ b/mpm/lib/i2c/i2cdev_iface.cpp @@ -64,23 +64,29 @@ public: return ret; } - int transfer(std::vector* tx, std::vector* rx, bool do_close) + std::vector transfer( + std::vector& tx, size_t num_rx_bytes, bool do_close) { uint8_t *tx_data = NULL, *rx_data = NULL; size_t tx_len = 0, rx_len = 0; + std::vector rx(num_rx_bytes); - if (tx) { - tx_data = tx->data(); - tx_len = tx->size(); + if (!tx.empty()) { + tx_data = tx.data(); + tx_len = tx.size(); } - if (rx) { - rx_data = rx->data(); - rx_len = rx->size(); + if (num_rx_bytes) { + rx_data = rx.data(); + rx_len = rx.size(); } - int ret = transfer(tx_data, tx_len, rx_data, rx_len, do_close); - return ret; + const int err = transfer(tx_data, tx_len, rx_data, num_rx_bytes, do_close); + if (err) { + throw mpm::runtime_error("I2C Transaction failed!"); + } + + return rx; } private: -- cgit v1.2.3