Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /system script add comment="=ROS-FUNCTIONS=" dont-require-permissions=no name=ros-functions owner=admin policy=ftp,reboot,read,write,policy,test,sniff source="# ROS Scripts - Custom functions \
- \n# Dmitry Shevchenko - 11.11.2019\
- \n\
- \n# Filesystem type\
- \n:global funcIsFlash do={\
- \n\t:local isFlash false;\
- \n\t:if ( [ :len [ file find where type=\"disk\" and name=\"flash\" ] ] != 0 ) do={ :set \$isFlash true ; } ; \
- \n\t:return [ \$isFlash ] ; \
- \n}\
- \n\
- \n# Convert command to script and run it\
- \n:global funcCmd2Script do={\
- \n\t:if ( [ :len \$cmd ] != 0 ) do={\
- \n\t\t# Remove (previous errors)\
- \n\t\t/system script remove [ find name=tmp-ros-m9e ];\
- \n\t\t# Create new & run it\
- \n\t\t/system script add name=\"tmp-ros-m9e\" source=\$cmd;\
- \n\t\t/system script run tmp-ros-m9e;\
- \n\t\t:delay 5s;\
- \n\t\t# Remove \
- \n\t\t/system script remove [ find name=tmp-ros-m9e ];\
- \n\t\t:delay 5s;\
- \n\t}\
- \n}\
- \n\
- \n# ROS Version Compare\
- \n:global funcROSVersionCompare do={\
- \n# Parse input values\
- \n# Current ROS version\
- \n\t:local curmajver [ :pick \$versionA 0 [ :find \$versionA \".\" ] ]\
- \n\t:local curminver [ :pick \$versionA ([ :find \$versionA \".\" ] + 1) [ :len \$versionA ] ]\
- \n# Control / Test ROS version ( user-defined value )\
- \n\t:local ctrmajver [ :pick \$versionB 0 [ :find \$versionB \".\" ] ]\
- \n\t:local ctrminver [ :pick \$versionB ([ :find \$versionB \".\" ] + 1) [ :len \$versionB ] ]\
- \n# Minor version check flag\
- \n\t:local minvercheck false;\
- \n# Version check\
- \n# Major version check\
- \n\t:if ( \$curmajver > \$ctrmajver ) do={ :return 1; } else={\
- \n\t\t:if ( \$curmajver = \$ctrmajver ) do={ :set minvercheck true; } else={ :return -1; };\
- \n\t};\
- \n# Minor version check\
- \n\t:if ( \$minvercheck ) do={\
- \n\t\t:if ( \$curminver > \$ctrminver ) do={ :return 1; } else={\
- \n\t\t\t\t:if ( \$curminver = \$ctrminver ) do={ :return 0; } else={ :return -1; };\
- \n\t\t};\
- \n\t};\t\
- \n}\
- \n\
- \n# End"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement