<commit_before>/*
 *  dht11.c:
 *  Simple test program to test the wiringPi functions
 *  DHT11 test
 *
 *  https://github.com/ook/dht11-json/blob/master/dht11.c
 *  http://blogs.msdn.com/b/laurelle/archive/2015/04/11/create-a-dht11-c-library-using-wiringpi-on-raspberrypi-and-use-it-in-mono-c.aspx
 */

#include <wiringPi.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#define MAXTIMINGS  85

#define DEBUG

typedef enum {
    false,
    true
} bool;

int dht11_dat[5] = { 0, 0, 0, 0, 0 };
int PIN;
// char* model[];
float datas[2];

const char* GPIO_PREFIX = "G:";
const char* WIRING_PREFIX = "W:";
const int PHY_PIN[] = {
    3,
    5,
    7, 8,
    10,
    11, 12,
    13, 14,
    15, 16,
    17, 18,
    19,
    21, 22,
    23, 24,
    26,
    27, 28,
    29,
    31, 32,
    33,
    35, 36,
    37, 38,
    40
};

const int GPIO_PIN[] = {
    2,
    3,
    4, 14,
    15,
    17, 18,
    27,
    22, 23,
    24,
    10,
    9, 25,
    11, 8,
    7,
    0, 1,
    5,
    6, 12,
    13,
    19, 16,
    26, 20,
    21
};

const int WIRING_PIN[] = {
    8,
    9,
    7, 15,
    16,
    0, 1,
    2,
    3, 4,
    5,
    12,
    13, 6,
    14, 10,
    11,
    30, 31,
    21,
    22, 26,
    23,
    24, 27,
    25, 28,
    29
};

void printMessage(bool result, char message[]);
bool checkPin(char* pin);
bool read_dht11_dat();

int main(int argc, char* argv[]) {
    #ifdef DEBUG
    printf("argument count : %d\n", argc);
    #endif
    if (argc != 5) {
        printf("Usage : sudo ./Raspberry_DHT11 -s [model] -g [G:PIN|W:PIN]\n");
        printf("Example : sudo ./Raspberry_DHT11 -s DHT11 -g G:18 => DHT11, GPIO_18\n");
        printf("Example : sudo ./Raspberry_DHT11 -s DHT11 -g W:1 => DHT11, WiringPi 1\n");

        exit(1);
    }

    int opt;

    while ((opt = getopt(argc, argv, "s:g:")) != -1) {
        #ifdef DEBUG
        printf("%c\n", opt);
        #endif

        switch (opt) {
            case 's':
                break;
            case 'g': 
                if (!checkPin(optarg)) {
                    exit(1);
                }

                break;
            // default:
            //     printf("Usage : sudo ./Raspberry_DHT11 -s [model] -g [G:PIN|W:PIN]\n");
            //     printf("Example : sudo ./Raspberry_DHT11 -s DHT11 -g G:18 => DHT11, GPIO_18\n");
            //     printf("Example : sudo ./Raspberry_DHT11 -s DHT11 -g W:1 => DHT11, WiringPi 1\n");

            //     exit(1);
            //     break;
        }
    }

    if ( wiringPiSetup() == -1 ) {
        printMessage(false, "Setup fail.");

        exit(1);
    }

    while (1) {
        if (read_dht11_dat()) {
            printMessage(true, NULL);
        }

        delay( 1000 ); /* wait 1sec to refresh */<commit_msg>* Debug mode 추가.<commit_after>/*
 *  dht11.c:
 *  Simple test program to test the wiringPi functions
 *  DHT11 test
 *
 *  https://github.com/ook/dht11-json/blob/master/dht11.c
 *  http://blogs.msdn.com/b/laurelle/archive/2015/04/11/create-a-dht11-c-library-using-wiringpi-on-raspberrypi-and-use-it-in-mono-c.aspx
 */

#include <wiringPi.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#define MAXTIMINGS  85

// #define DEBUG

typedef enum {
    false,
    true
} bool;

int dht11_dat[5] = { 0, 0, 0, 0, 0 };
int PIN;
// char* model[];
float datas[2];

const char* GPIO_PREFIX = "G:";
const char* WIRING_PREFIX = "W:";
const int PHY_PIN[] = {
    3,
    5,
    7, 8,
    10,
    11, 12,
    13, 14,
    15, 16,
    17, 18,
    19,
    21, 22,
    23, 24,
    26,
    27, 28,
    29,
    31, 32,
    33,
    35, 36,
    37, 38,
    40
};

const int GPIO_PIN[] = {
    2,
    3,
    4, 14,
    15,
    17, 18,
    27,
    22, 23,
    24,
    10,
    9, 25,
    11, 8,
    7,
    0, 1,
    5,
    6, 12,
    13,
    19, 16,
    26, 20,
    21
};

const int WIRING_PIN[] = {
    8,
    9,
    7, 15,
    16,
    0, 1,
    2,
    3, 4,
    5,
    12,
    13, 6,
    14, 10,
    11,
    30, 31,
    21,
    22, 26,
    23,
    24, 27,
    25, 28,
    29
};

void printMessage(bool result, char message[]);
bool checkPin(char* pin);
bool read_dht11_dat();

int main(int argc, char* argv[]) {
    #ifdef DEBUG
    printf("argument count : %d\n", argc);
    #endif
    if (argc != 5) {
        printf("Usage : sudo ./Raspberry_DHT11 -s [model] -g [G:PIN|W:PIN]\n");
        printf("Example : sudo ./Raspberry_DHT11 -s DHT11 -g G:18 => DHT11, GPIO_18\n");
        printf("Example : sudo ./Raspberry_DHT11 -s DHT11 -g W:1 => DHT11, WiringPi 1\n");

        exit(1);
    }

    int opt;

    while ((opt = getopt(argc, argv, "s:g:")) != -1) {
        #ifdef DEBUG
        printf("%c\n", opt);
        #endif

        switch (opt) {
            case 's':
                break;
            case 'g': 
                if (!checkPin(optarg)) {
                    exit(1);
                }

                break;
        }
    }

    if ( wiringPiSetup() == -1 ) {
        printMessage(false, "Setup fail.");

        exit(1);
    }

    while (1) {
        if (read_dht11_dat()) {
            printMessage(true, NULL);

            #ifndef DEBUG
            break;
            #endif
        }

        #ifdef DEBUG
        delay( 1000 ); /* wait 1sec to refresh */
        #endif
{'fraction_non_alphanumeric': 0.16224355354790138, 'fraction_numerical': 0.08413325804630152, 'mean_word_length': 1.5871470301850048, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '4902610', 'n_tokens_mistral': 2431, 'n_tokens_neox': 2103, 'n_words': 533}