Autor Tema: Ayudar con lantiq_dsl  (Leído 13431 veces)

0 Usuarios y 1 Visitante están viendo este tema.

kaitak

  • Visitante
Ayudar con lantiq_dsl
« en: 22-05-2014, 16:53 (Jueves) »
Saludos y por favor perdona el Inglés

Would like to add some more vdsl line information to lantiq_dsl.sh and luci status web page.

This is an example from kitz- that sadly never made it into openwrt patchwork.

root@OpenWrt:~# /etc/init.d/dsl_control status
CPE Chipset:      Lantiq-VRx:5.4.8.6.1.6
CO Chipset:      BDCM:v10.07.26
Line State:      UP [0x801: showtime_tc_sync]
Attain Data Rate:   49106 Kbps / 2625 Kbps
Actual Data Rate:   49080 Kbps / 2684 Kbps
Interleave Delay:       8.50 ms / 5.50 ms
Impulse Noise Prot:     1.0 sym / 0.7 sym
Line Attenuation:   32.2 dB / 0.0 dB
Signal Attenuation:   28.2 dB / 0.0 dB
Noise Margin:      6.1 dB / 5.5 dB
Transmit Power:      13.6 dBm / 6.3 dBm
Line Uptime:      2m 4s
FEC Errors:             1433 / 6607
CRC Errors:             150 / 441
ES:                     133 / 2
SES:                    42 / 0
UAS:                    311 / 311

Working with this basic script so far

Código: [Seleccionar]
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 OpenWrt.org

XDSL_CTRL=dsl_cpe_control

#
# Basic functions to send CLI commands to the vdsl_cpe_control daemon
#
dsl_cmd() {
killall -0 ${XDSL_CTRL} && (
echo "$@" > /tmp/pipe/dsl_cpe0_cmd
cat /tmp/pipe/dsl_cpe0_ack
)
}
dsl_val() {
echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
}

#
# Simple divide by 10 routine to cope with one decimal place
#
dbt() {
local a=$(expr $1 / 10)
local b=$(expr $1 % 10)
echo "${a}.${b}"
}
#
# Take a number and convert to k or meg
#
scale() {
local val=$1
local a
local b

if [ "$val" -gt 1000000 ]; then
a=$(expr $val / 1000)
b=$(expr $a % 1000)
a=$(expr $a / 1000)
printf "%d.%03d Mb" ${a} ${b}
elif [ "$val" -gt 1000 ]; then
a=$(expr $val / 1000)
printf "%d Kb" ${a}
else
echo "${val} b"
fi
}

#
# Read the data rates for both directions
#
data_rates() {
local csg
local lsg
local dru
local drd
local adru
local adrd
local sdru
local sdrd
local sadru
local sadrd

csg=$(dsl_cmd g997csg 0 1)
drd=$(dsl_val "$csg" ActualDataRate)

csg=$(dsl_cmd g997csg 0 0)
dru=$(dsl_val "$csg" ActualDataRate)

lsg=$(dsl_cmd g997lsg 1 1)
adrd=$(dsl_val "$lsg" ATTNDR)

lsg=$(dsl_cmd g997lsg 0 1)
adru=$(dsl_val "$lsg" ATTNDR)

[ -z "$drd" ] && drd=0
[ -z "$dru" ] && dru=0
[ -z "$adrd" ] && adrd=0
[ -z "$adru" ] && adru=0

sdrd=$(scale $drd)
sdru=$(scale $dru)

sadrd=$(scale $adrd)
sadru=$(scale $adru)

if [ "$action" = "lucistat" ]; then
echo "dsl.data_rate_down=$drd"
echo "dsl.data_rate_up=$dru"
echo "dsl.data_rate_down_s=\"$sdrd\""
echo "dsl.data_rate_up_s=\"$sdru\""
echo "dsl.att_data_rate_down=\"$adrd\""
echo "dsl.att_data_rate_up=\"$adru\""
echo "dsl.att_data_rate_down_s=\"$sadrd\""
echo "dsl.att_data_rate_up_s=\"$sadru\""
else
echo "Attain Data Rate: ${sadrd}ps / ${sadru}ps"
echo "Actual Data Rate: ${sdrd}ps / ${sdru}ps"
fi
}

#
# Chipset
#
chipset() {
local vig
local cs
local csv

vig=$(dsl_cmd vig)
cs=$(dsl_val "$vig" DSL_ChipSetType)
csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)

if [ "$action" = "lucistat" ]; then
echo "dsl.chipset=\"${cs} ${csv}\""
else
echo "Chipset: ${cs} ${csv}"
fi
}

#
# Work out how long the line has been up
#
line_uptime() {
local ccsg
local et
local etr
local d
local h
local m
local s
local rc=""

ccsg=$(dsl_cmd pmccsg 0 0 0)
et=$(dsl_val "$ccsg" nElapsedTime)

[ -z "$et" ] && et=0

if [ "$action" = "lucistat" ]; then
echo "dsl.line_uptime=${et}"
return
fi

d=$(expr $et / 86400)
etr=$(expr $et % 86400)
h=$(expr $etr / 3600)
etr=$(expr $etr % 3600)
m=$(expr $etr / 60)
s=$(expr $etr % 60)


[ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
[ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
[ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
[ "${d}" -ne 0 ] && rc="${d}d ${rc}"

[ -z "$rc" ] && rc="down"
echo "Line Uptime: ${rc}"
}

#
# Get noise and attenuation figures
#
line_data() {
local lsg
local latnu
local latnd
local snru
local snrd

lsg=$(dsl_cmd g997lsg 1 1)
latnd=$(dsl_val "$lsg" LATN)
snrd=$(dsl_val "$lsg" SNR)

lsg=$(dsl_cmd g997lsg 0 1)
latnu=$(dsl_val "$lsg" LATN)
snru=$(dsl_val "$lsg" SNR)

[ -z "$latnd" ] && latnd=0
[ -z "$latnu" ] && latnu=0
[ -z "$snrd" ] && snrd=0
[ -z "$snru" ] && snru=0

latnd=$(dbt $latnd)
latnu=$(dbt $latnu)
snrd=$(dbt $snrd)
snru=$(dbt $snru)

if [ "$action" = "lucistat" ]; then
echo "dsl.line_attenuation_down=$latnd"
echo "dsl.line_attenuation_up=$latnu"
echo "dsl.noise_margin_down=$snrd"
echo "dsl.noise_margin_up=$snru"
else
echo "Line Attenuation: ${latnd}dB / ${latnu}dB"
echo "Noise Margin: ${snrd}dB / ${snru}dB"
fi
}

#
# Is the line up? Or what state is it in?
#
line_state() {
local lsg=$(dsl_cmd lsg)
local ls=$(dsl_val "$lsg" nLineState);
local s;

case "$ls" in
"0x0") s="not initialized" ;;
"0x1") s="exception" ;;
"0x10") s="not updated" ;;
"0xff") s="idle request" ;;
"0x100") s="idle" ;;
"0x1ff") s="silent request" ;;
"0x200") s="silent" ;;
"0x300") s="handshake" ;;
"0x380") s="full_init" ;;
"0x400") s="discovery" ;;
"0x500") s="training" ;;
"0x600") s="analysis" ;;
"0x700") s="exchange" ;;
"0x800") s="showtime_no_sync" ;;
"0x801") s="showtime_tc_sync" ;;
"0x900") s="fastretrain" ;;
"0xa00") s="lowpower_l2" ;;
"0xb00") s="loopdiagnostic active" ;;
"0xb10") s="loopdiagnostic data exchange" ;;
"0xb20") s="loopdiagnostic data request" ;;
"0xc00") s="loopdiagnostic complete" ;;
"0x1000000") s="test" ;;
"0xd00") s="resync" ;;
"0x3c0") s="short init entry" ;;
"") s="not running daemon"; ls="0xfff" ;;
*) s="unknown" ;;
esac

if [ $action = "lucistat" ]; then
echo "dsl.line_state_num=$ls"
echo "dsl.line_state_detail=\"$s\""
if [ "$ls" = "0x801" ]; then
echo "dsl.line_state=\"UP\""
else
echo "dsl.line_state=\"DOWN\""
fi
else
if [ "$ls" = "0x801" ]; then
echo "Line State: UP [$ls: $s]"
else
echo "Line State: DOWN [$ls: $s]"
fi
fi
}

status() {
chipset
line_state
data_rates
line_data
line_uptime
}

lucistat() {
echo "local dsl={}"
status
echo "return dsl"
}

root@OpenWrt:~# /etc/init.d/dsl_control status
Chipset:                Lantiq-VRx Unknown
Line State:             UP [0x801: showtime_tc_sync]
Attain Data Rate:       0 / 0 Mbps
Actual Data Rate:       0 / 0 Mbps
Line Attenuation:       0dB / 0.0dB
Noise Margin:           0dB / 0dB
Line Uptime:            0m 52s

Help would be most welcome to add this additional information to the script.

Interleave Delay
Impulse noise protection
FEC Errors:            
CRC Errors:            
ES:                    
SES:                    
UAS:    

Yo soy un novato con poca experiencia en comparación con los otros grandes carteles en este sitio ayuda sería muy apreciada!
Muchas gracias


« Última modificación: 22-05-2014, 17:00 (Jueves) por kaitak »

Desconectado sanson

  • Moderador Global
  • *
  • Mensajes: 8396
Re: Re: Ayudar con lantiq_dsl
« Respuesta #1 en: 22-05-2014, 17:58 (Jueves) »
Hola

¿y por que escribes en ingles , ?   Entiendo que al decir " perdón por el ingles ".  Es por que no es tu idioma.  Este foro es en castellano por tanto no hay necesidad de escribir en ingles si no es tu idioma .

Saludos

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #2 en: 22-05-2014, 18:13 (Jueves) »
Hola
Thanks for the reply.

English is far easier for me, ;) {Hence the apology for not being able to post fully in castellano}
Just wanted to post  a  few words spainish/castellano out of respect for the forum users.

Thanks  ;D
« Última modificación: 22-05-2014, 18:15 (Jueves) por kaitak »

Desconectado sanson

  • Moderador Global
  • *
  • Mensajes: 8396
Re: Re: Ayudar con lantiq_dsl
« Respuesta #3 en: 22-05-2014, 18:32 (Jueves) »
Hola

Oh okay, I thought you were Spanish and you made an effort to write in english

Saludos

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2141
Re: Ayudar con lantiq_dsl
« Respuesta #4 en: 22-05-2014, 18:46 (Jueves) »
Citar
Yo soy un novato con poca experiencia en comparación con los otros grandes carteles en este sitio ayuda sería muy apreciada!
Difícilmente un español escribiría así...  ;D

Hi! Welcome to the forum!
Sometimes google translate does not "translate" very well. So when I have to write something in a foreign language I put the translation along with the original not translated text. That way there's a possibility for other people who can read your mother language to try to understand the mistakes made by Saint Google.
No habrás entendido algo, hasta que seas capaz de explicárselo a tu abuela...
Hacemos pantallas con píxeles casi invisibles, para luego ampliar la letra porque no la vemos... Bonita paradoja...
Creamos analfabetos tecnológicos con una velocidad pasmosa. Todo el mundo "maneja" tecnología, casi nadie sabe lo que tiene entre las manos, pero todo el mundo opina.
El analfabetismo, antes, pasaba desapercibido. Ahora, se transmite por Internet y las redes sociales.
Los dispositivos táctiles y las pantallas pequeñas son una lacra para la información relevante y el desarrollo de interfaces de usuario.
Trabajar sin la nube debería ser una prestación de los IoT, no un bug.

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #5 en: 22-05-2014, 19:18 (Jueves) »
Thanks for the warm welcome !  Gracias por la cálida bienvenida!

Did think about dual posting -  didn't   want to clutter  threads   :-[
Pensé en el doble desplazamiento - no quería estorbar hilos-


From the help command

ActualInterleaveDelay &  ActualImpulseNoiseProtection is under from g997csg

Código: [Seleccionar]
g997csg 0 1
nReturn=0 nChannel=0 nDirection=1 ActualDataRate  PreviousDataRate             000 ActualInterleaveDelay  ActualImpulseNoiseProtection
 ActualInterleaveDelay  ActualImpulseNoiseProtection


for FEC errors

Código: [Seleccionar]
pmcc1dg 0 1 0
nReturn=0 nChannel=0 nDirection=1 nHistoryInterval=0 nElapsedTime=0 bValid=1 nCodeViolations      =1 nFEC=0

For CRC & HEC
Código: [Seleccionar]
>pmdpc1dg 0 1 0
nReturn=0 nChannel=0 nDirection=1 nHistoryInterval=0 nElapsedTime= 0bValid=1 nHEC=0 nTotalCells=0 nUserTotalCells=0 nIBE=0 nTxUserTotalCells=0 nTxIBE=0 nCRC_P=0 nCRCP_P=0 nCV_P=0 nCVP_P=0

For ES & SES
Código: [Seleccionar]
pmlsc1dg 1 0
nReturn=0 nDirection=1 nHistoryInterval=0 nElapsedTime=0 bValid=1 nES=0 nSES=0  nLOSS=0nUAS=0 nLO        FS=0

System Msan Vendor ID
Código: [Seleccionar]
g997listrg 0
nReturn=0 nDirection=0 G994VendorID=IFTNU SystemVendorID=IFTN VersionNumber=5 SerialNumber=1 SelfTestResult=0 XTSECapabilities=(00,00,00,00,00,00,00,07)

Struggling to write that extra info into the script -
The posters on here are of very high caliber - any  pointers help ect would be greatly appreciated
in any language!

Luchando para escribir esa información adicional en el guión -
Los carteles de aquí son de muy alto calibre - cualquier punteros ayudan ect sería muy apreciada
en cualquier idioma!
« Última modificación: 23-05-2014, 01:24 (Viernes) por kaitak »

doblecero

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #6 en: 23-05-2014, 08:16 (Viernes) »
Hi,
I wonder whether they (OpenWrt people) are going to be happy with you approach of expanding the given information in the status command (no offense, I'm not complaining), they might not accept a patch bacause of this - not sure, just raising, let's see what other members say

A ddifferent approch would be adding those exta info into a new command. Something like status-all. So, /etc/init.d/dsl_control status would return the same that always has been returning and /etc/init.d/dsl_control status-all would return all the information we (actually you :)) can get from the driver.

Anyway, good work done so far  >:( >:( >:(

Cheers.
« Última modificación: 23-05-2014, 08:19 (Viernes) por doblecero »

Pteridium

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #7 en: 23-05-2014, 10:34 (Viernes) »
Hi,
I wonder whether they (OpenWrt people) are going to be happy with you approach of expanding the given information in the status command (no offense, I'm not complaining), they might not accept a patch bacause of this - not sure, just raising, let's see what other members say

A ddifferent approch would be adding those exta info into a new command. Something like status-all. So, /etc/init.d/dsl_control status would return the same that always has been returning and /etc/init.d/dsl_control status-all would return all the information we (actually you :)) can get from the driver.

Anyway, good work done so far  >:( >:( >:(

Cheers.
I agree with you: status for the basic info and status-all for the extended. Should be easy to make it.
Another option is to make an independent script (something like /bin/dsl_status.sh) that shows the extended info. What do you think?

@kaitak: great discovery! A lot of thanks for share it.  >:( >:( >:(
« Última modificación: 23-05-2014, 10:35 (Viernes) por Pteridium »

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #8 en: 23-05-2014, 16:02 (Viernes) »
Thank you for the kind words  :D

Although I was only really just adding to the great work of Lee Essen,
Frank Meerkötter, asbokid ,espeltron and of course John Crispin
.*
 
A new command would be great - would make it easier to  add an element/tab in luci. ?

You guys know far more on how best to approach openwrt patches so I'll follow you guys.

Managed to add downstream/upstream  Interleave Delay and Noise P from g997csg 0 1 / g997csg 0 0

 --- for now I'll hold off adding error rates to "status" ,as I think your approach is better -- ;)

Código: [Seleccionar]
Interleave Delay:       1350ms / 950ms
Impulse Noise P:        50sym / 26sym
Line Attenuation:       17.8dB / 0.0dB
Noise Margin:            7.1dB / 6.2dB

Thanks
un cordial saludo
---------------------------------------------------------------------------------------------------------------------

 * http://patchwork.openwrt.org/patch/2941
   https://lists.openwrt.org/pipermail/openwrt-devel/2012-January/013602.html

http://luci.subsignal.org/trac/attachment/ticket/620/OpenWrt-Devel-dsl-support-for-the-luci-webinterface.patch

   http://hackingecibfocusv2fubirevb.wordpress.com/
   http://huaweihg612hacking.wordpress.com/
 
https://foro.seguridadwireless.net/openwrt/(desarrollo)-openwrt-en-astoria-arv7519rw22-livebox-2-1/160/
« Última modificación: 23-05-2014, 16:57 (Viernes) por kaitak »

Pteridium

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #9 en: 23-05-2014, 16:38 (Viernes) »
Thank you for the kind words  :D

Although I was only really just adding to the great work of Lee Essen,
Frank Meerkötter, asbokid  and of course John Crispin
.*
 
A new command would be great - would make it easier to  add an element/tab in luci. ?

You guys know far more on how best to approach openwrt patches so I'll follow you guys.

Managed to add downstream/upstream  Interleave Delay and Noise P from g997csg 0 1 / g997csg 0 0

 --- for now I'll hold off adding error rates to "status" ,as I think your approach is better -- ;)

Código: [Seleccionar]
Interleave Delay:       1350ms / 950ms
Impulse Noise P:        50sym / 26sym
Line Attenuation:       17.8dB / 0.0dB
Noise Margin:            7.1dB / 6.2dB

Thanks
un cordial saludo
---------------------------------------------------------------------------------------------------------------------

 * http://patchwork.openwrt.org/patch/2941
   https://lists.openwrt.org/pipermail/openwrt-devel/2012-January/013602.html

The patches you have mentioned was included in openwrt and LuCI (if not the patches itself, at least the idea). With those links the job should be easier.
I still think that, for the moment, the initial approach should be add "dsl_control status-all " as doblecero pointed or write an independent script.

My idea is to make both options an let developers decide which is the best for OpenWRT. What do you think?

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #10 en: 23-05-2014, 17:03 (Viernes) »
I'll just follow you guys in what ever method has the best chance to be included to patchwork.  :D

I have no real experience in this area.

You guys are far for skilled than I - You''ll have a script produced before I've even thought about where to start  ;D  ;D

muchas gracias  :D

Desconectado Tki2000

  • Moderador
  • *
  • Mensajes: 2141
Re: Ayudar con lantiq_dsl
« Respuesta #11 en: 23-05-2014, 18:01 (Viernes) »
I think that, whatever the change is to be, it has to be backwards compatible. So I think it should be treated as an addon.
As an addon, you may or may not use the info returned by dsl_status, and will not break some other apps (or scripts that someone has already made) that rely on the "legacy" behaviour.
If you implement that as a forced addition, then you could break some other apps that rely on it.
If implemented with another whole command, or as an aditional argument to dsl_status, it's the programmer's choice. Just select one way or the other.
No habrás entendido algo, hasta que seas capaz de explicárselo a tu abuela...
Hacemos pantallas con píxeles casi invisibles, para luego ampliar la letra porque no la vemos... Bonita paradoja...
Creamos analfabetos tecnológicos con una velocidad pasmosa. Todo el mundo "maneja" tecnología, casi nadie sabe lo que tiene entre las manos, pero todo el mundo opina.
El analfabetismo, antes, pasaba desapercibido. Ahora, se transmite por Internet y las redes sociales.
Los dispositivos táctiles y las pantallas pequeñas son una lacra para la información relevante y el desarrollo de interfaces de usuario.
Trabajar sin la nube debería ser una prestación de los IoT, no un bug.

Pteridium

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #12 en: 23-05-2014, 18:40 (Viernes) »
If implemented with another whole command, or as an aditional argument to dsl_status, it's the programmer's choice. Just select one way or the other.

That is the plan: make an add-on in dsl_control or an independent script that gathers the additional info. If we don't do it in that way the patches will be rejected.

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #13 en: 24-05-2014, 00:53 (Sábado) »
Thanks  guys  ;) ;D

« Última modificación: 24-05-2014, 01:56 (Sábado) por kaitak »

doblecero

  • Visitante
Re:
« Respuesta #14 en: 24-05-2014, 11:49 (Sábado) »
Thanks to you!
Your time and effort are highly appreciated ;)

Enviado desde mi GT-I9300 mediante Tapatalk


kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #15 en: 24-05-2014, 19:24 (Sábado) »
gracias, gracias  ;D

If there are any commands you would like testing or adding to the template  feel free to ask /test or amend with your elegant scripts  as  I am experiencing writers block  :-[

Código: [Seleccionar]
CPE Chipset:      Lantiq-VRx:5.4.8.6.1.6
CO Chipset:      BDCM:v10.07.26
Line State:      UP [0x801: showtime_tc_sync]
Attain Data Rate:   49106 Kbps / 2625 Kbps
Actual Data Rate:   49080 Kbps / 2684 Kbps
Interleave Delay:       8.50 ms / 5.50 ms
Impulse Noise Prot:     1.0 sym / 0.7 sym
Line Attenuation:   32.2 dB / 0.0 dB
Signal Attenuation:   28.2 dB / 0.0 dB
Noise Margin:      6.1 dB / 5.5 dB
Transmit Power:      13.6 dBm / 6.3 dBm
Line Uptime:      2m 4s
FEC Errors:             1433 / 6607
CRC Errors:             150 / 441
ES:                     133 / 2
SES:                    42 / 0
UAS:                    311 / 311

disfrutar de la final de fútbol  / Monaco F1  ;)

saludos cordiales
« Última modificación: 24-05-2014, 19:43 (Sábado) por kaitak »

Pteridium

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #16 en: 25-05-2014, 16:21 (Domingo) »
This is only a draft but should work. Was not added lucistats to avoid problems with LuCI.
Código: [Seleccionar]
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 OpenWrt.org

XDSL_CTRL=dsl_cpe_control

#
# Basic functions to send CLI commands to the vdsl_cpe_control daemon
#
dsl_cmd() {
killall -0 ${XDSL_CTRL} && (
echo "$@" > /tmp/pipe/dsl_cpe0_cmd
cat /tmp/pipe/dsl_cpe0_ack
)
}
dsl_val() {
echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
}

#
# Simple divide by 10 routine to cope with one decimal place
#
dbt() {
local a=$(expr $1 / 10)
local b=$(expr $1 % 10)
echo "${a}.${b}"
}
#
# Take a number and convert to k or meg
#
scale() {
local val=$1
local a
local b

if [ "$val" -gt 1000000 ]; then
a=$(expr $val / 1000)
b=$(expr $a % 1000)
a=$(expr $a / 1000)
printf "%d.%03d Mb" ${a} ${b}
elif [ "$val" -gt 1000 ]; then
a=$(expr $val / 1000)
printf "%d Kb" ${a}
else
echo "${val} b"
fi
}

#
# Read the data rates for both directions
#
data_rates() {
local csg
local dru
local drd
local sdru
local sdrd

csg=$(dsl_cmd g997csg 0 1)
drd=$(dsl_val "$csg" ActualDataRate)

csg=$(dsl_cmd g997csg 0 0)
dru=$(dsl_val "$csg" ActualDataRate)

[ -z "$drd" ] && drd=0
[ -z "$dru" ] && dru=0

sdrd=$(scale $drd)
sdru=$(scale $dru)

if [ "$action" = "lucistat" ]; then
echo "dsl.data_rate_down=$drd"
echo "dsl.data_rate_up=$dru"
echo "dsl.data_rate_down_s=\"$sdrd\""
echo "dsl.data_rate_up_s=\"$sdru\""
else
echo "Data Rate: ${sdrd}/s / ${sdru}/s"
fi
}

#
# Read the extended data rates for both directions
#
data_rates_extended() {
local csg
local lsg
local dru
local drd
local adru
local adrd
local sdru
local sdrd
local sadru
local sadrd

csg=$(dsl_cmd g997csg 0 1)
drd=$(dsl_val "$csg" ActualDataRate)

csg=$(dsl_cmd g997csg 0 0)
dru=$(dsl_val "$csg" ActualDataRate)

lsg=$(dsl_cmd g997lsg 1 1)
adrd=$(dsl_val "$lsg" ATTNDR)

lsg=$(dsl_cmd g997lsg 0 1)
adru=$(dsl_val "$lsg" ATTNDR)

[ -z "$drd" ] && drd=0
[ -z "$dru" ] && dru=0
[ -z "$adrd" ] && adrd=0
[ -z "$adru" ] && adru=0

sdrd=$(scale $drd)
sdru=$(scale $dru)

sadrd=$(scale $adrd)
sadru=$(scale $adru)

if [ "$action" = "lucistat" ]; then
echo "dsl.data_rate_down=$drd"
echo "dsl.data_rate_up=$dru"
echo "dsl.data_rate_down_s=\"$sdrd\""
echo "dsl.data_rate_up_s=\"$sdru\""
echo "dsl.att_data_rate_down=\"$adrd\""
echo "dsl.att_data_rate_up=\"$adru\""
echo "dsl.att_data_rate_down_s=\"$sadrd\""
echo "dsl.att_data_rate_up_s=\"$sadru\""
else
echo "Attain Data Rate: ${sadrd}ps / ${sadru}ps"
echo "Actual Data Rate: ${sdrd}ps / ${sdru}ps"
fi
}

#
# Chipset
#
chipset() {
local vig
local cs
local csv

vig=$(dsl_cmd vig)
cs=$(dsl_val "$vig" DSL_ChipSetType)
csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)

if [ "$action" = "lucistat" ]; then
echo "dsl.chipset=\"${cs} ${csv}\""
else
echo "Chipset: ${cs} ${csv}"
fi
}

#
# Work out how long the line has been up
#
line_uptime() {
local ccsg
local et
local etr
local d
local h
local m
local s
local rc=""

ccsg=$(dsl_cmd pmccsg 0 0 0)
et=$(dsl_val "$ccsg" nElapsedTime)

[ -z "$et" ] && et=0

if [ "$action" = "lucistat" ]; then
echo "dsl.line_uptime=${et}"
return
fi

d=$(expr $et / 86400)
etr=$(expr $et % 86400)
h=$(expr $etr / 3600)
etr=$(expr $etr % 3600)
m=$(expr $etr / 60)
s=$(expr $etr % 60)


[ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
[ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
[ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
[ "${d}" -ne 0 ] && rc="${d}d ${rc}"

[ -z "$rc" ] && rc="down"
echo "Line Uptime: ${rc}"
}

#
# Get noise and attenuation figures
#
line_data() {
local lsg
local latnu
local latnd
local snru
local snrd

lsg=$(dsl_cmd g997lsg 1 1)
latnd=$(dsl_val "$lsg" LATN)
snrd=$(dsl_val "$lsg" SNR)

lsg=$(dsl_cmd g997lsg 0 1)
latnu=$(dsl_val "$lsg" LATN)
snru=$(dsl_val "$lsg" SNR)

[ -z "$latnd" ] && latnd=0
[ -z "$latnu" ] && latnu=0
[ -z "$snrd" ] && snrd=0
[ -z "$snru" ] && snru=0

latnd=$(dbt $latnd)
latnu=$(dbt $latnu)
snrd=$(dbt $snrd)
snru=$(dbt $snru)

if [ "$action" = "lucistat" ]; then
echo "dsl.line_attenuation_down=$latnd"
echo "dsl.line_attenuation_up=$latnu"
echo "dsl.noise_margin_down=$snrd"
echo "dsl.noise_margin_up=$snru"
else
echo "Line Attenuation: ${latnd}dB / ${latnu}dB"
echo "Noise Margin: ${snrd}dB / ${snru}dB"
fi
}

#
# Is the line up? Or what state is it in?
#
line_state() {
local lsg=$(dsl_cmd lsg)
local ls=$(dsl_val "$lsg" nLineState);
local s;

case "$ls" in
"0x0") s="not initialized" ;;
"0x1") s="exception" ;;
"0x10") s="not updated" ;;
"0xff") s="idle request" ;;
"0x100") s="idle" ;;
"0x1ff") s="silent request" ;;
"0x200") s="silent" ;;
"0x300") s="handshake" ;;
"0x380") s="full_init" ;;
"0x400") s="discovery" ;;
"0x500") s="training" ;;
"0x600") s="analysis" ;;
"0x700") s="exchange" ;;
"0x800") s="showtime_no_sync" ;;
"0x801") s="showtime_tc_sync" ;;
"0x900") s="fastretrain" ;;
"0xa00") s="lowpower_l2" ;;
"0xb00") s="loopdiagnostic active" ;;
"0xb10") s="loopdiagnostic data exchange" ;;
"0xb20") s="loopdiagnostic data request" ;;
"0xc00") s="loopdiagnostic complete" ;;
"0x1000000") s="test" ;;
"0xd00") s="resync" ;;
"0x3c0") s="short init entry" ;;
"") s="not running daemon"; ls="0xfff" ;;
*) s="unknown" ;;
esac

if [ $action = "lucistat" ]; then
echo "dsl.line_state_num=$ls"
echo "dsl.line_state_detail=\"$s\""
if [ "$ls" = "0x801" ]; then
echo "dsl.line_state=\"UP\""
else
echo "dsl.line_state=\"DOWN\""
fi
else
if [ "$ls" = "0x801" ]; then
echo "Line State: UP [$ls: $s]"
else
echo "Line State: DOWN [$ls: $s]"
fi
fi
}

status() {
chipset
line_state
data_rates
line_data
line_uptime
}

status_all() {
chipset
line_state
data_rates_extended
line_data
line_uptime
}

lucistat() {
echo "local dsl={}"
status
echo "return dsl"
}
The extended info is displayed with "/etc/init.d/dsl_control status_all".
I couldn't test the script so any advice will be welcome.  :-\

Edit: here are the patch and the modified lantiq_dsl.sh. The file is located, inside the flash of the router, in /lib/functions/. The patch is intended to be applied in the OpenWRT sources with a simple "patch -p0 -i dsl_info.patch".
« Última modificación: 25-05-2014, 16:45 (Domingo) por Pteridium »

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #17 en: 25-05-2014, 21:02 (Domingo) »
Gracias gracias for the draft.

Worked no problem when adding extra commands /help in dsl_control  ( shortened "all" command also works great  
 
/etc/init.d/dsl_control
Código: [Seleccionar]
 
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 OpenWrt.org
# needs to start before the atm layer which starts at 50
START=48

EXTRA_COMMANDS="status status_all lucistat"       ++
EXTRA_HELP="    status  Get DSL status information
        status_ all     Get DSL status extended  information   +++
        lucistat  Get status information if lua friendly format"


root@OpenWrt:~#  /etc/init.d/dsl_control status_all
Código: [Seleccionar]
Chipset:                Lantiq-VRx Unknown
Line State:             UP [0x801: showtime_tc_sync]
Attain Data Rate:       0. 0 Mbps / 0.0 Mbps
Actual Data Rate:       0.0 Mbps / 0.0 Mbps
Line Attenuation:       17.8dB / 0.0dB
Noise Margin:           6.5dB / 6.1dB
Line Uptime:            0h  0m 40s

root@OpenWrt:~#  /etc/init.d/dsl_control status
Código: [Seleccionar]
Chipset:                Lantiq-VRx Unknown
Line State:             UP [0x801: showtime_tc_sync]
Data Rate:              0 Mb/s / 0Mb/s
Line Attenuation:       17.8dB / 0.0dB
Noise Margin:           6.5dB / 6.1dB
Line Uptime:            0h 0m 7s


 root@OpenWrt:~# /etc/init.d/dsl_control lucistat
Código: [Seleccionar]
local dsl={}
dsl.chipset="Lantiq-VRx Unknown"
dsl.line_state_num=0x801
dsl.line_state_detail="showtime_tc_sync"
dsl.line_state="UP"
dsl.data_rate_down=0
dsl.data_rate_up=0
dsl.data_rate_down_s="0 Mb"
dsl.data_rate_up_s=" 0Mb"
dsl.line_attenuation_down=17.8
dsl.line_attenuation_up=0.0
dsl.noise_margin_down=6.5
dsl.noise_margin_up=6.1
dsl.line_uptime=100
return dsl


Syntax: /etc/init.d/dsl_control [command]
Código: [Seleccionar]
Available commands:
        start   Start the service
        stop    Stop the service
        restart Restart the service
        reload  Reload configuration files (or restart if that fails)
        enable  Enable service autostart
        disable Disable service autostart
        status  Get DSL status information
        status_ all     Get DSL status extended  information
        lucistat  Get status information if lua friendly format

« Última modificación: 25-05-2014, 22:03 (Domingo) por kaitak »

kaitak

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #18 en: 26-05-2014, 15:38 (Lunes) »
No problems so far  20h+   running smoothly  {lisamente?}

Código: [Seleccionar]
root@OpenWrt:~# /etc/init.d/dsl_control all
Chipset:                Lantiq-VRx Unknown
Line State:             UP [0x801: showtime_tc_sync]
Attain Data Rate:       49.588 Mbps / 11.134 Mbps
Actual Data Rate:       48.752 Mbps / 11.352 Mbps
Line Attenuation:       17.8dB / 0.0dB
Noise Margin:           6.4dB / 6.0dB
Line Uptime:            21h 52m 11s
Gracias  :D
« Última modificación: 26-05-2014, 15:42 (Lunes) por kaitak »

doblecero

  • Visitante
Re: Ayudar con lantiq_dsl
« Respuesta #19 en: 26-05-2014, 16:20 (Lunes) »
Great!
As soon as I sort some compilations issues out I'll update this on my Livebox and see how it works too. :)