<commit_before>#include <adk.h>
#include <usbhub.h>
#include <TimerOne.h>
#include <SoftwareSerial.h>
#include <SD.h>
#include <SPI.h>
#include <Servo.h> 
#include "abs.h"

Servo myServo[MAX_SERVO];
SoftwareSerial mySerial[MAX_SERIAL] = {SoftwareSerial(10,11), SoftwareSerial(7,8)};

File buffer;
char *data;
uint8_t msg[MAX_PACKET_SIZE];
uint16_t length;
USBPacket packet;
USB Usb;
USBHub hub0(&Usb);
USBHub hub1(&Usb);
Event event_list[MAX_EVENTS];
int time=0, eventCount = 0, packetCount = 0; 
USBPacket res;
uint8_t *response;

ADK adk(&Usb, "UPC, BarcelonaTech",
              "Android Beyond the Stratoshpere",
              "Android Beyond the Stratoshpere",
              "1.0",
              "http://www.upc.edu",
              "000000000000000001");

void setup(void)
{
    Serial.begin(SERIAL_BITRATE);
    //while(!Serial); 
    Serial.println("\r\nArduino firmware start");
        
    if(Usb.Init() == -1) {
        Serial.println("OSCOKIRQ failed to assert");
        while(Usb.Init() == -1); /* retry */
    }
    Timer1.initialize(TIMER_INTERVAL);
    Timer1.pwm(9, 512);
    Timer1.attachInterrupt(events_routine);
    
    pinMode(SD_CS, OUTPUT);
   
    if (!SD.begin(SD_CS)) {
        Serial.println("Error initializing SDcard");
    }
}

void loop(void)
{  
    int i = 0;
    Usb.Task(); 
    if(!adk.isReady()) { 
        return; /* restart Arduino firmware */
    }
    length = sizeof(msg);
    adk.RcvData(&length, msg);
    if(length > 0) {
        packet = process_packet(msg);
        res = execute_packet(&packet);
        response = to_raw(res, &length);
        char str[80];
        sprintf(str,"%x:%x:%x:%x length %d",response[0],response[1],response[2],response[3],length);
        Serial.println(str);
        adk.SndData(length, response);   
        adk.SndData(length, response);  
        free(response);
       
    }    
   
    for(i = 0; i < eventCount; i++) {
        if(event_list[i].execute == 1) {
            packet = event_list[i].action;
            res = execute_packet(&packet);
            save_event_data(i, (char *) res.data);
            event_list[i].execute = 0;
        }
    }     
}

void events_routine(void)
{  
    int i = 0;
    for(i = 0; i < eventCount; i++) {
      if(time % event_list[i].interval == 0) {
            Serial.println("Event!!!");
            event_list[i].execute = 1;
        }
    }
    time++;
}
<commit_msg>Update abs.ino<commit_after>#include <adk.h>
#include <usbhub.h>
#include <TimerOne.h>
#include <SoftwareSerial.h>
#include <SD.h>
#include <SPI.h>
#include <Servo.h>
#include <comms.h>
#include <hdlc.h>
#include "abs.h"

Servo myServo[MAX_SERVO];
SoftwareSerial mySerial[MAX_SERIAL] = {SoftwareSerial(10,11), SoftwareSerial(7,8)};

File buffer;
char *data;
uint8_t msg[MAX_PACKET_SIZE];
uint16_t length;
USBPacket packet;
USB Usb;
USBHub hub0(&Usb);
USBHub hub1(&Usb);
Event event_list[MAX_EVENTS];
int time=0, eventCount = 0, packetCount = 0; 
USBPacket res;
uint8_t *response;

ADK adk(&Usb, "UPC, BarcelonaTech",
              "Android Beyond the Stratoshpere",
              "Android Beyond the Stratoshpere",
              "1.0",
              "http://www.upc.edu",
              "000000000000000001");

void setup(void)
{
    Serial.begin(SERIAL_BITRATE);
    //while(!Serial); 
    Serial.println("\r\nArduino firmware start");
        
    if(Usb.Init() == -1) {
        Serial.println("OSCOKIRQ failed to assert");
        while(Usb.Init() == -1); /* retry */
    }
    Timer1.initialize(TIMER_INTERVAL);
    Timer1.pwm(9, 512);
    Timer1.attachInterrupt(events_routine);
    
    pinMode(SD_CS, OUTPUT);
   
    if (!SD.begin(SD_CS)) {
        Serial.println("Error initializing SDcard");
    }
}

void loop(void)
{  
    int i = 0;
    Usb.Task(); 
    if(!adk.isReady()) { 
        return; /* restart Arduino firmware */
    }
    length = sizeof(msg);
    adk.RcvData(&length, msg);
    if(length > 0) {
        packet = process_packet(msg);
        res = execute_packet(&packet);
        response = to_raw(res, &length);
        char str[80];
        sprintf(str,"%x:%x:%x:%x length %d",response[0],response[1],response[2],response[3],length);
        Serial.println(str);
        adk.SndData(length, response);   
        adk.SndData(length, response);  
        free(response);
       
    }    
   
    for(i = 0; i < eventCount; i++) {
        if(event_list[i].execute == 1) {
            packet = event_list[i].action;
            res = execute_packet(&packet);
            save_event_data(i, (char *) res.data);
            event_list[i].execute = 0;
        }
    }     
}

void events_routine(void)
{  
    int i = 0;
    for(i = 0; i < eventCount; i++) {
      if(time % event_list[i].interval == 0) {
            Serial.println("Event!!!");
            event_list[i].execute = 1;
        }
    }
    time++;
}

{'fraction_non_alphanumeric': 0.15739400206825233, 'fraction_numerical': 0.024405377456049638, 'mean_word_length': 2.479136690647482, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3914303', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1705, 'n_words': 325}