<commit_before>#include <iostream>
#include <cstdio>
#include <cstring>
#include "MotorEncoders.h"
#include "../arduino/DataPacket.hpp"
using namespace std;

int main(void) {
	MotorEncoders encoders;
	//MotorEncoders::reply_t status;

	cout << "Size of short = " << sizeof(short) << endl;
	cout << "Size of header = " << sizeof(DataPacket::header_t) << endl;
	cout << "size of struct = " << (sizeof(DataPacket::encoder_reply_t)) << endl;

	//int exp_packetnum = 1;
	int i;
	for( i = 0; i < 10; i++){
		//cout << "Heading = " << encoders.getHeading() << endl;
		//encoders.setArduinoClock();
		//reply_t packet = encoders.getInfo();

		DataPacket packet;

		//((ArduinoInterface)encoders).setArduinoClock();

		encoders.getInfo_class(&packet);

		DataPacket::encoder_reply_t parsed_data;
		memcpy(&parsed_data, packet.data, sizeof(DataPacket::encoder_reply_t));

		//DataPacket::encoder_reply_t data = encoders.getInfo();
		//printf("timestamp (s): %d\n", (packet.packet->timestamp) / 1000);
		//printf("packetnum: %d\n", packet.packet->packetnum);

		//printf("dl: %X\n", (unsigned short)parsed_data.dl);
		//printf("dr: %X\n", (unsigned short)parsed_data.dr);
		//printf("dt: %X\n", (unsigned)parsed_data.dt);
		cout << parsed_data << "\n\n";

		//for(int i = 0; i < sizeof(DataPacket::header_t); i++){
		//	printf("%X",  ((byte*)(&packet.header))[i]);
		//}
		for(int i = 0; i < sizeof(DataPacket::encoder_reply_t); i++){
			//printf("%X",  ((byte*)(&parsed_data))[i]);
			printf("%X", packet.data[i] );
		}
		cout << "\n\n";
		//status = encoders.getInfo();
		//cout << "Heading = " << status.heading << endl;
		usleep(.005*1e6);
	}

	DataPacket pk;
	((ArduinoInterface)encoders).arduinoResendPacket(1, &pk);

	DataPacket::encoder_reply_t parsed_data;
	if (pk.data != NULL){
		memcpy(&parsed_data, pk.data, sizeof(DataPacket::encoder_reply_t));
		printf("dl: %X\n", (unsigned short)parsed_data.dl);
		printf("dr: %X\n", (unsigned short)parsed_data.dr);
		printf("dt: %X\n", (unsigned)parsed_data.dt);
	}
	//printf("timestamp (s): %d\n", (parseddata->timestamp) / 1000);
	//printf("packetnum: %d\n", parseddata->packetnum);<commit_msg>modify test code for new interface and packet debugging<commit_after>#include <iostream>
#include <cstdio>
#include <cstring>
#include "MotorEncoders.h"
#include "../arduino/DataPacket.hpp"
using namespace std;

int main(void) {
	MotorEncoders encoders;

//	cout << "Size of short = " << sizeof(short) << endl;
//	cout << "Size of header = " << sizeof(DataPacket::header_t) << endl;
//	cout << "size of struct = " << (sizeof(DataPacket::encoder_reply_t)) << endl;

	//int exp_packetnum = 1;
	int i;
	for( i = 0; i < 10000; i++){
		//cout << "Heading = " << encoders.getHeading() << endl;

		DataPacket packet;

		encoders.getInfo_class(&packet);

		DataPacket::encoder_reply_t parsed_data;
		memcpy(&parsed_data, packet.data, sizeof(DataPacket::encoder_reply_t));

		cout << packet;
		cout << parsed_data << "\n\n";

		//for(int i = 0; i < sizeof(DataPacket::header_t); i++){
		//	printf("%X",  ((byte*)(&packet.header))[i]);
		//}
//		for(int i = 0; i < sizeof(DataPacket::encoder_reply_t); i++){
			//printf("%X",  ((byte*)(&parsed_data))[i]);
			//printf("%X", packet.data[i] );
//		}
		cout << "\n\n";
		//status = encoders.getInfo();
		//cout << "Heading = " << status.heading << endl;
		usleep(.001*1e6);
	}

	DataPacket * pk = new DataPacket;
	encoders.arduinoInterface.arduinoResendPacket(40070, pk);

	cout << *pk << endl;

	std::cout << "resend pk debug extern" << std::endl;
	std::cout << "data size: " << (int) pk->header.size << std::endl;
	std::cout << "dataloc: " << (int) pk->data << std::endl;

	if (pk->data != NULL){
		if(pk->header.cmd == 'r'){
			DataPacket::encoder_reply_t parsed_data;
			memcpy(&parsed_data, pk->data, sizeof(DataPacket::encoder_reply_t));
			cout << parsed_data << "\n\n";
		}
	}
	delete pk;
{'fraction_non_alphanumeric': 0.2116279069767442, 'fraction_numerical': 0.010077519379844961, 'mean_word_length': 4.398884239888424, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 18, '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': '1761886', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1461, 'n_words': 286}