Community discussions

MikroTik App
 
blakbox
just joined
Topic Author
Posts: 2
Joined: Sun Jun 02, 2019 7:24 pm

Need to know a state of every pair with ethernet cable-test

Sat Jul 09, 2022 2:46 pm

Hi there!
I used to get a state of every ethernet pair by doing this
:local strData [/interface ethernet cable-test $iface once as-value]; 
:local arrData [ :toarray $strData ]; 
:local strData2 ( $arrData->"cable-pairs" ); 
:local arrData2 [ :toarray $strData2 ]; 
:local state3 [:pick [($arrData2->0)] 0 [:find [($arrData2->0)] ":"]];
:local state4 [:pick [($arrData2->1)] 0 [:find [($arrData2->1)] ":"]];
And this was perfectly fine solution for me until one day my script stopped working.
Now the output of /interface ethernet cable-test $iface once as-value doesn't have cable-pairs: key in it.
How does it happened? Should I upgrade fw/hw or should I re-write my script?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Need to know a state of every pair with ethernet cable-test

Sat Jul 09, 2022 3:03 pm

I test that on various hardware and 3 RouterOS version: 6.48.6, 6.47.10, 6.46.8
When status=link-ok the other values are not reported...

:local arrData [ :toarray $strData ];
Why??? Is already one array what is returned.....

this is better:

test code

{

:local iface "ether1"
/interface ethernet
:local tcable [cable-test $iface once as-value]
:local status ($tcable->"status")
:local pair1 ($tcable->"cable-pairs"->0)
:local pair2 ($tcable->"cable-pairs"->1)
:local pair3 ($tcable->"cable-pairs"->2)
:local pair4 ($tcable->"cable-pairs"->3)
:set pair1 [:pick $pair1 0 [:find $pair1 ":"]]
:set pair2 [:pick $pair2 0 [:find $pair2 ":"]]
:set pair3 [:pick $pair3 0 [:find $pair3 ":"]]
:set pair4 [:pick $pair4 0 [:find $pair4 ":"]]
:if ($status != "link-ok") do={
    :put "$iface $status $pair1 $pair2 $pair3 $pair4"
} else={
    :put "$iface $status"
}

}

or for just replace your code: (why state3 is 1st pair and state4 is the second???)
:local arrData [/interface ethernet cable-test $iface once as-value]
:local state3 [:pick ($arrData->"cable-pairs"->0) 0 [:find ($arrData->"cable-pairs"->0) ":"]]
:local state4 [:pick ($arrData->"cable-pairs"->1) 0 [:find ($arrData->"cable-pairs"->1) ":"]]
 
blakbox
just joined
Topic Author
Posts: 2
Joined: Sun Jun 02, 2019 7:24 pm

Re: Need to know a state of every pair with ethernet cable-test

Tue Jul 12, 2022 8:36 pm

Thanks a lot, rextended
:local arrData [/interface ethernet cable-test $iface once as-value]
:local state3 [:pick ($arrData->"cable-pairs"->0) 0 [:find ($arrData->"cable-pairs"->0) ":"]]
:local state4 [:pick ($arrData->"cable-pairs"->1) 0 [:find ($arrData->"cable-pairs"->1) ":"]]
I'll use your code in my script, it's simpler and better.
Why state3 and 4 for first 2 pairs - I don't know :) That was quite a time ago.
But my present problem is not in the code.
A year ago(approx.) my ugly script did the job, but today it don't.
I use port 11(RB1100AH, bypass->off) for testing purposes only and now I see
[admin@RouterOS] > interface ethernet cable-test ether11 once 
    name: ether11
  status: no-link
[admin@RouterOS] >
but the same router for another port, say ether8, do provide all the information
[admin@RouterOS] > interface ethernet cable-test ether8 once   
         name: ether8-slave-local
       status: no-link
  cable-pairs: normal:?,normal:?,open:1,open:1
[admin@RouterOS] >
Reboot and fw upgrade doesn't help, port11 trough 13 - same problem, port8, port4 - all ok.
Port12 is in bridge, same as port4 and port8, port11 and port13 - are independent.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Need to know a state of every pair with ethernet cable-test

Tue Jul 12, 2022 9:49 pm

that board have inside multiple switch chips, one for port 1-5 and one for 6-10 but another different model dedicated to port (11 + 12) and 13
and different chip can have or not cable test support

Who is online

Users browsing this forum: No registered users and 6 guests