From 1f6e07a1af0cad9a75316466c8e648d88cc24e90 Mon Sep 17 00:00:00 2001 From: diijkstra <16804536+diijkstra@users.noreply.github.com> Date: Fri, 13 Mar 2026 23:48:49 +0100 Subject: [PATCH] Web: Add SFP state/pin status The state of the SFP module is being already send in status.json, but was not parsed via Web UI. When debuging SFP LOS/Signal detection it is usefull to see what module is reporting back. Extended the SFP mouse-over information with: - RX LOS as reported in 0x02 bit of register 238 - External TX Disabled from 0x80 bit of register 238 - TX fault from 0x04 of the same register - The last state of RX LOS pin (available also when there is no 0x40 option on the module) This should help identify missing/incorrect setup of TX disabled pin. --- html/main.js | 4 ++++ httpd/page_impl.c | 3 ++- rtlplayground.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/html/main.js b/html/main.js index 085db57..1677a38 100644 --- a/html/main.js +++ b/html/main.js @@ -97,10 +97,14 @@ function update(callback) { if (p.sfp_options & 0x40) { iHTML += "Temp:" + (Number(p.sfp_temp) >> 8) + "." + ((Number(p.sfp_temp) & 0xff)/256.0 * 100).toFixed(0) + " ℃"; iHTML += "Vcc:" + (Number(p.sfp_vcc) / 10000.0).toFixed(2) + " V"; + iHTML += "TX-Fault:" + (Boolean(Number(p.sfp_state) & 0x4)) + ""; + iHTML += "TX-Disabled:" + (Boolean(Number(p.sfp_state) & 0x80)) + ""; iHTML += "TX-Bias:" + (Number(p.sfp_txbias) / 500.0).toFixed(1) + " mA"; iHTML += "TX-Power:" + (Number(p.sfp_txpower) / 10.0).toFixed(0) + " mW"; iHTML += "RX-Power:" + (Number(p.sfp_rxpower) / 10.0).toFixed(0) + " mW"; + iHTML += "RX-LOS:" + (Boolean(Number(p.sfp_state) & 0x2)) + ""; } + iHTML += "RX-LOS pin:" + Boolean(Number(p.sfp_los)) + ""; } else { pAdvertised[n] = parseInt(p.adv, 2); } diff --git a/httpd/page_impl.c b/httpd/page_impl.c index 82e5314..56aa523 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -655,7 +655,8 @@ 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\":"); + 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 041c7ed..8f320a7 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];