WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Command line LED control?  (Read 7561 times)

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #15 on: December 26, 2011, 10:02:24 PM »
just tried that -- no change.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11515
Re: Command line LED control?
« Reply #16 on: December 26, 2011, 10:24:59 PM »
Hi mb
This would be a lot easier if I could reproduce the symptoms at my end.
After running ./ledcontrol do any new messages show up in dmesg?
Although it should not be necessary, does  sudo ./ledcontrol  make any difference?
If those two steps don't produce any answers, try the following:
Open the file  ledcontrol.c
Change:
if((fd=open("/dev/tty", O_NOCTTY)) < 0)
to:
if((fd=open("/dev/console", O_NOCTTY)) < 0)
Save the file and run  ./compileledcontrol  again
You will need sudo after this change.
sudo ./ledcontrol
« Last Edit: December 26, 2011, 10:47:17 PM by Rich »

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #17 on: December 27, 2011, 09:21:20 AM »
Thanks, changing to /dev/console worked!

now for the cleanup.. i just delete xorg-75-bin and remove it from onboot.lst right? and if i just remove mpc.tcz and compiletc from onboot.lst then none of their dependancies will load, right?.. (is there a quick way to check/remove all unused dependancies??)

((Shame about no num lock. Theres also an 'email alert' led that would have been nice to use.))

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11515
Re: Command line LED control?
« Reply #18 on: December 27, 2011, 09:36:44 AM »
Hi mb
Quote
Thanks, changing to /dev/console worked!
Thanks for bearing with me in sorting this out. Removing the unwanted applications from  onboot.lst
will prevent them from loading.
Quote
(is there a quick way to check/remove all unused dependancies??)
I'm afraid I don't know how to do that in Microcore.
Quote
Although I don't know why, I see now what's happening. The keys that are used to emulate a numeric
keypad on the laptop are behaving like a numeric keypad with NumLock turned off. The J behaves
like a left arrow, 8 behaves like an up arrow, etc. When I have the program turn the LED off, the keys
go back to their normal functions.
Does your keyboard behave the same way?

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #19 on: December 27, 2011, 10:30:09 AM »
I had to connect a display which is why i didn't answer that before. my behavior is similar.. but a little different.

ledcontrol N/n does effectively nothing on its own. HOWEVER, while i press the Fn key after running 'ledcontrol N', then both the LED comes on, and the relevant area works like a num pad. Release Fn key and it is back to normal. I'd love a fix if you are able.

What i'd really like to do is have one of them act as a wifi status LED. Could you suggest something here?? ..all i can think of is running ping on a script every few seconds, which seems a pretty awful solution.

And thank you :)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11515
Re: Command line LED control?
« Reply #20 on: December 27, 2011, 02:46:32 PM »
Hi mb
Try running this periodically in a script (replace eth0 with your adapter):
Code: [Select]
cat /sys/class/net/eth0/operstateThis will return  up, down, or unknown  for link status. Turn the LED on for up and off for down. If it
comes back as unknown, use the Toggle function for that LED and it will blink at the same rate that
the script is called.
Quote
I'd love a fix if you are able.
If I knew how and why the NumLock on a laptop behaved differently, I'd try to fix it.


Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #21 on: December 27, 2011, 06:39:29 PM »
Ok i've had a go but i'm a bit of a noob with shell scripting and it's not working right...
Code: [Select]
#!/bin/sh
cat /sys/class/net/eth1/operstate | while read line
do
        if [ $line == "up" ]; then
           sudo /opt/ledcontrol S
        else
           sudo /opt/ledcontrol s
        fi
        sleep 2
done
i ran this by adding '/opt/script.sh &' at the end of the dhcp.sh

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Command line LED control?
« Reply #22 on: December 27, 2011, 06:45:05 PM »
#!/bin/sh
while read line
do
        if [ $line == "up" ]; then
           sudo /opt/ledcontrol S
        else
           sudo /opt/ledcontrol s
        fi
        sleep 2
done < /sys/class/net/eth1/operstate

Please get a book.  This is not Linux 101.

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #23 on: December 27, 2011, 07:00:09 PM »
well, it still doesn't work. I got pretty close, and its not like i opened a new thread about it either.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Command line LED control?
« Reply #24 on: December 27, 2011, 07:09:24 PM »
Then try:
#!/bin/sh
while true
do
        read line < /sys/class/net/eth1/operstate
        if [ $line == "up" ]; then
           sudo /opt/ledcontrol S
        else
           sudo /opt/ledcontrol s
        fi
        sleep 2
done

Offline mb

  • Jr. Member
  • **
  • Posts: 69
Re: Command line LED control?
« Reply #25 on: December 27, 2011, 07:49:49 PM »
Thank you, this works.