File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,29 @@ void ImageCallback(const void *msg, size_t) {
1818 // 处理图像数据
1919}
2020
21- int main () {
21+ int main (int argc, char * argv[] ) {
2222 // 1.创建同步器
2323 Synchronizer synchronizer;
24- // synchronizer.SetUsbLink("/dev/ttyACM0", 921600);
25- synchronizer.SetNetLink (" 192.168.1.188" , 8888 );
24+
25+ if (argc < 2 ) {
26+ // 默认使用串口
27+ std::cout << " 未传入参数,默认使用 USB 串口 /dev/ttyACM0" << std::endl;
28+ synchronizer.SetUsbLink (" /dev/ttyACM0" , 921600 );
29+ } else {
30+ std::string mode = argv[1 ];
31+ if (mode == " uart" ) {
32+ std::cout << " 参数为 uart,使用 USB 串口 /dev/ttyACM0" << std::endl;
33+ synchronizer.SetUsbLink (" /dev/ttyACM0" , 921600 );
34+ } else if (mode == " net" ) {
35+ std::cout << " 参数为 net,使用网口 192.168.1.188:8888" << std::endl;
36+ synchronizer.SetNetLink (" 192.168.1.188" , 8888 );
37+ } else {
38+ std::cerr << " 未知参数: " << mode
39+ << " ,请使用 uart / net 或不传参数" << std::endl;
40+ return -1 ;
41+ }
42+ }
43+
2644 // 2.配置同步接口
2745 auto mv_cam = std::make_shared<MvCam>();
2846 mv_cam->SetParams ({{" cam_1" , CAM_1}});
@@ -38,6 +56,7 @@ int main() {
3856 while (true ) {
3957 std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
4058 }
59+
4160 // 5.停止同步
4261 synchronizer.Stop ();
4362 return 0 ;
You can’t perform that action at this time.
0 commit comments