Please select Into the mobile phone version | Continue to access the computer ver.
Products + Follow Have 7 Audience + New Thread

设置ip失败

[Copy Link]
Author: Tifox | Time: 2021-9-16 17:46:19 | MID-70|
1 1994

1

Threads

2

Posts

11

Credits

Kindergarten

Rank: 1

Credits
11
Posted on 2021-9-16 17:46:19| All floors |Read mode
通过代码设置ip失败。只连接了一台mid70雷达到机器上。
成功连接之后,SetStaticDeviceIpModeRequest的成员设置好。
再通过SetStaticIp调整雷达ip。
然后使用RebootDevice来重启雷达,重启之后显示雷达的ip未改变。

代码如下:
svr.Post("/changelidarip", [](const Request& req, Response& res) {
        auto body = req.body;
        json nj = json::parse(body);
        string change_lidar_ip = nj["change_lidar_ip"];
        string change_lidar_subnet = nj["change_lidar_subnet"];
        string change_lidar_netgate = nj["change_lidar_netgate"];
        Trim(change_lidar_ip);
        Trim(change_lidar_subnet);
        Trim(change_lidar_netgate);
        cout << change_lidar_ip << " "<< change_lidar_subnet << " "<< change_lidar_netgate << endl;
        uint32_t ip = ipToInt(change_lidar_ip);
        uint32_t netmask = ipToInt(change_lidar_subnet);
        uint32_t netgate = ipToInt(change_lidar_netgate);
        cout << ip << " " << netmask << " " << netgate << endl;
        SetStaticDeviceIpModeRequest change_ip;
        change_ip.ip_addr = ip;
        change_ip.net_mask = netmask;
        change_ip.gw_addr = netgate;
        // change_ip.ip_addr = 3232235816;
        // change_ip.net_mask = 4294967040;
        // change_ip.gw_addr = 3232235777;
        SetStaticDeviceIpModeRequest* ip_s = &change_ip;
        int ret = SetStaticIp(0,ip_s,OnStopImuCallback,0);
        cout << "set ip" << ret << endl;
        if(ret == 0){
            res.set_content("set ip success", "text/plain");
        }
    });
    svr.Post("/lidar_reboot", [](const Request& req, Response& res){
        int i = RebootDevice(0,1000,OnStopImuCallback,0);
        cout << "reboot " << i << endl;
        res.set_content("reboot success", "text/plain");
    });

OnStopImuCallback是空的函数。
具体是通过request调用。

但是通过livox viewer是可以正确设置雷达的。并且通过抓包分析livox viewer也是发送两个指令,08设置ip与0a重启设备。请问我的操作中有什么不对的地方导致这种情况发生吗?

程序执行如下:


This post contains more resources

You need to Login Before they can download or view these resources, Don’t have an account?Register

x
Reply

Use props Report

1

Threads

2

Posts

11

Credits

Kindergarten

Rank: 1

Credits
11
 Author| Posted on 2021-9-17 09:30:17| All floors
自问自答,SetStaticDeviceIpModeRequest 里面的uint32_t使用的是字节序不一样,需要转换字节序。uint32_t ntohl(uint32_t netlong);
Reply

Use props Report

You need to log in before you can reply Login | Register

Credit Rules

Author's New Posts
Quick Reply Back to top