Skip to content

Commit e19a1b6

Browse files
authored
Merge pull request #223 from JAndrassy/ethernet_debugging
EthernetC33 debugging
2 parents 79e014e + fc6aad0 commit e19a1b6

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

Diff for: libraries/Ethernet/src/Ethernet.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ void CEthernet::setDNS(IPAddress dns_server) {
7676
/* -------------------------------------------------------------------------- */
7777
int CEthernet::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
7878
/* -------------------------------------------------------------------------- */
79-
int ret = (int)CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
80-
begin(timeout, responseTimeout);
81-
return ret;
79+
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
80+
return begin(timeout, responseTimeout);
8281
}
8382

8483
/* -------------------------------------------------------------------------- */
@@ -111,7 +110,7 @@ int CEthernet::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_ser
111110
/* -------------------------------------------------------------------------- */
112111
int CEthernet::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
113112
/* -------------------------------------------------------------------------- */
114-
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac_address);
113+
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
115114
return begin(local_ip, dns_server, gateway, subnet);
116115
}
117116

Diff for: libraries/lwIpWrapper/src/CNetIf.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,19 @@ err_t CEth::output(struct netif* _ni, struct pbuf *p) {
352352
err_t errval = ERR_OK;
353353

354354
if(eth_output_can_transimit()) {
355-
uint16_t tx_buf_dim = 0;
355+
uint16_t tx_buf_dim = p->tot_len;
356356

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

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

363-
if (bytes_actually_copied > 0 && !eth_output(tx_buf, bytes_actually_copied)) {
364-
errval = ERR_IF;
363+
if (bytes_actually_copied > 0 && !eth_output(tx_buf, bytes_actually_copied)) {
364+
errval = ERR_IF;
365+
}
366+
} else {
367+
errval = ERR_MEM;
365368
}
366369
} else {
367370
errval = ERR_INPROGRESS;
@@ -516,7 +519,7 @@ bool CLwipIf::setMacAddress(NetIfType_t type, uint8_t* mac)
516519
eth_set_mac_address(mac);
517520
}
518521

519-
CLwipIf::getInstance().startSyncRequest();
522+
CLwipIf::getInstance().restartAsyncRequest();
520523
return true;
521524
}
522525

@@ -546,7 +549,7 @@ int CLwipIf::getMacAddress(NetIfType_t type, uint8_t* mac)
546549
rv = MAC_ADDRESS_DIM;
547550
}
548551

549-
CLwipIf::getInstance().startSyncRequest();
552+
CLwipIf::getInstance().restartAsyncRequest();
550553
return rv;
551554
}
552555

Diff for: libraries/lwIpWrapper/src/CNetIf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class CNetIf {
148148
unsigned long dhcp_timeout;
149149
DhcpSt_t dhcp_st;
150150
bool dhcp_started;
151-
bool dhcp_acquired;
151+
volatile bool dhcp_acquired;
152152
uint8_t _dhcp_lease_state;
153153
void dhcp_task();
154154
void dhcp_reset();

0 commit comments

Comments
 (0)