diff --git a/html/main.js b/html/main.js index 2f256ee..d58f54e 100644 --- a/html/main.js +++ b/html/main.js @@ -92,31 +92,47 @@ function update(callback) { var iHTML = ""; iHTML += ""; if (p.isSFP) { - pAdvertised[n] = 0; + pAdvertised[n] = 0; + const hasExtendedStatus = p.sfp_options & 0x40; iHTML += ""; iHTML += ""; iHTML += ""; - if (p.sfp_options & 0x40) { + if (hasExtendedStatus) { iHTML += ""; iHTML += ""; + iHTML += ""; + iHTML += ""; iHTML += ""; iHTML += ""; iHTML += ""; } + // Not all devices & modules have LOS pin... + const rx_los_pin = p.sfp_los !== null ? Boolean(Number(p.sfp_los)) : null; + const rx_los_module = hasExtendedStatus ? Boolean(Number(p.sfp_state) & 0x2) : null; + if (rx_los_module !== null || rx_los_pin !== null) { + iHTML += ``; + } } else { pAdvertised[n] = parseInt(p.adv, 2); - } + }; iHTML += "
Link speed:" + linkS[p.link + 1] + "
Vendor:" + p.sfp_vendor + "
Model:" + p.sfp_model + "
Serial:" + p.sfp_serial + "
Temp:" + (Number(p.sfp_temp) >> 8) + "." + ((Number(p.sfp_temp) & 0xff)/256.0 * 100).toFixed(0) + " ℃
Vcc:" + (Number(p.sfp_vcc) / 10000.0).toFixed(2) + " V
TX-Fault:" + (Boolean(Number(p.sfp_state) & 0x4)) + "
TX-Disabled:" + (Boolean(Number(p.sfp_state) & 0x80)) + "
TX-Bias:" + (Number(p.sfp_txbias) / 500.0).toFixed(1) + " mA
TX-Power:" + (Number(p.sfp_txpower) / 10.0).toFixed(0) + " mW
RX-Power:" + (Number(p.sfp_rxpower) / 10.0).toFixed(0) + " mW
RX-LOS:${rxLosHTML(rx_los_pin, rx_los_module)}
"; tt.innerHTML = iHTML; - } - } - if (callback) - callback(); - } - }; - xhttp.open("GET", "/status.json", true); - xhttp.timeout = 5000; - sendXHTTP(xhttp); + }} + if (callback) + callback(); + }}; + xhttp.open("GET", "/status.json", true); + xhttp.timeout = 5000; + sendXHTTP(xhttp); +} + +function rxLosHTML(pinStatus, moduleStatus) { + if (moduleStatus !== null && pinStatus !== null && moduleStatus !== pinStatus) { + return `pin=${pinStatus}
mod=${moduleStatus}
❗❗❗❗`; + } + + // Returns first non null value + return moduleStatus ?? pinStatus; } function callbackXHTTP() diff --git a/httpd/page_impl.c b/httpd/page_impl.c index 82e5314..92aed11 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -655,7 +655,12 @@ void send_status(void) slen += strtox(outbuf + slen,"\",\"sfp_serial\":\""); for (register uint8_t s = 0; s < 16; s++) outbuf[slen++] = sfp_module_serial[machine.is_sfp[i]-1][s]; - char_to_html('"'); + slen += strtox(outbuf + slen,"\",\"sfp_los\":"); + if (machine.sfp_port[machine.is_sfp[i]-1].pin_los == GPIO_NA) { + slen += strtox(outbuf + slen,"null"); + } else { + bool_to_html(sfp_pins_last & (0x2 << (((machine.is_sfp[i]-1) << 2)))); + } } else { bool_to_html(0); } diff --git a/rtlplayground.c b/rtlplayground.c index 01a1fc6..d2727b2 100644 --- a/rtlplayground.c +++ b/rtlplayground.c @@ -124,6 +124,9 @@ __code uint16_t bit_mask[16] = { __xdata uint8_t linkbits_last[4]; __xdata uint8_t linkbits_last_p89; +// Last known state of the SFP detection/Loss of Signal pins +// SFP1 b0 = 1 => module missing, b1 = 1 => LOS; +// SFP2 b4 = 1 => module missing, b5 = 1 => LOS; __xdata uint8_t sfp_pins_last; __xdata char sfp_module_vendor[2][17]; __xdata char sfp_module_model[2][17];