rbiks
Posts: 16
Joined: Sun Oct 07, 2012 2:47 pm
Location: central Germany

Controlling LAN LEDs individually

Fri Mar 14, 2014 10:59 am

Hi out there,

here is a small program that allows you to control the LAN status LEDs. You might simply want to switch them off if you find them too bright (this was my intention).
Your need libusb-0.1-4 and libusb-dev to compile. It does not work with libusb-1! I tested the program with raspbian but it should also work with other distributions.

Get the attachment, ungzip it and compile with

Code: Select all

make
Have fun!
Attachments
llctl.tgz
(3.05 KiB) Downloaded 1624 times
Last edited by rbiks on Sat Mar 22, 2014 12:18 am, edited 4 times in total.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 9556
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Controlling LAN9512s LEDs

Fri Mar 14, 2014 8:23 pm

for a moment I thought that you controlled over 9000 LED's!

Because of that I slightly modified the subject line. :D

rbiks
Posts: 16
Joined: Sun Oct 07, 2012 2:47 pm
Location: central Germany

Re: Controlling LAN LEDs individually

Fri Mar 21, 2014 5:37 pm

After a bit of trying I managed to control the LAN LEDs individually. Any of the three LEDs (duplex, speed and link) can now be independently switched so that it is suitable to signal events as you like.
Attachments
llctl.tgz
(3.05 KiB) Downloaded 701 times

User avatar
rpdom
Posts: 11525
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Controlling LAN LEDs individually

Fri Mar 21, 2014 5:47 pm

i tried this on my model a pi and i couldn't get any of those leds to light up. am i doing something wrong? :o

:lol:

rbiks
Posts: 16
Joined: Sun Oct 07, 2012 2:47 pm
Location: central Germany

Re: Controlling LAN LEDs individually

Fri Mar 21, 2014 7:04 pm

rpdom wrote:i tried this on my model a pi and i couldn't get any of those leds to light up. am i doing something wrong? :o

:lol:
Try harder ;-)

User avatar
joan
Posts: 12745
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Controlling LAN LEDs individually

Fri Mar 21, 2014 7:15 pm

rpdom wrote:i tried this on my model a pi and i couldn't get any of those leds to light up. am i doing something wrong? :o

:lol:
It might work if you use sudo.

User avatar
rpdom
Posts: 11525
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Controlling LAN LEDs individually

Fri Mar 21, 2014 7:51 pm

Tanks. sudo fixed it :lol:

kosh-ark
Posts: 2
Joined: Sat May 24, 2014 6:16 pm

Re: Controlling LAN LEDs individually

Sat May 24, 2014 6:20 pm

Hello,
I tried to compile but it doesn't work:

Code: Select all

pi@volumio:~$ apt-get install gcc
pi@volumio:~$ sudo apt-get install libusb-dev
pi@volumio:~$ gcc llctl.c
/tmp/cc1vXasU.o: In function `get_config':
llctl.c:(.text+0x374): undefined reference to `usb_control_msg'
/tmp/cc1vXasU.o: In function `write_config':
llctl.c:(.text+0x3f8): undefined reference to `usb_control_msg'
/tmp/cc1vXasU.o: In function `get_usb_device':
llctl.c:(.text+0x420): undefined reference to `usb_init'
llctl.c:(.text+0x424): undefined reference to `usb_find_busses'
llctl.c:(.text+0x428): undefined reference to `usb_find_devices'
llctl.c:(.text+0x4c0): undefined reference to `usb_busses'
/tmp/cc1vXasU.o: In function `main':
llctl.c:(.text+0x578): undefined reference to `usb_open'
llctl.c:(.text+0x5b8): undefined reference to `usb_close'
llctl.c:(.text+0x60c): undefined reference to `usb_open'
llctl.c:(.text+0x9c0): undefined reference to `usb_close'
collect2: ld returned 1 exit status
Could you please provide binaries or some help? thanks.

kosh-ark
Posts: 2
Joined: Sat May 24, 2014 6:16 pm

Re: Controlling LAN LEDs individually

Sat May 24, 2014 9:01 pm

My fault, I didn't notice the Makefile.
Compiled now.

henryk
Posts: 1
Joined: Fri Jun 27, 2014 8:07 pm

Re: Controlling LAN LEDs individually

Fri Jun 27, 2014 8:12 pm

FYI: There *is* a datasheet that covers this topic. It's just called "Databook for Software Development" and hence not easy to find when looking for a datasheet: http://www.microchip.com/SWLibraryWeb/p ... AN95xx-DAT. LED-GPIO configuration is found in section 4.3.9 on page 160.

rbiks
Posts: 16
Joined: Sun Oct 07, 2012 2:47 pm
Location: central Germany

Re: Controlling LAN LEDs individually

Sat Jun 28, 2014 2:42 pm

henryk wrote:FYI: There *is* a datasheet that covers this topic. It's just called "Databook for Software Development" and hence not easy to find when looking for a datasheet: http://www.microchip.com/SWLibraryWeb/p ... AN95xx-DAT. LED-GPIO configuration is found in section 4.3.9 on page 160.
Thank you Henryk,

this looks very interesting. Expecially the sections about power saving.

rbiks

bejkarna
Posts: 1
Joined: Thu Sep 24, 2015 10:51 am

Re: Controlling LAN LEDs individually

Thu Sep 24, 2015 10:57 am

I had some problems compiling using Makefile. I got errors like:

llctl.c:(.text+0x220): undefined reference to `usb_control_msg'

I solved this by putting CCFLAGS after SRC in Makefile as follows:

CC = gcc
CCFLAGS = -lusb
SRC = llctl.c
TRG = llctl

all:
$(CC) $(SRC) $(CCFLAGS) -o $(TRG)
strip $(TRG)

coding
Posts: 39
Joined: Sun Jul 20, 2014 7:23 am

Re: Controlling LAN LEDs individually

Sun Oct 18, 2015 6:08 pm

Hello,

I would like to disable the LAN LEDs of my Raspberry Pi 2.
I noticed this thread is old and it was created when the Raspberry Pi 2 did not yet exist.
Is this the only method to disable the LAN LEDs or is there a simpler method especially for the Raspberry Pi 2?

User avatar
DougieLawson
Posts: 29760
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Controlling LAN LEDs individually

Sun Oct 18, 2015 7:06 pm

coding wrote:Hello,

I would like to disable the LAN LEDs of my Raspberry Pi 2.
I noticed this thread is old and it was created when the Raspberry Pi 2 did not yet exist.
Is this the only method to disable the LAN LEDs or is there a simpler method especially for the Raspberry Pi 2?
I'm not sure the LAN LEDs are connected to a GPIO on the RPi2 (or a B+), they appear to be part of the ethernet hardware.

I'd guess the machine to test this stuff on is my B+, since the old A/B version of the program should run on there without needing any changes.

Edit: I tried this on my B+ and it has precisely zero effect on the ethernet LEDs.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

The_Unknown
Posts: 2
Joined: Tue Nov 03, 2015 8:02 pm

Re: Controlling LAN LEDs individually

Tue Nov 03, 2015 8:05 pm

I just used the script on my Pi 2. Works like a charm. Only one thing is still annoying: When restarting the device, the configuration gets lost :( I tried to add it to the super user level /etc/rc.local file but not success. The file is read but my commands (which of course in this case don't use the sudo command) aren't executed.

Adding to the user's .profile file (user osmc) won't work either since it's required to run it as super user.

What can I do :(?

User avatar
dasmanul
Posts: 501
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Controlling LAN LEDs individually

Fri Nov 06, 2015 11:31 am

I can confirm that this works flawlessly on a Pi 2. Thanks very much, rbiks! I'm using my Pi 2 as a music player in the bedroom and the LEDs were somewhat annoying.

I also had no trouble adding it to /etc/rc.local (on Raspbian Jessie), Ethernet LEDs turn off immediately after reboot.
The_Unknown wrote:I tried to add it to the super user level /etc/rc.local file but not success. The file is read but my commands (which of course in this case don't use the sudo command) aren't executed.
That's strange. As I wrote, this works flawlessly for me. What version of which OS are you running? What exactly did you put into /etc/rc.local? Did you give the full path for the llctl binary? Here's what it looks like on my system:

Code: Select all

reiter@nacht:~$ grep llctl /etc/rc.local 
/usr/local/bin/llctl f0 l0 d0

coding
Posts: 39
Joined: Sun Jul 20, 2014 7:23 am

Re: Controlling LAN LEDs individually

Fri Nov 06, 2015 12:35 pm

Can someone who is a programmer and has a good reputation on this forum please confirm that the source code is safe to use? I don't understand the source code, so I wouldn't know what I compile and how it could affect my Pi's security. But if it works and is safe, I think it should become more known to the community.

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Controlling LAN LEDs individually

Fri Nov 06, 2015 1:19 pm

Source is safe on security point of view.
It is simple little program, which does not open any doors nor include viruses.

I also tested that it works and indeed needs root privileges.

You just compile it:
make

It needs this:
sudo apt-get install libusb-dev

coding
Posts: 39
Joined: Sun Jul 20, 2014 7:23 am

Re: Controlling LAN LEDs individually

Fri Nov 06, 2015 7:05 pm

Wow, I just tried this program too, it works for the Pi 2 and is fantastic. It's a must have for bedroom Pis. This thread is heavily underrated, the attachment should have thousands of downloads. The Raspberry Pi foundation should include such functionality in their raspi-config setup program.

Many thanks @rbiks for a great program!

The_Unknown
Posts: 2
Joined: Tue Nov 03, 2015 8:02 pm

Re: Controlling LAN LEDs individually

Sat Nov 07, 2015 5:44 pm

dasmanul wrote:I can confirm that this works flawlessly on a Pi 2. Thanks very much, rbiks! I'm using my Pi 2 as a music player in the bedroom and the LEDs were somewhat annoying.

I also had no trouble adding it to /etc/rc.local (on Raspbian Jessie), Ethernet LEDs turn off immediately after reboot.
The_Unknown wrote:I tried to add it to the super user level /etc/rc.local file but not success. The file is read but my commands (which of course in this case don't use the sudo command) aren't executed.
That's strange. As I wrote, this works flawlessly for me. What version of which OS are you running? What exactly did you put into /etc/rc.local? Did you give the full path for the llctl binary? Here's what it looks like on my system:

Code: Select all

reiter@nacht:~$ grep llctl /etc/rc.local 
/usr/local/bin/llctl f0 l0 d0
At first I had the file in the osmc-user's dir. After your post, I tried to do exactly the same as you did, but no success. The lights are on :(

wiredman
Posts: 1
Joined: Mon Dec 21, 2015 9:51 am

Re: Controlling LAN LEDs individually

Mon Dec 21, 2015 9:55 am

okay so the right way to do it is to edit "/etc/network/interfaces"
under the "iface eth0" line, add post-up /path/llctl f0 l0 d0.
the network driver changes leds later on; this makes it so every time it changes, you reset the leds.

coding
Posts: 39
Joined: Sun Jul 20, 2014 7:23 am

Re: Controlling LAN LEDs individually

Sun Apr 24, 2016 2:59 pm

Do you know how to install libusb-0.1-4 in Arch Linux? Because there is only libusb 1. Libusb's homepage does not list the release 0.1.

Any way to rewrite the code to work with libusb-1?

Edit: this is a solution:

Code: Select all

pacman -S libusb-compat
It's version 0.1.5-1 and works. Could compile and execute.

mcduman
Posts: 11
Joined: Mon Mar 14, 2016 3:24 am

Re: Controlling LAN LEDs individually

Sat Mar 25, 2017 1:09 pm

anybody tried this with the rpi3? I cannot get it to work.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5099
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Controlling LAN LEDs individually

Sat Mar 25, 2017 2:34 pm

mcduman wrote:anybody tried this with the rpi3? I cannot get it to work.
Yes, works for me on Pi3.
I ran:

Code: Select all

tar xf llctl.tgz 
make
sudo ./llctl f0 l0 d0
and the LEDs went off.

mcduman
Posts: 11
Joined: Mon Mar 14, 2016 3:24 am

Re: Controlling LAN LEDs individually

Sun Mar 26, 2017 11:57 am

Yep it works. I saw a new commit at github though dated February 2017 (https://github.com/dradermacher/lan951x-led-ctl) downloaded and compiled it but could not get it to work

Return to “General discussion”

Who is online

Users browsing this forum: ahmedawad, Joe Chip, lisawelch and 42 guests