<commit_before>#include "depthai/depthai.hpp"

int main(int argc, char** argv) {
    // Options
    bool usage = false, read = true, clear = false;
    std::string path = "";
    if(argc >= 2) {
        std::string op = argv[1];
        if(op == "read") {
            read = true;
        } else if(op == "flash") {
            read = false;
            if(argc >= 3) {
                path = argv[2];
            }
        } else if(op == "clear") {
            clear = true;
            read = false;
        } else if(op == "clear") {
            clear = true;
            read = false;
        } else {
            usage = true;
        }
    } else {
        usage = true;
    }
    if(usage) {
        std::cout << "Usage: " << argv[0] << " [read/flash/clear] [flash: path/to/config/json]" << std::endl;
        return -1;
    }

    // DeviceBootloader configuration
    bool res = false;
    dai::DeviceInfo info;
    std::tie(res, info) = dai::DeviceBootloader::getFirstAvailableDevice();

    if(res) {
        std::cout << "Found device with name: " << info.name << std::endl;
        dai::DeviceBootloader bl(info);

        if(read) {
            std::cout << "Current flashed configuration\n" << bl.readConfigData().dump(4) << std::endl;
        } else {
            std::cout << "Warning! Flashing bootloader config can potentially soft brick your device and should be done with caution." << std::endl;
            std::cout << "Do not unplug your device while the bootloader config is flashing." << std::endl;
            std::cout << "Type 'y' and press enter to proceed, otherwise exits: ";
            std::cin.ignore();
            if(std::cin.get() != 'y') {
                std::cout << "Prompt declined, exiting..." << std::endl;
                return -1;
            }

            bool success;
            std::string error;
            if(clear) {
                std::tie(success, error) = bl.flashConfigClear();
            } else {
                if(path.empty()) {
                    std::tie(success, error) = bl.flashConfig(dai::DeviceBootloader::Config{});
                } else {
                    std::tie(success, error) = bl.flashConfigFile(path);
                }
            }
            if(success) {
                std::cout << "Successfully flashed bootloader configuration\n";
            } else {
                std::cout << "Error flashing bootloader configuration: " << error;
            }
        }

    } else {
        std::cout << "No devices found" << std::endl;
    }

    return 0;
}<commit_msg>Updated bootloader_config example<commit_after>#include "depthai/depthai.hpp"

int main(int argc, char** argv) {
    // Options
    bool usage = false, read = true, clear = false;
    std::string path = "";
    if(argc >= 2) {
        std::string op = argv[1];
        if(op == "read") {
            read = true;
        } else if(op == "flash") {
            read = false;
            if(argc >= 3) {
                path = argv[2];
            }
        } else if(op == "clear") {
            clear = true;
            read = false;
        } else if(op == "clear") {
            clear = true;
            read = false;
        } else {
            usage = true;
        }
    } else {
        usage = true;
    }
    if(usage) {
        std::cout << "Usage: " << argv[0] << " [read/flash/clear] [flash: path/to/config/json]" << std::endl;
        return -1;
    }

    // DeviceBootloader configuration
    bool res = false;
    dai::DeviceInfo info;
    std::tie(res, info) = dai::DeviceBootloader::getFirstAvailableDevice();

    if(res) {
        std::cout << "Found device with name: " << info.name << std::endl;
        dai::DeviceBootloader bl(info);

        try {
            if(read) {
                std::cout << "Current flashed configuration\n" << bl.readConfigData().dump(4) << std::endl;
            } else {
                std::cout << "Warning! Flashing bootloader config can potentially soft brick your device and should be done with caution." << std::endl;
                std::cout << "Do not unplug your device while the bootloader config is flashing." << std::endl;
                std::cout << "Type 'y' and press enter to proceed, otherwise exits: ";
                std::cin.ignore();
                if(std::cin.get() != 'y') {
                    std::cout << "Prompt declined, exiting..." << std::endl;
                    return -1;
                }

                bool success;
                std::string error;
                if(clear) {
                    std::tie(success, error) = bl.flashConfigClear();
                } else {
                    if(path.empty()) {
                        std::tie(success, error) = bl.flashConfig(dai::DeviceBootloader::Config{});
                    } else {
                        std::tie(success, error) = bl.flashConfigFile(path);
                    }
                }
                if(success) {
                    std::cout << "Successfully flashed bootloader configuration\n";
                } else {
                    std::cout << "Error flashing bootloader configuration: " << error;
                }
            }
        } catch (const std::exception& ex) {
            std::cout << "Error accessing config: " << ex.what() << std::endl;
        }

    } else {
        std::cout << "No devices found" << std::endl;
    }

    return 0;
}
{'fraction_non_alphanumeric': 0.14333333333333334, 'fraction_numerical': 0.0033333333333333335, 'mean_word_length': 1.5368717707844057, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 7, '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': '5818940', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1470, 'n_words': 377}