2
\$\begingroup\$

Is it possible to set some of four available user leds to show serial port activity, like we can set it to show mmc activity?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Based on Ubuntu linux on BBB, but other Linux will work similarly.

The user LED mode can be accessed using the following command:

echo none | sudo tee /sys/class/leds/beaglebone\:green\:usr3/trigger > /dev/null

Where none can be replaced with one of the following:

none nand-disk mmc0 mmc1 timer oneshot heartbeat backlight gpio cpu0 default-on transient

I am unaware of any option to "connect" a user LED to a serial port. The only option I see is "manually" writing 0 or 1 to one of the brightness files upon receiving data in your program.

Optionally work around running as root by issuing a sudo chown ubuntu:ubuntu /sys/class/leds/beaglebone\:green\:usr3/brightness once.

In Perl you can blink the LED as follows:

my $ledState = 0;
while( 1 ) {
  $ledState ^= 1;   # toggle state
  open( LED , ">" , "/sys/class/leds/beaglebone\:green\:usr3/brightness" ) or die "Cannot open file for LED control: $!\n";;
  print LED $ledState;
  close( LED );
  sleep( 1 );
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.