Merge remote-tracking branch 'origin/master'

This commit is contained in:
xinyang
2019-05-10 20:47:23 +08:00
2 changed files with 28 additions and 9 deletions

View File

@@ -65,6 +65,7 @@ int main(int argc, char *argv[]) {
delete video_armor;
delete video_energy;
cout << "Program fails. Restarting" << endl;
continue;
}
Mat energy_src, armor_src;

View File

@@ -7,33 +7,51 @@
#include <options/options.h>
#include <log.h>
using std::cout;
using std::cerr;
using std::clog;
using std::dec;
using std::endl;
using std::hex;
using namespace std;
GMAngle_t aim;
string get_uart_dev_name(){
FILE* ls = popen("ls /dev/ttyUSB* --color=never", "r");
char name[20] = {0};
fscanf(ls, "%s", name);
return name;
}
Uart::Uart(){
if(wait_uart){
while((fd = open("/dev/ttyUSB0", O_RDWR)) < 0);
string name;
do{
name = get_uart_dev_name();
if(name == ""){
continue;
}
}while((fd=open(name.data(), O_RDWR)) < 0);
}else{
fd = open("/dev/ttyUSB0", O_RDWR);
string name = get_uart_dev_name();
if(name == ""){
cerr<<"open port error"<<endl;
return;
}
fd = open(name.data(), O_RDWR);
if(fd < 0) {
cerr<<"open port error"<<endl;
return;
}
}
// fd = open("/dev/ttyUSB1", O_RDWR);
// if(fd < 0) {
// cerr<<"open port error"<<endl;
// return;
// }
if(set_opt(fd, 115200, 8, 'N', 1) < 0 )
{
cerr<<"set opt error"<<endl;
return;
}
cout<<"uart port success"<<endl;
cout << "uart port success" << endl;
buff[0] = 's';
buff[1] = '+';