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?
1 Answer
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 );
}