Skip to content

Commit cc5ad5f

Browse files
committed
EthernetC33 debugging
1 parent 6ee152f commit cc5ad5f

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

libraries/Ethernet/src/Ethernet.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ void CEthernet::setDNS(IPAddress dns_server) {
7373
/* -------------------------------------------------------------------------- */
7474
int CEthernet::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
7575
/* -------------------------------------------------------------------------- */
76-
int ret = (int)CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
77-
begin(timeout, responseTimeout);
78-
return ret;
76+
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
77+
return begin(timeout, responseTimeout);
7978
}
8079

8180
/* -------------------------------------------------------------------------- */
@@ -108,7 +107,7 @@ int CEthernet::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_ser
108107
/* -------------------------------------------------------------------------- */
109108
int CEthernet::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
110109
/* -------------------------------------------------------------------------- */
111-
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac_address);
110+
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
112111
return begin(local_ip, subnet, gateway, dns_server);
113112
}
114113

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

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)