Skip to content

Commit

Permalink
EthernetC33 debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy authored and aentinger committed Jan 9, 2024
1 parent 79e014e commit fc6aad0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
7 changes: 3 additions & 4 deletions libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ void CEthernet::setDNS(IPAddress dns_server) {
/* -------------------------------------------------------------------------- */
int CEthernet::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
/* -------------------------------------------------------------------------- */
int ret = (int)CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
begin(timeout, responseTimeout);
return ret;
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
return begin(timeout, responseTimeout);
}

/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -111,7 +110,7 @@ int CEthernet::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_ser
/* -------------------------------------------------------------------------- */
int CEthernet::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
/* -------------------------------------------------------------------------- */
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac_address);
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
return begin(local_ip, dns_server, gateway, subnet);
}

Expand Down
17 changes: 10 additions & 7 deletions libraries/lwIpWrapper/src/CNetIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,19 @@ err_t CEth::output(struct netif* _ni, struct pbuf *p) {
err_t errval = ERR_OK;

if(eth_output_can_transimit()) {
uint16_t tx_buf_dim = 0;
uint16_t tx_buf_dim = p->tot_len;

// TODO analyze the race conditions that may arise from sharing a non synchronized buffer
uint8_t *tx_buf = eth_get_tx_buffer(&tx_buf_dim);
assert (p->tot_len <= tx_buf_dim);
if (p->tot_len <= tx_buf_dim) {

uint16_t bytes_actually_copied = pbuf_copy_partial(p, tx_buf, p->tot_len, 0);
uint16_t bytes_actually_copied = pbuf_copy_partial(p, tx_buf, p->tot_len, 0);

if (bytes_actually_copied > 0 && !eth_output(tx_buf, bytes_actually_copied)) {
errval = ERR_IF;
if (bytes_actually_copied > 0 && !eth_output(tx_buf, bytes_actually_copied)) {
errval = ERR_IF;
}
} else {
errval = ERR_MEM;
}
} else {
errval = ERR_INPROGRESS;
Expand Down Expand Up @@ -516,7 +519,7 @@ bool CLwipIf::setMacAddress(NetIfType_t type, uint8_t* mac)
eth_set_mac_address(mac);
}

CLwipIf::getInstance().startSyncRequest();
CLwipIf::getInstance().restartAsyncRequest();
return true;
}

Expand Down Expand Up @@ -546,7 +549,7 @@ int CLwipIf::getMacAddress(NetIfType_t type, uint8_t* mac)
rv = MAC_ADDRESS_DIM;
}

CLwipIf::getInstance().startSyncRequest();
CLwipIf::getInstance().restartAsyncRequest();
return rv;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/lwIpWrapper/src/CNetIf.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CNetIf {
unsigned long dhcp_timeout;
DhcpSt_t dhcp_st;
bool dhcp_started;
bool dhcp_acquired;
volatile bool dhcp_acquired;
uint8_t _dhcp_lease_state;
void dhcp_task();
void dhcp_reset();
Expand Down

0 comments on commit fc6aad0

Please sign in to comment.