mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-02-06 17:02:45 +08:00
| | old version | new version (second proposal) | |-|-|-| | module name | `microdds_client` | **`uxrce_dds_client`** | | strings / comments about the module | non consistent | **UXRCE-DDS Client** | | menuconfig option | `MODULES_MICRODDS_CLIENT` | **`MODULES_UXRCE_DDS_CLIENT`** | | module parameters group name | `Micro XRCE-DDS` | **UXRCE-DDS Client** | | module parameters name prefix | `XRCE_DDS_` | `UXRCE_DDS_` | | module class name | `MicroddsClient` | **`UxrceddsClient`** | |`init.d/rcS` whenever the module is mentioned | `microdds` | **`uxrce_dds`** | | main doc page name | XRCE-DDS (PX4-FastDDS Bridge) | **uXRCE-DDS (PX4-micro XRCE-DDS Bridge)**| | environment variable to have custom namespace in simulation | PX4_MICRODDS_NS | **PX4_UXRCE_DDS_NS** | Signed-off-by: Beniamino Pozzan <beniamino.pozzan@phd.unipd.it>
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Converts IP address given in decimal dot notation to int32 to be used in UXRCE_DDS_CFG parameter
|
|
and vice-versa
|
|
|
|
@author: Beniamino Pozzan (beniamino.pozzan@phd.unipd.it)
|
|
"""
|
|
|
|
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog = 'convert_ip',
|
|
description = 'converts IP to int32 and viceversa'
|
|
)
|
|
parser.add_argument('input',
|
|
type=str,
|
|
help='IP address to convert')
|
|
parser.add_argument('-r','--reverse',
|
|
action='store_true',
|
|
help='converts from int32 to dot decimal')
|
|
|
|
args = parser.parse_args()
|
|
|
|
if( args.reverse == False ):
|
|
|
|
try:
|
|
ip_parts = [int(x) for x in args.input.split('.')]
|
|
except:
|
|
raise ValueError("Not a valid IP")
|
|
if( len(ip_parts)!=4 ):
|
|
raise ValueError("Not a valid IP")
|
|
if( not all(x>=0 and x<255 for x in ip_parts) ):
|
|
raise ValueError("Not a valid IP")
|
|
|
|
ip = (ip_parts[0]<<24) + (ip_parts[1]<<16) + (ip_parts[2]<<8) + ip_parts[3]
|
|
|
|
if(ip & 0x80000000):
|
|
ip = -0x100000000 + ip
|
|
|
|
print(ip)
|
|
|
|
else:
|
|
try:
|
|
ip = int(args.input)
|
|
except:
|
|
raise ValueError("Not a valid IP")
|
|
if(ip < 0):
|
|
ip = ip + 0x100000000
|
|
print('{}.{}.{}.{}'.format(ip>>24, (ip>>16)&0xff, (ip>>8)&0xff, ip&0xff))
|