mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Convert unconditional prints to debug prints in httpd
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#ifndef __DEBUG_H__
|
||||
#define __DEBUG_H__
|
||||
|
||||
#ifdef DEBUG
|
||||
#define dbg_string(s) print_string(s)
|
||||
#define dbg_string_x(s) print_string_x(s)
|
||||
#define dbg_byte(s) print_byte(s)
|
||||
#define dbg_short(s) print_short(s)
|
||||
#define dbg_char(s) write_char(s)
|
||||
#else
|
||||
#define dbg_string(s)
|
||||
#define dbg_string_x(s)
|
||||
#define dbg_byte(s)
|
||||
#define dbg_short(s)
|
||||
#define dbg_char(s)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
CC = sdcc
|
||||
CC_FLAGS = -mmcs51 -I. -I../uip
|
||||
CC_FLAGS = -mmcs51 -I. -I.. -I../uip
|
||||
ASM = sdas8051
|
||||
AFLAGS= -plosgff
|
||||
|
||||
|
||||
+64
-58
@@ -1,12 +1,16 @@
|
||||
|
||||
#include "httpd.h"
|
||||
#include "page_impl.h"
|
||||
#include "../rtl837x_common.h"
|
||||
#include "../rtl837x_regs.h"
|
||||
#include "../cmd_parser.h"
|
||||
#include "../rtl837x_flash.h"
|
||||
#include "rtl837x_common.h"
|
||||
#include "rtl837x_regs.h"
|
||||
#include "cmd_parser.h"
|
||||
#include "rtl837x_flash.h"
|
||||
#include "uip.h"
|
||||
#include "../html_data.h"
|
||||
#include "html_data.h"
|
||||
|
||||
// #define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#define SESSION_ID_LENGTH 12
|
||||
#define SESSION_TIMEOUT 200
|
||||
@@ -209,7 +213,7 @@ __xdata uint8_t *scan_header(__xdata uint8_t *p)
|
||||
authenticated = 0;
|
||||
|
||||
while (*p != '\r' || *(p + 1) != '\n' || *(p + 2) != '\r' || *(p + 3) != '\n') {
|
||||
write_char(*p);
|
||||
dbg_char(*p);
|
||||
if (!*p++)
|
||||
break;
|
||||
if (is_word(p, "\nContent-Type:"))
|
||||
@@ -218,7 +222,7 @@ __xdata uint8_t *scan_header(__xdata uint8_t *p)
|
||||
session = p + 17;
|
||||
}
|
||||
if (content_type && is_word(content_type, "multipart/form-data; boundary")) {
|
||||
print_string("\nFound multipart\n");
|
||||
dbg_string("\nFound multipart\n");
|
||||
content_type += 30;
|
||||
uint8_t i = 0;
|
||||
while (content_type[i] != '\r' && content_type[i] != '\n') {
|
||||
@@ -237,12 +241,12 @@ __xdata uint8_t *scan_header(__xdata uint8_t *p)
|
||||
|
||||
if (session) {
|
||||
if (now - last_session_use > SESSION_TIMEOUT) {
|
||||
print_string("Session expired\n");
|
||||
dbg_string("Session expired\n");
|
||||
} else {
|
||||
if (is_word_x(session, session_id))
|
||||
authenticated = 1;
|
||||
else
|
||||
print_string("Invalid session cookie!\n");
|
||||
dbg_string("Invalid session cookie!\n");
|
||||
}
|
||||
}
|
||||
return p;
|
||||
@@ -273,8 +277,8 @@ uint8_t stream_upload(uint16_t bptr)
|
||||
__xdata uint8_t *p = uip_appdata;
|
||||
__xdata struct httpd_state * __xdata s = &(uip_conn->appstate);
|
||||
|
||||
print_string("Stream_upload called: ");
|
||||
print_short(bptr); write_char('\n');
|
||||
dbg_string("Stream_upload called: ");
|
||||
dbg_short(bptr); dbg_char('\n');
|
||||
|
||||
do {
|
||||
if (bptr >= uip_len) {
|
||||
@@ -284,7 +288,7 @@ uint8_t stream_upload(uint16_t bptr)
|
||||
// Have we reached the end of the part?
|
||||
if (!boundary[bindex]) {
|
||||
s->tstate = TSTATE_NONE;
|
||||
print_string("len 2: "); print_short(write_len); write_char(' ');
|
||||
dbg_string("len 2: "); dbg_short(write_len); dbg_char(' ');
|
||||
flash_region.addr = uptr;
|
||||
flash_region.len = write_len;
|
||||
flash_write_bytes(flash_buf);
|
||||
@@ -292,13 +296,13 @@ uint8_t stream_upload(uint16_t bptr)
|
||||
write_len = 0;
|
||||
// TODO: This is a bit premature, what about a nice web-page saying the device will reset???
|
||||
if (verify_crc) {
|
||||
print_string("CRC16: "); print_short(crc_final); write_char('\n');
|
||||
dbg_string("CRC16: "); dbg_short(crc_final); dbg_char('\n');
|
||||
if (crc_final == 0xb001) {
|
||||
print_string("Checksum OK.");
|
||||
dbg_string("Checksum OK.");
|
||||
} else {
|
||||
print_string("Checksum incorrect!");
|
||||
dbg_string("Checksum incorrect!");
|
||||
}
|
||||
print_string("Upload to flash done, will reset!\n");
|
||||
dbg_string("Upload to flash done, will reset!\n");
|
||||
reset_chip();
|
||||
}
|
||||
// Make sure there is a 0 at the end of the uploaded data
|
||||
@@ -325,8 +329,8 @@ uint8_t stream_upload(uint16_t bptr)
|
||||
crc16(p + bptr);
|
||||
flash_buf[write_len++] = p[bptr++];
|
||||
if (write_len >= FLASHMEM_PAGE_SIZE) {
|
||||
print_string("len: "); print_short(write_len); write_char(' ');
|
||||
print_string("CRC16: "); print_short(crc_value); write_char('\n');
|
||||
dbg_string("len: "); dbg_short(write_len); dbg_char(' ');
|
||||
dbg_string("CRC16: "); dbg_short(crc_value); dbg_char('\n');
|
||||
flash_region.addr = uptr;
|
||||
flash_region.len = FLASHMEM_PAGE_SIZE;
|
||||
flash_write_bytes(flash_buf);
|
||||
@@ -350,7 +354,7 @@ void handle_post(void)
|
||||
__xdata uint8_t *p = uip_appdata;
|
||||
__xdata uint8_t *request_path = p + 6;
|
||||
|
||||
print_string("Is POST\n");
|
||||
dbg_string("Is POST\n");
|
||||
p += 5; // Skip post
|
||||
// Find end of request path
|
||||
while (*p && !is_separator(*p))
|
||||
@@ -360,9 +364,9 @@ void handle_post(void)
|
||||
// Find end of request header
|
||||
boundary[0] ='\0';
|
||||
p = scan_header(p);
|
||||
print_string("Boundary: >"); print_string_x(boundary); print_string("<\n");
|
||||
dbg_string("Boundary: >"); dbg_string_x(boundary); dbg_string("<\n");
|
||||
if (!*p || !content_type) {
|
||||
print_string("Bad Request!\n");
|
||||
dbg_string("Bad Request!\n");
|
||||
send_not_found();
|
||||
return;
|
||||
}
|
||||
@@ -380,10 +384,10 @@ void handle_post(void)
|
||||
if (i)
|
||||
cmd_available = 1;
|
||||
} else if (is_word(request_path, "login")) {
|
||||
print_string("POST login\n");
|
||||
dbg_string("POST login\n");
|
||||
p += 8; // Read also over "pwd="
|
||||
if (is_word_x(p, passwd)) {
|
||||
print_string("Password accepted!\n");
|
||||
dbg_string("Password accepted!\n");
|
||||
read_reg_timer(&last_session_use);
|
||||
gen_random_bytes(session_id, SESSION_ID_LENGTH);
|
||||
session_id[SESSION_ID_LENGTH] = '\0';
|
||||
@@ -397,13 +401,13 @@ void handle_post(void)
|
||||
}
|
||||
return;
|
||||
} else if (is_word(request_path, "upload") || is_word(request_path, "config")) {
|
||||
print_string("POST upload/config request\n");
|
||||
dbg_string("POST upload/config request\n");
|
||||
if (!authenticated) {
|
||||
send_unauthorized();
|
||||
return;
|
||||
}
|
||||
if (!boundary[0]) {
|
||||
print_string("Bad request, no boundary!\n");
|
||||
dbg_string("Bad request, no boundary!\n");
|
||||
send_bad_request();
|
||||
return;
|
||||
}
|
||||
@@ -418,7 +422,7 @@ void handle_post(void)
|
||||
if (!content_type) // We are waiting for the part with the octet stream
|
||||
continue;
|
||||
} while (!is_word(content_type, "application/octet-stream"));
|
||||
print_string("Have content octets\n");
|
||||
dbg_string("Have content octets\n");
|
||||
p += 4; // Skip \r\n\r\n sequence at end of preamble of part
|
||||
|
||||
if (is_word(request_path, "upload")) {
|
||||
@@ -426,7 +430,7 @@ void handle_post(void)
|
||||
verify_crc = 1;
|
||||
max_upload = 1024576;
|
||||
} else {
|
||||
print_string("Configuration upload, erasing config mem!\n");
|
||||
dbg_string("Configuration upload, erasing config mem!\n");
|
||||
uptr = CONFIG_START;
|
||||
verify_crc = 0;
|
||||
max_upload = 2048;
|
||||
@@ -438,7 +442,7 @@ void handle_post(void)
|
||||
write_len = 0;
|
||||
stream_upload(p - uip_appdata);
|
||||
|
||||
print_string("Done reading first fragment\n");
|
||||
dbg_string("Done reading first fragment\n");
|
||||
return;
|
||||
|
||||
} else {
|
||||
@@ -457,26 +461,26 @@ void httpd_appcall(void)
|
||||
{
|
||||
__xdata struct httpd_state * __xdata s = &(uip_conn->appstate);
|
||||
|
||||
write_char('P');
|
||||
dbg_char('P');
|
||||
if(uip_connected() && s->tstate == TSTATE_CLOSED) {
|
||||
print_string("Connected...\n");
|
||||
dbg_string("Connected...\n");
|
||||
s->tstate = TSTATE_NONE;
|
||||
} else if (uip_closed()) {
|
||||
print_string("Connection closed\n");
|
||||
dbg_string("Connection closed\n");
|
||||
s->tstate = TSTATE_CLOSED;
|
||||
} else if (uip_aborted()) {
|
||||
print_string("Connection aborted\n");
|
||||
dbg_string("Connection aborted\n");
|
||||
uip_close();
|
||||
s->tstate = TSTATE_CLOSED;
|
||||
} else if (uip_poll()) {
|
||||
uip_len = 0;
|
||||
if (s->tstate == TSTATE_ACKED) {
|
||||
print_string("Closing because everything has been transmitted\n");
|
||||
dbg_string("Closing because everything has been transmitted\n");
|
||||
uip_close();
|
||||
s->tstate = TSTATE_CLOSED;
|
||||
}
|
||||
} else if (uip_acked() && s->tstate == TSTATE_TX) {
|
||||
print_string("ACK\n");
|
||||
dbg_string("ACK\n");
|
||||
if (slen > uip_mss()) {
|
||||
slen -= uip_mss();
|
||||
o_idx += uip_mss();
|
||||
@@ -488,15 +492,15 @@ void httpd_appcall(void)
|
||||
s->tstate = TSTATE_ACKED;
|
||||
|
||||
if (slen > uip_mss()) {
|
||||
print_string("Sending A: "); print_short(slen); write_char('\n');
|
||||
dbg_string("Sending A: "); dbg_short(slen); dbg_char('\n');
|
||||
uip_send(outbuf + o_idx, uip_mss());
|
||||
s->tstate = TSTATE_TX;
|
||||
} else if (slen > 0) {
|
||||
print_string("Sending B: "); print_short(slen); write_char('\n');
|
||||
dbg_string("Sending B: "); dbg_short(slen); dbg_char('\n');
|
||||
uip_send(outbuf + o_idx, slen);
|
||||
s->tstate = TSTATE_TX;
|
||||
} else if (cont_len) {
|
||||
print_string("CONT cont_len: "); print_short(cont_len);
|
||||
dbg_string("CONT cont_len: "); dbg_short(cont_len);
|
||||
slen = cont_len > uip_mss() ? uip_mss() : cont_len;
|
||||
if (slen > TCP_OUTBUF_SIZE)
|
||||
slen = TCP_OUTBUF_SIZE;
|
||||
@@ -518,13 +522,15 @@ void httpd_appcall(void)
|
||||
}
|
||||
} else if (uip_newdata() && s->tstate != TSTATE_TX) {
|
||||
cont_len = 0;
|
||||
write_char('<'); print_short(uip_len); write_char('\n');
|
||||
dbg_char('<'); dbg_short(uip_len); dbg_char('\n');
|
||||
__xdata uint8_t *p = uip_appdata;
|
||||
// Mark end of request header with \0
|
||||
p[uip_len] = 0;
|
||||
#ifdef DEBUG
|
||||
while (*p)
|
||||
write_char(*p++);
|
||||
write_char('\n');
|
||||
dbg_char(*p++);
|
||||
dbg_char('\n');
|
||||
#endif
|
||||
p = uip_appdata;
|
||||
if (is_word(p, "POST")) {
|
||||
handle_post();
|
||||
@@ -537,26 +543,26 @@ void httpd_appcall(void)
|
||||
}
|
||||
|
||||
if (is_word(p, "GET"))
|
||||
print_string("GET request ");
|
||||
dbg_string("GET request ");
|
||||
p += 4;
|
||||
scan_header(p);
|
||||
__xdata uint8_t *q = p;
|
||||
while (!is_separator(*p))
|
||||
p++;
|
||||
*p = '\0';
|
||||
print_string_x(q);
|
||||
write_char('\n');
|
||||
dbg_string_x(q);
|
||||
dbg_char('\n');
|
||||
|
||||
s->tstate = TSTATE_NONE;
|
||||
entry = find_entry(q);
|
||||
print_string("Entry is: "); print_byte(entry); write_char('\n');
|
||||
dbg_string("Entry is: "); dbg_byte(entry); dbg_char('\n');
|
||||
if (entry == 0xff) {
|
||||
if (!authenticated) {
|
||||
print_string("Not authorized!\n");
|
||||
dbg_string("Not authorized!\n");
|
||||
send_unauthorized();
|
||||
goto do_send;
|
||||
}
|
||||
print_string("Not file entry\n");
|
||||
dbg_string("Not file entry\n");
|
||||
if (!strcmp(q, "/status.json")) {
|
||||
send_status();
|
||||
} else if (!strcmp(q, "/information.json")) {
|
||||
@@ -582,7 +588,7 @@ void httpd_appcall(void)
|
||||
send_not_found();
|
||||
}
|
||||
} else {
|
||||
print_string("Have entry, authenticated: "); print_byte(authenticated); write_char('\n');
|
||||
dbg_string("Have entry, authenticated: "); dbg_byte(authenticated); dbg_char('\n');
|
||||
if (!authenticated && !(f_data[entry].start == FDATA_START_login_html
|
||||
|| f_data[entry].start == FDATA_START_style_css)) {
|
||||
send_to_login();
|
||||
@@ -602,35 +608,35 @@ void httpd_appcall(void)
|
||||
len_left = TCP_OUTBUF_SIZE - slen;
|
||||
cont_addr = f_data[entry].start + len_left;
|
||||
}
|
||||
print_string("MIME: "); print_string(mime_strings[f_data[entry].mime]); write_char('\n');
|
||||
dbg_string("MIME: "); dbg_string(mime_strings[f_data[entry].mime]); dbg_char('\n');
|
||||
flash_region.addr = f_data[entry].start;
|
||||
flash_region.len = len_left;
|
||||
flash_read_bulk(outbuf + slen);
|
||||
slen += len_left;
|
||||
}
|
||||
do_send:
|
||||
print_string("slen: "); print_short(slen); write_char('\n');
|
||||
dbg_string("slen: "); dbg_short(slen); dbg_char('\n');
|
||||
o_idx = 0;
|
||||
if (slen > uip_mss()) {
|
||||
print_string("Sending a: "); print_short(slen); write_char('\n');
|
||||
dbg_string("Sending a: "); dbg_short(slen); dbg_char('\n');
|
||||
uip_send(outbuf + o_idx, uip_mss());
|
||||
print_string("Sending a done\n");
|
||||
dbg_string("Sending a done\n");
|
||||
} else {
|
||||
print_string("Sending b: "); print_short(slen); write_char('\n');
|
||||
dbg_string("Sending b: "); dbg_short(slen); dbg_char('\n');
|
||||
uip_send(outbuf + o_idx, slen);
|
||||
print_string("Sending b done\n");
|
||||
dbg_string("Sending b done\n");
|
||||
}
|
||||
s->tstate = TSTATE_TX;
|
||||
} else if (uip_rexmit()) { // Connection established, need to rexmit?
|
||||
print_string("RETRANSMIT requested\n");
|
||||
dbg_string("RETRANSMIT requested\n");
|
||||
if (slen > uip_mss()) {
|
||||
print_string("Sending C: "); print_short(slen); write_char('\n');
|
||||
dbg_string("Sending C: "); dbg_short(slen); dbg_char('\n');
|
||||
uip_send(outbuf + o_idx, uip_mss());
|
||||
print_string("Sending C done\n");
|
||||
dbg_string("Sending C done\n");
|
||||
} else if (slen > 0) {
|
||||
print_string("Sending D: "); print_short(slen); write_char('\n');
|
||||
dbg_string("Sending D: "); dbg_short(slen); dbg_char('\n');
|
||||
uip_send(outbuf + o_idx, slen);
|
||||
print_string("Sending D done\n");
|
||||
dbg_string("Sending D done\n");
|
||||
}
|
||||
s->tstate = TSTATE_TX;
|
||||
uip_len = 0;
|
||||
|
||||
+29
-26
@@ -1,18 +1,21 @@
|
||||
// #define REGDBG 1
|
||||
|
||||
#include "../rtl837x_sfr.h"
|
||||
#include "../rtl837x_common.h"
|
||||
#include "../rtl837x_regs.h"
|
||||
#include "../rtl837x_port.h"
|
||||
#include "../rtl837x_flash.h"
|
||||
#include "rtl837x_sfr.h"
|
||||
#include "rtl837x_common.h"
|
||||
#include "rtl837x_regs.h"
|
||||
#include "rtl837x_port.h"
|
||||
#include "rtl837x_flash.h"
|
||||
#include "uip.h"
|
||||
#include "../html_data.h"
|
||||
#include "html_data.h"
|
||||
#include <stdint.h>
|
||||
#include "../phy.h"
|
||||
#include "../version.h"
|
||||
#include "../machine.h"
|
||||
#include "phy.h"
|
||||
#include "version.h"
|
||||
#include "machine.h"
|
||||
#include "page_impl.h"
|
||||
|
||||
// #define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
#pragma codeseg BANK1
|
||||
#pragma constseg BANK1
|
||||
|
||||
@@ -94,14 +97,14 @@ void itoa_html(uint8_t v)
|
||||
|
||||
uint16_t stat_content(void)
|
||||
{
|
||||
print_string("stat_content called\n");
|
||||
dbg_string("stat_content called\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint16_t port_status(void)
|
||||
{
|
||||
print_string("port_status called\n");
|
||||
dbg_string("port_status called\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -190,7 +193,7 @@ void sfp_send_data(uint8_t slot, uint8_t reg, uint8_t len)
|
||||
void send_basic_info(void)
|
||||
{
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
print_string("send_basic_info called\n");
|
||||
dbg_string("send_basic_info called\n");
|
||||
slen += strtox(outbuf + slen, "{\"ip_address\":\"");
|
||||
itoa_html(uip_hostaddr[0]); char_to_html('.');
|
||||
itoa_html(uip_hostaddr[0] >> 8); char_to_html('.');
|
||||
@@ -232,7 +235,7 @@ void send_basic_info(void)
|
||||
void send_vlan(uint16_t vlan)
|
||||
{
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
print_string("sending VLAN\n");
|
||||
dbg_string("sending VLAN\n");
|
||||
//{"members":"0x00060011"}
|
||||
slen += strtox(outbuf + slen, "{\"members\":\"0x");
|
||||
vlan_get(vlan);
|
||||
@@ -240,7 +243,7 @@ void send_vlan(uint16_t vlan)
|
||||
slen += strtox(outbuf + slen, "\",\"name\":\"");
|
||||
__xdata uint16_t n = vlan_name(vlan);
|
||||
if (n== 0xffff) {
|
||||
print_string("VLAN has no name\n");
|
||||
dbg_string("VLAN has no name\n");
|
||||
} else {
|
||||
while(vlan_names[n] && vlan_names[n] != ' ')
|
||||
char_to_html(vlan_names[n++]);
|
||||
@@ -251,9 +254,9 @@ void send_vlan(uint16_t vlan)
|
||||
|
||||
void send_counters(char port)
|
||||
{
|
||||
print_string("send_counters called: "); print_byte(port); write_char('\n');
|
||||
dbg_string("send_counters called: "); dbg_byte(port); dbg_char('\n');
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
print_string("sending counters\n");
|
||||
dbg_string("sending counters\n");
|
||||
|
||||
port--;
|
||||
uint8_t i = machine.phys_to_log_port[port];
|
||||
@@ -274,7 +277,7 @@ void send_counters(char port)
|
||||
|
||||
void send_mirror(void)
|
||||
{
|
||||
print_string("send_mirror called\n");
|
||||
dbg_string("send_mirror called\n");
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
|
||||
reg_read_m(RTL837x_MIRROR_CTRL);
|
||||
@@ -308,7 +311,7 @@ void send_mirror(void)
|
||||
|
||||
void send_lag(void)
|
||||
{
|
||||
print_string("send_lag called\n");
|
||||
dbg_string("send_lag called\n");
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
|
||||
char_to_html('[');
|
||||
@@ -334,7 +337,7 @@ void send_lag(void)
|
||||
|
||||
void send_eee(void)
|
||||
{
|
||||
print_string("send_eee called\nsending EEE status\n");
|
||||
dbg_string("send_eee called\nsending EEE status\n");
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
|
||||
reg_read_m(RTL8373_PHY_EEE_ABLTY);
|
||||
@@ -382,7 +385,7 @@ void send_eee(void)
|
||||
|
||||
void send_mtu(void)
|
||||
{
|
||||
print_string("send_mtu called\n");
|
||||
dbg_string("send_mtu called\n");
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
char_to_html('[');
|
||||
for (uint8_t i = machine.min_port; i <= machine.max_port; i++) {
|
||||
@@ -406,7 +409,7 @@ void send_mtu(void)
|
||||
void send_status(void)
|
||||
{
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
print_string("sending status\n");
|
||||
dbg_string("sending status\n");
|
||||
char_to_html('[');
|
||||
|
||||
for (uint8_t i = machine.min_port; i <= machine.max_port; i++) {
|
||||
@@ -507,14 +510,14 @@ void send_status(void)
|
||||
|
||||
void send_config(void)
|
||||
{
|
||||
print_string("send_config called\n");
|
||||
dbg_string("send_config called\n");
|
||||
__xdata uint32_t pos = CONFIG_START; // 70000 , 6c000 / 0xc000 = 9
|
||||
|
||||
extern __xdata uint16_t len_left = CONFIG_LEN;
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_TXT);
|
||||
while (read_flash((CONFIG_START-CODE0_SIZE) / CODE_BANK_SIZE + 1,
|
||||
(__code uint8_t *) (((CONFIG_START + len_left - CODE0_SIZE) % CODE_BANK_SIZE) + CODE0_SIZE + len_left)) == 0xff) {
|
||||
print_short(len_left);
|
||||
dbg_short(len_left);
|
||||
len_left--;
|
||||
}
|
||||
len_left++;
|
||||
@@ -532,12 +535,12 @@ void send_config(void)
|
||||
|
||||
void send_cmd_log(void)
|
||||
{
|
||||
print_string("send_cmd_log called\n");
|
||||
dbg_string("send_cmd_log called\n");
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_TXT);
|
||||
__xdata uint16_t p = (cmd_history_ptr + 1) & CMD_HISTORY_MASK;
|
||||
__xdata uint8_t found_begin = 0;
|
||||
print_string("History ptr: ");
|
||||
print_short(cmd_history_ptr); write_char('\n');
|
||||
dbg_string("History ptr: ");
|
||||
dbg_short(cmd_history_ptr); dbg_char('\n');
|
||||
while (p != cmd_history_ptr) {
|
||||
if (!cmd_history[p] || cmd_history[p] == '\n')
|
||||
found_begin = 1;
|
||||
|
||||
+3
-1
@@ -899,7 +899,9 @@ void handle_tx(void)
|
||||
for(uint8_t i = 0; i < UIP_CONNS; i++) {
|
||||
uip_periodic(i);
|
||||
if(uip_len > 0) {
|
||||
write_char('.'); print_short(i);
|
||||
#ifdef RXTXDBG
|
||||
write_char('.'); print_short(i);
|
||||
#endif
|
||||
uip_arp_out();
|
||||
tcpip_output();
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
CC = sdcc
|
||||
CC_FLAGS = -mmcs51 -I. -I../httpd
|
||||
CC_FLAGS = -mmcs51 -I. -I.. -I../httpd
|
||||
ASM = sdas8051
|
||||
AFLAGS= -plosgff
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#define DEBUG_PRINTF(...) /*printf(__VA_ARGS__)*/
|
||||
|
||||
// #define DEBUG
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* \defgroup uip The uIP TCP/IP stack
|
||||
* @{
|
||||
@@ -691,9 +694,9 @@ uip_process(u8_t flag) __banked
|
||||
if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED &&
|
||||
!uip_outstanding(uip_connr)) {
|
||||
uip_flags = UIP_POLL;
|
||||
write_char('B');
|
||||
dbg_char('B');
|
||||
UIP_APPCALL();
|
||||
write_char('b');
|
||||
dbg_char('b');
|
||||
goto appsend;
|
||||
}
|
||||
goto drop;
|
||||
@@ -745,9 +748,9 @@ uip_process(u8_t flag) __banked
|
||||
UIP_TIMEDOUT to inform the application that the
|
||||
connection has timed out. */
|
||||
uip_flags = UIP_TIMEDOUT;
|
||||
write_char('C');
|
||||
dbg_char('C');
|
||||
UIP_APPCALL();
|
||||
write_char('c');
|
||||
dbg_char('c');
|
||||
|
||||
/* We also send a reset packet to the remote host. */
|
||||
BUF->flags = TCP_RST | TCP_ACK;
|
||||
@@ -786,7 +789,7 @@ uip_process(u8_t flag) __banked
|
||||
the code for sending out the packet (the apprexmit
|
||||
label). */
|
||||
uip_flags = UIP_REXMIT;
|
||||
write_char('R');
|
||||
dbg_char('R');
|
||||
UIP_APPCALL();
|
||||
goto apprexmit;
|
||||
|
||||
@@ -1386,9 +1389,9 @@ uip_process(u8_t flag) __banked
|
||||
uip_connr->tcpstateflags = UIP_CLOSED;
|
||||
UIP_LOG("tcp: got reset, aborting connection.");
|
||||
uip_flags = UIP_ABORT;
|
||||
write_char('F');
|
||||
dbg_char('F');
|
||||
UIP_APPCALL();
|
||||
write_char('f');
|
||||
dbg_char('f');
|
||||
goto drop;
|
||||
}
|
||||
/* Calculated the length of the data, if the application has sent
|
||||
@@ -1532,16 +1535,16 @@ uip_process(u8_t flag) __banked
|
||||
uip_connr->len = 0;
|
||||
uip_len = 0;
|
||||
uip_slen = 0;
|
||||
write_char('H');
|
||||
dbg_char('H');
|
||||
UIP_APPCALL();
|
||||
write_char('h');
|
||||
dbg_char('h');
|
||||
goto appsend;
|
||||
}
|
||||
/* Inform the application that the connection failed */
|
||||
uip_flags = UIP_ABORT;
|
||||
write_char('I');
|
||||
dbg_char('I');
|
||||
UIP_APPCALL();
|
||||
write_char('I');
|
||||
dbg_char('I');
|
||||
/* The connection is closed after we send the RST */
|
||||
uip_conn->tcpstateflags = UIP_CLOSED;
|
||||
goto reset;
|
||||
@@ -1568,9 +1571,9 @@ uip_process(u8_t flag) __banked
|
||||
if(uip_len > 0) {
|
||||
uip_flags |= UIP_NEWDATA;
|
||||
}
|
||||
write_char('J');
|
||||
dbg_char('J');
|
||||
UIP_APPCALL();
|
||||
write_char('j');
|
||||
dbg_char('j');
|
||||
uip_connr->len = 1;
|
||||
uip_connr->tcpstateflags = UIP_LAST_ACK;
|
||||
uip_connr->nrtx = 0;
|
||||
@@ -1728,9 +1731,9 @@ uip_process(u8_t flag) __banked
|
||||
if(uip_flags & UIP_ACKDATA) {
|
||||
uip_connr->tcpstateflags = UIP_CLOSED;
|
||||
uip_flags = UIP_CLOSE;
|
||||
write_char('L');
|
||||
dbg_char('L');
|
||||
UIP_APPCALL();
|
||||
write_char('l');
|
||||
dbg_char('l');
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1751,9 +1754,9 @@ uip_process(u8_t flag) __banked
|
||||
}
|
||||
uip_add_rcv_nxt(1);
|
||||
uip_flags = UIP_CLOSE;
|
||||
write_char('M');
|
||||
dbg_char('M');
|
||||
UIP_APPCALL();
|
||||
write_char('m');
|
||||
dbg_char('m');
|
||||
goto tcp_send_ack;
|
||||
} else if(uip_flags & UIP_ACKDATA) {
|
||||
uip_connr->tcpstateflags = UIP_FIN_WAIT_2;
|
||||
@@ -1774,9 +1777,9 @@ uip_process(u8_t flag) __banked
|
||||
uip_connr->timer = 0;
|
||||
uip_add_rcv_nxt(1);
|
||||
uip_flags = UIP_CLOSE;
|
||||
write_char('N');
|
||||
dbg_char('N');
|
||||
UIP_APPCALL();
|
||||
write_char('n');
|
||||
dbg_char('n');
|
||||
goto tcp_send_ack;
|
||||
}
|
||||
if(uip_len > 0) {
|
||||
|
||||
Reference in New Issue
Block a user