Use multiple concurrent TCP connections

This uses multiple concurrent TCP connections by making the state
of the connection including the output buffer a part of the application
data. This leads to the buffer, to be sent length of data and the already
sent data to be part of that state and must be handed over to functions
that generate data. At this point this leads to an overuse of OSEG and DSEG
memory space so further work needs to be done on tuning the code.
Putting it into a branch for now.
This commit is contained in:
logicog
2025-08-06 17:00:14 +02:00
parent fff09a0521
commit 984831620c
6 changed files with 92 additions and 98 deletions
+43 -49
View File
@@ -4,81 +4,75 @@
#pragma codeseg BANK1
extern __xdata uint8_t outbuf[2048];
extern __xdata uint16_t slen;
extern __code uint8_t * __code hex;
extern __xdata uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;
extern __code uint8_t ownMAC[];
inline void byte_to_html(uint8_t a)
{
outbuf[slen++] = hex[(a >> 4) & 0xf];
outbuf[slen++] = hex[a & 0xf];
}
#define PUTC(c) *outbuf++ = c;
#define PUTBYTE(a) { *outbuf++ = hex[(a >> 4) & 0xf]; *outbuf++ = hex[a & 0xf]; }
inline void char_to_html(char c)
{
outbuf[slen++] = c;
}
inline void itoa_html(uint8_t v)
inline uint8_t itoa_html(uint8_t v, __xdata uint8_t *outbuf)
{
uint8_t t = (v / 100) % 10;
if (t)
char_to_html('0' + t);
PUTC('0' + t);
t = (v / 10) % 10;
if (t)
char_to_html('0' + t);
char_to_html('0' + (v % 10));
PUTC('0' + t);
PUTC('0' + (v % 10));
if (v >= 100)
return 3;
else if (v >= 10)
return 2;
else
return 1;
}
uint16_t stat_content(void)
uint16_t stat_content(__xdata uint8_t *outbuf)
{
print_string("stat_content called\n");
return 0;
}
uint16_t port_status(void)
uint16_t port_status(__xdata uint8_t *outbuf)
{
print_string("port_status called\n");
return 0;
}
uint16_t html_index(void)
uint16_t html_index(__xdata uint8_t *outbuf)
{
__xdata uint8_t *oldptr = outbuf;
print_string("html_index called\n");
slen += strtox(outbuf + slen, "<tr><td>IP Address</td><td>");
print_string("\nIP:");
print_byte(uip_hostaddr[0]); write_char('.');
print_byte(uip_hostaddr[0] >> 8); write_char('.');
print_byte(uip_hostaddr[1]); write_char('.');
print_byte(uip_hostaddr[1] >> 8); write_char('\n');
itoa_html(uip_hostaddr[0]); char_to_html('.');
itoa_html(uip_hostaddr[0] >> 8); char_to_html('.');
itoa_html(uip_hostaddr[1]); char_to_html('.');
itoa_html(uip_hostaddr[1]);
slen += strtox(outbuf + slen, "</td></tr><tr><td>Gateway</td><td>");
itoa_html(uip_draddr[0]); char_to_html('.');
itoa_html(uip_draddr[0] >> 8); char_to_html('.');
itoa_html(uip_draddr[1]); char_to_html('.');
itoa_html(uip_draddr[1] >> 8);
slen += strtox(outbuf + slen, "</td></tr><tr><td>Netmask</td><td>");
itoa_html(uip_netmask[0]); char_to_html('.');
itoa_html(uip_netmask[0] >> 8); char_to_html('.');
itoa_html(uip_netmask[1]); char_to_html('.');
itoa_html(uip_netmask[1] >> 8);
slen += strtox(outbuf + slen, "</td></tr><tr><td>MAC Address</td><td>");
byte_to_html(ownMAC[0]); char_to_html(':');
byte_to_html(ownMAC[1]); char_to_html(':');
byte_to_html(ownMAC[2]); char_to_html(':');
byte_to_html(ownMAC[3]); char_to_html(':');
byte_to_html(ownMAC[4]); char_to_html(':');
byte_to_html(ownMAC[5]);
slen += strtox(outbuf + slen, "</td></tr>");
return 0;
outbuf += strtox(outbuf, "<tr><td>IP Address</td><td>");
outbuf += itoa_html(uip_hostaddr[0], outbuf); PUTC('.');
outbuf += itoa_html(uip_hostaddr[0] >> 8, outbuf); PUTC('.');
outbuf += itoa_html(uip_hostaddr[1], outbuf); PUTC('.');
outbuf += itoa_html(uip_hostaddr[1] >> 8, outbuf);
outbuf += strtox(outbuf, "</td></tr><tr><td>Gateway</td><td>");
outbuf += itoa_html(uip_draddr[0], outbuf); PUTC('.');
outbuf += itoa_html(uip_draddr[0] >> 8, outbuf); PUTC('.');
outbuf += itoa_html(uip_draddr[1], outbuf); PUTC('.');
outbuf += itoa_html(uip_draddr[1] >> 8, outbuf);
outbuf += strtox(outbuf, "</td></tr><tr><td>Netmask</td><td>");
outbuf += itoa_html(uip_netmask[0], outbuf); PUTC('.');
outbuf += itoa_html(uip_netmask[0] >> 8, outbuf); PUTC('.');
outbuf += itoa_html(uip_netmask[1], outbuf); PUTC('.');
outbuf += itoa_html(uip_netmask[1] >> 8, outbuf);
outbuf += strtox(outbuf, "</td></tr><tr><td>MAC Address</td><td>");
PUTBYTE(ownMAC[0]); PUTC(':');
PUTBYTE(ownMAC[1]); PUTC(':');
PUTBYTE(ownMAC[2]); PUTC(':');
PUTBYTE(ownMAC[3]); PUTC(':');
PUTBYTE(ownMAC[4]); PUTC(':');
PUTBYTE(ownMAC[5]);
outbuf += strtox(outbuf, "</td></tr>");
return outbuf - oldptr;
}