diff --git a/main.cpp b/main.cpp index 9223424..67bf00e 100644 --- a/main.cpp +++ b/main.cpp @@ -33,23 +33,11 @@ int mark = 0; void uartReceive(Uart* uart); -thread* create_data_recv_thread(Uart *uart){ - thread *thread1 = new thread([uart](){ - LOGM("Start receiving!"); - while(1){ - uart->debugUart(); - } - }); - return thread1; -} - - int main(int argc, char *argv[]){ process_options(argc, argv); Uart uart; thread receive(uartReceive, &uart); bool flag = true; -// create_data_recv_thread(&uart); while (flag){ int ally_color = ALLY_RED; int energy_part_rotation = CLOCKWISE; diff --git a/others/include/uart/uart.h b/others/include/uart/uart.h index ad4e06c..c0a452e 100644 --- a/others/include/uart/uart.h +++ b/others/include/uart/uart.h @@ -36,7 +36,6 @@ public: uint8_t receive(); void receive_data(); - bool debugUart(); }; diff --git a/others/src/uart/uart.cpp b/others/src/uart/uart.cpp index 74cce81..819ea4a 100644 --- a/others/src/uart/uart.cpp +++ b/others/src/uart/uart.cpp @@ -121,9 +121,6 @@ int Uart::set_opt(int fd, int nSpeed, int nBits, char nEvent, int nStop) { return 0; } -FILE *send_info=fopen("send.info", "w"); -FILE *recv_info=fopen("recv.info", "w"); - void Uart::sendTarget(float x, float y, float z) { static short x_tmp, y_tmp, z_tmp; @@ -149,48 +146,12 @@ void Uart::sendTarget(float x, float y, float z) { buff[6] = static_cast((z_tmp >> 0) & 0xFF); buff[7] = 'e'; - timeval ts; - gettimeofday(&ts, NULL); - fprintf(send_info, "%lf %f %f\n", - ts.tv_sec + ts.tv_usec / 1e6, - x, y - ); - write(fd, buff, 8); } -// 's' + (x) ( 8bit + 8bit ) + (y) ( 8bit + 8bit ) + (z) ( 8bit + 8bit ) + 'e' - - uint8_t Uart::receive() { uint8_t data; while(read(fd, &data, 1) < 1); return data; } - -void readall(int fd, void* buff, int size) { - int cnt = 0; - while ((cnt += read(fd, (char*)buff + cnt, size - cnt)) < size); -} - -char readone(int fd){ - char val; - while(read(fd, &val, 1) < 1); - return val; -} - - - -bool Uart::debugUart() { - float val[3]; - //while(readone(fd) != 's'); - readall(fd, val, sizeof(val)); - timeval ts; - gettimeofday(&ts, NULL); - fprintf(recv_info, "%lf %f %f %f\n", - ts.tv_sec + ts.tv_usec / 1e6, - val[0], val[1], val[2] - ); -} -