<commit_before>/*
 * SDR device I/O base class and various utility functions
 */
#pragma once

#include <QObject>
#include <QSettings>
#include <QString>
#include <QWidget>

#include "nanosdr/common/datatypes.h"


/* clang-format off */
// Error codes used for return values
#define SDR_DEVICE_OK           0
#define SDR_DEVICE_ERROR       -1   // Other unspecified error
#define SDR_DEVICE_ELIB        -2   // Error loading driver library
#define SDR_DEVICE_ENOTFOUND   -3   // Device not found
#define SDR_DEVICE_EBUSY       -4   // Device is busy
#define SDR_DEVICE_EPERM       -5   // Insuficcient permissions to open device
#define SDR_DEVICE_EOPEN       -6   // Other error while trying to open device
#define SDR_DEVICE_ENOTAVAIL   -7   // Function not available for this device
#define SDR_DEVICE_ERANGE      -8   // Parameter out of range
/* clang-format on */

typedef struct {
    bool    driver_is_loaded;
    bool    device_is_open;
    bool    rx_is_running;
} sdr_device_status_t;

typedef struct {
    quint64     rx_samples;
    quint64     rx_overruns;
} sdr_device_stats_t;

class SdrDevice : public QObject
{
    Q_OBJECT

public:
    explicit SdrDevice(QObject *parent = nullptr);

    virtual int         open(void) = 0;
    virtual int         close(void) = 0;
    virtual int         readSettings(const QSettings &s) = 0;<commit_msg>Add error code for failed device init<commit_after>/*
 * SDR device I/O base class and various utility functions
 */
#pragma once

#include <QObject>
#include <QSettings>
#include <QString>
#include <QWidget>

#include "nanosdr/common/datatypes.h"


/* clang-format off */
// Error codes used for return values
#define SDR_DEVICE_OK           0
#define SDR_DEVICE_ERROR       -1   // Other unspecified error
#define SDR_DEVICE_ELIB        -2   // Error loading driver library
#define SDR_DEVICE_ENOTFOUND   -3   // Device not found
#define SDR_DEVICE_EBUSY       -4   // Device is busy
#define SDR_DEVICE_EPERM       -5   // Insuficcient permissions to open device
#define SDR_DEVICE_EOPEN       -6   // Other error while trying to open device
#define SDR_DEVICE_EINIT       -7   // Error trying to initialize device
#define SDR_DEVICE_ENOTAVAIL   -8   // Function not available for this device
#define SDR_DEVICE_ERANGE      -9   // Parameter out of range
/* clang-format on */

typedef struct {
    bool    driver_is_loaded;
    bool    device_is_open;
    bool    rx_is_running;
} sdr_device_status_t;

typedef struct {
    quint64     rx_samples;
    quint64     rx_overruns;
} sdr_device_stats_t;

class SdrDevice : public QObject
{
    Q_OBJECT

public:
    explicit SdrDevice(QObject *parent = nullptr);

    virtual int         open(void) = 0;
    virtual int         close(void) = 0;
    virtual int         readSettings(const QSettings &s) = 0;
{'fraction_non_alphanumeric': 0.07612949128424049, 'fraction_numerical': 0.011739594450373533, 'mean_word_length': 2.8258503401360544, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1654208', 'n_tokens_mistral': 923, 'n_tokens_neox': 895, 'n_words': 281}