|
20 | 20 | */ |
21 | 21 |
|
22 | 22 | #include "deviceinfopage.h" |
| 23 | +#include <iioutil/iiocpp/iiocontext.h> |
| 24 | +#include <iioutil/iiocpp/iioattribute.h> |
| 25 | +#include <iioutil/iiocpp/iioresult.h> |
23 | 26 | #include <QVBoxLayout> |
24 | 27 | #include <QDebug> |
25 | 28 |
|
@@ -55,33 +58,36 @@ void DeviceInfoPage::setupInfoPage() |
55 | 58 |
|
56 | 59 | QString backendName, description; |
57 | 60 | unsigned int major, minor; |
58 | | - char git_tag[8] = "0000000"; |
59 | | - int ret = EXIT_FAILURE; |
60 | | - ret = iio_context_get_version(m_conn->context(), &major, &minor, git_tag); |
61 | | - if(ret) { |
62 | | - qWarning() << "Error, cannot read backend version."; |
63 | | - major = 'x'; |
64 | | - minor = 'x'; |
65 | | - } |
| 61 | + const char *versionTag; |
| 62 | + |
| 63 | + major = IIOContext::get_version_major(m_conn->context()); |
| 64 | + minor = IIOContext::get_version_minor(m_conn->context()); |
| 65 | + versionTag = IIOContext::get_version_tag(m_conn->context()); |
66 | 66 |
|
67 | | - backendName = iio_context_get_name(m_conn->context()); |
68 | | - description = iio_context_get_description(m_conn->context()); |
| 67 | + backendName = IIOContext::get_name(m_conn->context()); |
| 68 | + description = IIOContext::get_description(m_conn->context()); |
69 | 69 |
|
70 | 70 | QString backendText = "IIO context created with %1 backend.\n" |
71 | 71 | "Backend version: %2.%3 (git tag: %4)\n" |
72 | 72 | "Backend description string: %5"; |
73 | 73 | m_backendInfo->setText(backendText.arg(backendName) |
74 | 74 | .arg(QString::number(major)) |
75 | 75 | .arg(QString::number(minor)) |
76 | | - .arg(git_tag) |
| 76 | + .arg(versionTag) |
77 | 77 | .arg(description)); |
78 | 78 |
|
79 | 79 | const char *name; |
80 | 80 | const char *value; |
81 | | - for(int i = 0; i < iio_context_get_attrs_count(m_conn->context()); ++i) { |
82 | | - int ret = iio_context_get_attr(m_conn->context(), i, &name, &value); |
83 | | - if(ret != 0) |
| 81 | + for(int i = 0; i < IIOContext::get_attrs_count(m_conn->context()); ++i) { |
| 82 | + IIOResult<const iio_attr *> res = IIOContext::get_attr(m_conn->context(), i, &name, &value); |
| 83 | + if(!res.ok()) { |
| 84 | + qDebug() << "Error getting attribute at index" << i << "error code:" << res.error(); |
84 | 85 | continue; |
| 86 | + } |
| 87 | + |
| 88 | + // TODO: check that get_static_value_works |
| 89 | + name = IIOAttribute::get_name(res.data()); |
| 90 | + value = IIOAttribute::get_static_value(res.data()); |
85 | 91 |
|
86 | 92 | m_infoPage->update(name, value); |
87 | 93 | } |
|
0 commit comments