码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 机器人多设备局域网可通调试


    作者: Herman Ye @Auromix
    版本: V1.0
    测试环境: Ubuntu20.04
    更新日期: 2023/09/13
    注1: @Auromix 是一个机器人爱好者开源组织。
    注2: 本文在更新日期经过测试,确认有效。

    使用情景

    同一机器人不同硬件设备通过局域网有线通信,但存在通信异常,通过命令或脚本来查找各设备。

    命令行查看当前局域网段下的其他设备

    提示: HWaddress 值为incomplete 是不正常的设备

    arp -n
    
    • 1

    脚本查看当前局域网段下可Ping通的所有设备

    #!/bin/bash
    #
    # Copyright 2023 Herman Ye @Auromix
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    # 
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    #
    # Description: This script finds your device in the specified network segment, such as robot arm, lidar.
    # Version: 1.0
    # Date: 2023-09-13
    # Author: Herman Ye @Auromix
    #
    # set -x
    
    
    # Prompt the user to enter a network segment
    read -p "Please enter a network segment (press Enter for default value 192.168.1): " network
    
    # Set a default value if the user presses Enter
    network="${network:-192.168.1}"
    
    echo "Finding devices from $network.1 to $network.254"
    # Initialize an array to store reachable devices
    reachable_devices=()
    
    # Iterate through all IP addresses in the specified network segment
    for ip in ${network}.{1..254}; do
        # Use the ping command to check if the device is reachable
        # -c 1 means send only one ICMP request, -W 1 means wait for 1 second
        if ping -c 1 -W 1 $ip >/dev/null; then
            echo "Device at $ip is reachable"
            # Add reachable devices to the array
            reachable_devices+=("$ip")
        else
            echo "Device at $ip is not reachable"
        fi
    done
    
    # Print information about all reachable devices
    echo "All reachable devices:"
    for device in "${reachable_devices[@]}"; do
        echo "$device"
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
  • 相关阅读:
    通过pytorch转换得到ms模型,训练模式下输出和pytorch模型一样,验证模式下通过batchnorm2d算子的输出不同
    QT+OSG/osgEarth编译之四十九:osgSim+Qt编译(一套代码、一套框架,跨平台编译,版本:OSG-3.6.5核心库osgSim)
    C++之STL中vector的使用
    【IROS 2019】RangeNet++: 快速准确的LiDAR语义分割
    【ES】笔记-Map介绍与API
    深入浅出Java多线程(十):CAS
    零数科技深耕苏州,受邀参加中国金融科技产业峰会
    Spring Data JPA渐进式学习--Repostory
    探寻容器的本质
    openpnp - src - 配置文件载入过程的初步分析
  • 原文地址:https://blog.csdn.net/m0_56661101/article/details/132848328
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号