<commit_before>/******************************************************************************
* IMU_Functions.cpp
*
* Runs initialization and reads files on the BNO055 IMU
******************************************************************************/
#include "Mapper.h"


/******************************************************************************
 * void start_read_imu
 *
 * Starts read_imu.py code
******************************************************************************/
void start_read_imu(void)
{
  // Create flag for continuing
  bool success = false;
  while (!success)
  {
    // clear fifo file //
    std::FILE* fd = fopen("imu.fifo","w");
    fclose(fd);
    printf("Created and cleared imu.fifo\n");

    printf("Starting read_imu.py, then waiting 2 seconds\n");
    char cmd[50];
    strcpy(cmd,"python read_imu.py & exit");
    system(cmd);
    printf("Started IMU using system(cmd)\n");
    // Wait 2 seconds to let the python script start up
    usleep(2000000);

    // Check whether the python script wrote anything
    std::ifstream pFile("imu.fifo");
    if(pFile.peek() == std::ifstream::traits_type::eof())
    {
      printf("read_imu.py has NOT written to imu.fifo\n");
      printf("Retrying IMU initialization\n");
      // if it isn't printing values, restart initialization
    }
    else
    {
      printf("read_imu.py HAS written to imu.fifo\n");
      // success! continue
      printf("IMU Initialized\n");<commit_msg>init works, now to seg fault...again<commit_after>/******************************************************************************
* IMU_Functions.cpp
*
* Runs initialization and reads files on the BNO055 IMU
******************************************************************************/
#include "Mapper.h"


/******************************************************************************
 * void start_read_imu
 *
 * Starts read_imu.py code
******************************************************************************/
void start_read_imu(void)
{
  // Create flag for continuing
  bool success = false;
  while (!success)
  {
    // clear fifo file //
    std::FILE* fd = fopen("imu.fifo","w");
    fclose(fd);
    printf("\nCreated and cleared imu.fifo\n");

    printf("Starting read_imu.py, then waiting 2 seconds\n");
    char cmd[50];
    strcpy(cmd,"python read_imu.py & exit");
    system(cmd);
    printf("Started IMU using system(cmd)\n");
    // Wait 2 seconds to let the python script start up
    usleep(2000000);

    // Check whether the python script wrote anything
    std::ifstream pFile("imu.fifo");
    if(pFile.peek() == std::ifstream::traits_type::eof())
    {
      printf("\nERROR: -----> read_imu.py has NOT written to imu.fifo\n");
      printf("Retrying IMU initialization\n");
      // if it isn't printing values, restart initialization
    }
    else
    {
      printf("read_imu.py HAS written to imu.fifo\n");
      // success! continue
      printf("IMU Initialized\n");
{'fraction_non_alphanumeric': 0.3187478963312016, 'fraction_numerical': 0.009424436216762033, 'mean_word_length': 3.9865771812080535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4995305', 'n_tokens_mistral': 856, 'n_tokens_neox': 800, 'n_words': 213}