<commit_before>/*
 * Author: <NAME> <<EMAIL>>
 * Copyright (c) 2014 Intel Corporation.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mraa/i2c.h"

#include "mraa_internal_types.h"

extern mraa_board_t* plat;

void
print_version()
{
    fprintf(stdout, "Version %s on %s", mraa_get_version(), mraa_get_platform_name());
    if (plat != NULL && plat->sub_platform != NULL)
        fprintf(stdout, " with %s", plat->sub_platform->platform_name);
    fprintf(stdout, "\n");
}

void
print_help()
{
    fprintf(stdout, "version                   Get mraa version and board name\n");
    fprintf(stdout, "list                      List available busses\n");
    fprintf(stdout, "detect bus                List detected devices on specified bus\n");
    fprintf(stdout, "get bus device reg        Get value from specified device register\n");
    fprintf(stdout, "set bus device reg value  Set specified device register to value\n");
}

void
print_command_error()
{
    fprintf(stdout, "Invalid command, options are:\n");
    print_help();
}

void
print_bus(mraa_board_t* board)
{
    int i, bus;
    for (i = 0; i < board->i2c_bus_count; ++i) {
        char* busType;
        switch (board->platform_type) {
            case MRAA_INTEL_GALILEO_GEN1:
            case MRAA_INTEL_GALILEO_GEN2:
            case MRAA_INTEL_EDISON_FAB_C:
            case MRAA_INTEL_DE3815:
            case MRAA_INTEL_MINNOWBOARD_MAX:
            case MRAA_RASPBERRY_PI:
            case MRAA_BEAGLEBONE:
            case MRAA_BANANA:
            case MRAA_UP:
                bus = i;
                busType = "linux";
                break;
            case MRAA_FTDI_FT4222:
                busType = "ft4222";
                bus = mraa_get_sub_platform_id(i);
                break;
            default:
                busType = "unknown";
                break;
        }
        int id = board->i2c_bus[i].bus_id;
        fprintf(stdout, "Bus %3d: id=%02d type=%s ", bus, id, busType);
        if (i == board->def_i2c_bus)
            fprintf(stdout, " default");
        if (id == -1)<commit_msg>mraa-i2c: stop switching on every platform type and assume linux<commit_after>/*
 * Author: <NAME> <<EMAIL>>
 * Copyright (c) 2014 Intel Corporation.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mraa/i2c.h"

#include "mraa_internal_types.h"

extern mraa_board_t* plat;

void
print_version()
{
    fprintf(stdout, "Version %s on %s", mraa_get_version(), mraa_get_platform_name());
    if (plat != NULL && plat->sub_platform != NULL)
        fprintf(stdout, " with %s", plat->sub_platform->platform_name);
    fprintf(stdout, "\n");
}

void
print_help()
{
    fprintf(stdout, "version                   Get mraa version and board name\n");
    fprintf(stdout, "list                      List available busses\n");
    fprintf(stdout, "detect bus                List detected devices on specified bus\n");
    fprintf(stdout, "get bus device reg        Get value from specified device register\n");
    fprintf(stdout, "set bus device reg value  Set specified device register to value\n");
}

void
print_command_error()
{
    fprintf(stdout, "Invalid command, options are:\n");
    print_help();
}

void
print_bus(mraa_board_t* board)
{
    int i, bus;
    for (i = 0; i < board->i2c_bus_count; ++i) {
        char* busType;
        switch (board->platform_type) {
            case MRAA_FTDI_FT4222:
                busType = "ft4222";
                bus = mraa_get_sub_platform_id(i);
                break;
            default:
                busType = "linux";
                bus = i;
                break;
        }
        int id = board->i2c_bus[i].bus_id;
        fprintf(stdout, "Bus %3d: id=%02d type=%s ", bus, id, busType);
        if (i == board->def_i2c_bus)
            fprintf(stdout, " default");
        if (id == -1)
{'fraction_non_alphanumeric': 0.09561490273656446, 'fraction_numerical': 0.008077810748433894, 'mean_word_length': 2.7613143211407314, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 31, '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': '7178011', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1779, 'n_words': 647}