lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Using ARP to get MAC address


From: Tomas D.
Subject: Re: [lwip-users] Using ARP to get MAC address
Date: Thu, 23 Feb 2012 23:08:09 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 2012.02.20 21:35, Kieran Mansley wrote:
On 19 Feb 2012, at 13:42, Tomas D. wrote:

If find_entry() is returning 0 (i.e. it has a row for that IP addr at index 0) 
but etharp_find_addr() is returning -1 that must mean that the arp_table.state 
for that row is not ETHARP_STATE_STABLE.  What is it?  That will show you the 
problem.

Hello,
exactly, find_entry() returns 0 as index, but arp_table.state returns 
ETHARP_STATE_PENDING. I can't get it to go ETHARP_STATE_STABLE. Maybe someone 
could drop me some pointers how to solve this?
Are you getting a valid ARP response from the other end?  It might be worth 
tracing through what happens in lwIP when that packet is received to see why it 
doesn't transition to STABLE as a result.

Hello again,
seems like my problem was solved temporarily :-)
The situation:
LwIP runs on a microcontroller, with no RTOS. The other microcontroller sends SPI command with remote IP address, so the first one with LwIP has to send ARP command and get the remote MAC. I've implemented SPI interrupt, which receives the remote IP address and does ARP query. However my first tests were not inside an interrupt, so this code worked fine:
if(etharp_query() == ERR_OK) {
    while(etharp_find_addr() < 0) {
        ethernetif_input();
    }
}

Now if I try to do the same inside an interrupt, the controller hangs on the while() and I get no results and no exit from interrupt. Dead end. If I change the code to:
if(etharp_query() == ERR_OK) {
    if(etharp_find_addr() > -1) {
        //... do the stuff
    }
}
Then I get no answer after the first interrupt is done, but I get result when I send the same SPI command again and get into the second interrupt. This is logically explainable, since ethernetif_input() in the main cycle does the processing job. I don't understand why do I get while() hanged? Maybe someone could tell me how to solve this problem of getting IP address if I am inside interrupt where ethernetif_input() doesn't do the processing?

P.S. I've also tried:
if(etharp_query() == ERR_OK) {
    delay_ms(1000); // delay here one second
    ethernetif_input(); // process packet
    if(etharp_find_addr() > -1) {
        //... do the stuff
    }
}

But sometimes it works, sometimes not, but I also get processor hanged many times.

Thanks.

Tomas D.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]