1 Reply Latest reply on Jan 5, 2015 10:44 AM by DiegoV_Intel

    Trigger when no ethernet connected

    dpc27

      Hi!

       

      So, I'm trying to inform of the current state of the ethernet connection, via LED and Serial interface.

      I'm using a timer for polling the state, and at the same time being able to do other things.

       

      It works, but I'd like not to have a poll to change the blink mode of the LED, and have a trigger instead, that is activated when the ethernet is unplugged or something like that.

      When that happens, it automatically changes from the DHCP IP given to 255.255.255.255, so I guess there must be something in the libraries to do so, but I don't find it. I'm not very good analysing them.

       

      PD: I had lot of problems to make work the timers, when it should apparently work, they didn't, and I did so many tries and changes that I don't know actually why it does work now, but I think is because I uploaded the last linux image to the SD card, and changed the code a little, making it cleaner.

       

      Regards and Happy New Year,

       

      David

        • 1. Re: Trigger when no ethernet connected
          DiegoV_Intel

          Hi dpc27,

           

          You can use the following command to know if the Ethernet cable is plugged or not:

          cat /sys/class/net/eth0/carrier
          

           

          If the Ethernet cable is unplugged you will get a 0 and if it is plugged you will get a 1.

           

          I have not tested it yet but the idea I can think is to polling the state of this flag in order to know if the cable is plugged or not. You can run a script in the background for that. If you want to run that script in the start-up I'd suggest checking this following thread, it might be interesting for you: Re: How to automatically run program on Intel Galileo startup?

           

          Regards,

          Diego.