<commit_before>#include <stdio.h>
#include <string.h>

#include "segwayrmp.h"

void handleSegwayStatus(segwayrmp::SegwayStatus &ss) {
    std::cout << ss.str() << std::endl << std::endl;
}

int run_segway(segwayrmp::InterfaceType interface_type, std::string port = "/dev/ttyUSB0") {
    segwayrmp::SegwayRMP rmp(interface_type);
    if (interface_type == segwayrmp::serial) {
        rmp.configureSerial(port);
    }
    rmp.setStatusCallback(handleSegwayStatus);
    rmp.connect();
    while(true) {
        rmp.move(1.0, 0);
        usleep(100000);
    }
}

void print_usage() {
    std::cout << "Usage: segwayrmp_example usb" << std::endl;
    std::cout << "       or" << std::endl;
    std::cout << "       segwayrmp_example serial <serial port>" << std::endl;
}

int main(int argc, char *argv[]) {
    if (argc < 2) {
        print_usage();
        return 0;
    }
    if (argv[1] == "serial") {
        if (argc < 3) {
            print_usage();
            return 0;
        }
        run_segway(segwayrmp::serial, std::string(argv[2]));
    } else {
        run_segway(segwayrmp::usb);
    }
}<commit_msg>Bug fixes for the example program.<commit_after>#include <iostream>
#include <string.h>

#include "segwayrmp.h"

void handleSegwayStatus(segwayrmp::SegwayStatus &ss) {
    std::cout << ss.str() << std::endl << std::endl;
}

int run_segway(segwayrmp::InterfaceType interface_type, std::string port = "/dev/ttyUSB0") {
    segwayrmp::SegwayRMP rmp(interface_type);
    if (interface_type == segwayrmp::serial) {
        rmp.configureSerial(port);
    }
    rmp.setStatusCallback(handleSegwayStatus);
    rmp.connect();
    while(true) {
        rmp.move(0.3, 0);
        usleep(100000);
    }
}

void print_usage() {
    std::cout << "Usage: segwayrmp_example usb" << std::endl;
    std::cout << "       or" << std::endl;
    std::cout << "       segwayrmp_example serial <serial port>" << std::endl;
}

int main(int argc, char *argv[]) {
    if (argc < 2) {
        print_usage();
        return 0;
    }
    if (std::strcmp(argv[1], "serial") == 0) {
        if (argc < 3) {
            print_usage();
            return 0;
        }
        run_segway(segwayrmp::serial, std::string(argv[2]));
    } else {
        run_segway(segwayrmp::usb);
    }
}
{'fraction_non_alphanumeric': 0.16563604240282687, 'fraction_numerical': 0.014575971731448763, 'mean_word_length': 2.80672268907563, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 9, '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': '5191706', 'n_tokens_mistral': 829, 'n_tokens_neox': 808, 'n_words': 148}