EthernetGateway hangs after "Gateway startup complete"


  • Hero Member

    Hello,
    I spent some hours to get my EthernetGateway running on the following configuration:

    • SainSmart Arduino Uno R3
    • SainSmart EthernetShield (5100)
    • EthernetGateway.ino
      I followed the steps in the documentation and luckily received the message: "Gateway startup complete"
      BUT then I noticed that I could not ping the gateway.

    After adding some "Serial.println"-calls in the setup() routine I discovered that the arduino did not return from the
    gw.begin(...); call. Having a look at the implementation made me a bit curious.

    setup() does the following:

    1. gw.begin
    2. Ethernet.begin
    3. server.begin

    gw.begin accepts a callback "writeEthernet" which is implemented as follows:
    void writeEthernet(char *writeBuffer) {
    server.write(writeBuffer);
    }
    This callback is called before server.begin is called. So server.write gets called before server.begin!

    To avoid calling server.write before server.begin was called I introduced a bool which is set to true at the end of setup() and used this
    in the following way:
    void writeEthernet(char *writeBuffer) {
    if (serverUp)
    {
    server.write(writeBuffer);
    }
    }

    Now my EthernetGateway runs fine, with this workaround.
    Is this a bug in the code?
    Could anyone provide some help to find out why the arduino hangs when server.write is called before server.begin?


  • Hero Member



Suggested Topics

58
Online

11.4k
Users

11.1k
Topics

112.6k
Posts