使用旧版候选区寻找方式。

This commit is contained in:
xinyang
2019-05-02 20:49:58 +08:00
parent 2f20367677
commit 64d2554069
3 changed files with 0 additions and 52 deletions

View File

@@ -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;

View File

@@ -36,7 +36,6 @@ public:
uint8_t receive();
void receive_data();
bool debugUart();
};

View File

@@ -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<char>((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]
);
}