mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
+30
-49
@@ -53,6 +53,13 @@ void charhex_to_html(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert (uint8_t) bool to ascii '0' or '1' char push on html-buffer.
|
||||||
|
void bool_to_html(char c)
|
||||||
|
{
|
||||||
|
outbuf[slen++] = c ? '1' : '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void char_to_html(char c)
|
void char_to_html(char c)
|
||||||
{
|
{
|
||||||
outbuf[slen++] = c;
|
outbuf[slen++] = c;
|
||||||
@@ -212,12 +219,12 @@ void send_counters(char port)
|
|||||||
|
|
||||||
void send_eee()
|
void send_eee()
|
||||||
{
|
{
|
||||||
print_string("send_eee called\n");
|
print_string("send_eee called\nsending EEE status\n");
|
||||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||||
print_string("sending EEE status\n");
|
|
||||||
|
|
||||||
reg_read_m(RTL8373_PHY_EEE_ABLTY);
|
reg_read_m(RTL8373_PHY_EEE_ABLTY);
|
||||||
uint8_t eee_ablty = sfr_data[3];
|
uint8_t eee_ablty = sfr_data[3];
|
||||||
|
|
||||||
char_to_html('[');
|
char_to_html('[');
|
||||||
for (uint8_t i = minPort; i <= maxPort; i++) {
|
for (uint8_t i = minPort; i <= maxPort; i++) {
|
||||||
slen += strtox(outbuf + slen, "{\"portNum\":");
|
slen += strtox(outbuf + slen, "{\"portNum\":");
|
||||||
@@ -225,51 +232,33 @@ void send_eee()
|
|||||||
itoa_html(log_to_phys_port[i]);
|
itoa_html(log_to_phys_port[i]);
|
||||||
else
|
else
|
||||||
itoa_html(i + 1);
|
itoa_html(i + 1);
|
||||||
|
|
||||||
if (IS_SFP(i)) {
|
if (IS_SFP(i)) {
|
||||||
slen += strtox(outbuf + slen, " ,\"isSFP\": 1");
|
slen += strtox(outbuf + slen, ",\"isSFP\":1");
|
||||||
} else {
|
} else {
|
||||||
slen += strtox(outbuf + slen, " ,\"isSFP\": 0 ");
|
slen += strtox(outbuf + slen, ",\"isSFP\":0,\"eee\":\"");
|
||||||
uint16_t v;
|
uint16_t v;
|
||||||
phy_read(i, PHY_MMD_AN, PHY_EEE_ADV2);
|
phy_read(i, PHY_MMD_AN, PHY_EEE_ADV2);
|
||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
slen += strtox(outbuf + slen, ",\"eee\":\"");
|
bool_to_html(v & PHY_EEE_BIT_2G5);
|
||||||
if (v & PHY_EEE_BIT_2G5)
|
|
||||||
char_to_html('1');
|
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
phy_read(i, PHY_MMD_AN, PHY_EEE_ADV);
|
phy_read(i, PHY_MMD_AN, PHY_EEE_ADV);
|
||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
if (v & PHY_EEE_BIT_1G)
|
bool_to_html(v & PHY_EEE_BIT_1G);
|
||||||
char_to_html('1');
|
bool_to_html(v & PHY_EEE_BIT_100M);
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
if (v & PHY_EEE_BIT_100M)
|
|
||||||
char_to_html('1');
|
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
|
|
||||||
phy_read(i, PHY_MMD_AN, PHY_EEE_LP_ABILITY2);
|
phy_read(i, PHY_MMD_AN, PHY_EEE_LP_ABILITY2);
|
||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
slen += strtox(outbuf + slen, "\", \"eee_lp\":\"");
|
slen += strtox(outbuf + slen, "\",\"eee_lp\":\"");
|
||||||
if (v & PHY_EEE_BIT_2G5)
|
bool_to_html (v & PHY_EEE_BIT_2G5);
|
||||||
char_to_html('1');
|
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
phy_read(i, PHY_MMD_AN, PHY_EEE_LP_ABILITY);
|
phy_read(i, PHY_MMD_AN, PHY_EEE_LP_ABILITY);
|
||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
if (v & PHY_EEE_BIT_1G)
|
bool_to_html(v & PHY_EEE_BIT_1G);
|
||||||
char_to_html('1');
|
bool_to_html(v & PHY_EEE_BIT_100M);
|
||||||
else
|
|
||||||
char_to_html('0');
|
slen += strtox(outbuf + slen, "\",\"active\":");
|
||||||
if (v & PHY_EEE_BIT_100M)
|
bool_to_html(eee_ablty & (1 << i));
|
||||||
char_to_html('1');
|
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
slen += strtox(outbuf + slen, "\", \"active\": ");
|
|
||||||
if (eee_ablty & (1 << i))
|
|
||||||
char_to_html('1');
|
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
}
|
}
|
||||||
char_to_html('}');
|
char_to_html('}');
|
||||||
if (i < maxPort)
|
if (i < maxPort)
|
||||||
@@ -293,15 +282,10 @@ void send_status(void)
|
|||||||
else
|
else
|
||||||
itoa_html(i + 1);
|
itoa_html(i + 1);
|
||||||
|
|
||||||
slen += strtox(outbuf + slen, ",\"isSFP\":");
|
|
||||||
if (IS_SFP(i)) {
|
if (IS_SFP(i)) {
|
||||||
char_to_html('1');
|
slen += strtox(outbuf + slen, ",\"isSFP\":1,\"enabled\":");
|
||||||
slen += strtox(outbuf + slen, ",\"enabled\":");
|
bool_to_html(!((sfp_pins_last >> (i == maxPort ? 0 : 4)) & 1));
|
||||||
if (!((sfp_pins_last >> (i == maxPort ? 0 : 4)) & 1)) {
|
|
||||||
char_to_html('1');
|
|
||||||
} else {
|
|
||||||
char_to_html('0');
|
|
||||||
}
|
|
||||||
slen += strtox(outbuf + slen, ",\"link\":");
|
slen += strtox(outbuf + slen, ",\"link\":");
|
||||||
uint8_t rate = sfp_read_reg(i == maxPort ? 0 : 1, 12);
|
uint8_t rate = sfp_read_reg(i == maxPort ? 0 : 1, 12);
|
||||||
if (rate == 0xd)
|
if (rate == 0xd)
|
||||||
@@ -313,13 +297,10 @@ void send_status(void)
|
|||||||
else
|
else
|
||||||
char_to_html('1'); // 100M ???
|
char_to_html('1'); // 100M ???
|
||||||
} else {
|
} else {
|
||||||
char_to_html('0');
|
slen += strtox(outbuf + slen, ",\"isSFP\":0,\"enabled\":");
|
||||||
slen += strtox(outbuf + slen, ",\"enabled\":");
|
|
||||||
phy_read(i, 0x1f, 0xa610);
|
phy_read(i, 0x1f, 0xa610);
|
||||||
if (SFR_DATA_8 == 0x20)
|
bool_to_html(SFR_DATA_8 == 0x20);
|
||||||
char_to_html('1');
|
|
||||||
else
|
|
||||||
char_to_html('0');
|
|
||||||
slen += strtox(outbuf + slen, ",\"link\":");
|
slen += strtox(outbuf + slen, ",\"link\":");
|
||||||
reg_read_m(RTL837X_REG_LINKS);
|
reg_read_m(RTL837X_REG_LINKS);
|
||||||
uint8_t b = sfr_data[3 - (i >> 1)];
|
uint8_t b = sfr_data[3 - (i >> 1)];
|
||||||
|
|||||||
Reference in New Issue
Block a user