sysfs attributes Reference

Kumar Abhishek edited this page Oct 4, 2015 · 6 revisions

Let's take a look at the sysfs attributes that BeagleLogic module exports.

root@beaglebone:~# ls /sys/devices/virtual/misc/beaglelogic/ -l
total 0
-r--r--r-- 1 root root 4096 Jun  6 03:16 buffers
-r--r--r-- 1 root root 4096 Jun  6 03:16 dev
--w------- 1 root root 4096 Jun  6 03:16 filltestpattern
-r--r--r-- 1 root root 4096 Jun  6 03:16 lasterror
-rw-r--r-- 1 root root 4096 Jun  5 23:22 memalloc
drwxr-xr-x 2 root root    0 Jun  6 03:16 power
-rw-r--r-- 1 root root 4096 Jun  6 03:16 samplerate
-rw-r--r-- 1 root root 4096 Jun  6 03:16 sampleunit
-rw-r--r-- 1 root root 4096 Jun  6 03:16 state
lrwxrwxrwx 1 root root    0 Jun  5 23:21 subsystem -> ../../../../class/misc
-rw-r--r-- 1 root root 4096 Jun  6 03:16 triggerflags
-rw-r--r-- 1 root root 4096 Jun  5 23:21 uevent
root@beaglebone:~# 

buffers [readonly]

Gives the physical addresses of the allocated buffers along with their sizes

root@beaglebone:~# cat  /sys/devices/virtual/misc/beaglelogic/buffers 
99800000,4194304
99c00000,4194304
99000000,4194304
99400000,4194304

memalloc [rw]

Reading this attribute returns the current size of the sampling buffer. Writing to this attributes sets aside that memory size rounded up to the nearest 4 MB unit, subject to a minimum of 8 MB. Upto 320 MB has been personally tested by the developer.

samplerate [rw]

Gets or sets Samplerate in Hz. Legal values are between 1 to 100000000.
(as of now, the kernel module will wait until a complete 4 MB buffer is filled up, hence it is recommended to keep the sample rate reasonably high to reduce the waiting time)

sampleunit [rw]

Note: Due to a bug in the way this attribute displays its value, it displays "16bit,norle" when it should actually be "8bit,norle" and vice versa. Please read it the opposite way until it is fixed in the next release.

At module startup, BeagleLogic is configured to 8-bit mode by default.

Write '1' to it for 8 bit samples ; Write '0' to it for 16 bit samples. Please disregard the displayed values of this attribute and configure accordingly for your usage.

triggerflags [rw]

0 = One-shot sampling [PRU halts after the buffer has been filled once]
1 = Continuous sampling [Buffers are filled in a continous manned until sampling is aborted] If data is not removed fast enough as it arrived, it may be overwritten. Kernel logs can reveal where the overrun had occurred.


Under the hood.
For testing purposes only.

state [rw]

For use with mmap interface only, not to be mixed with read() operation [which auto-triggers the sampling]
Writing a 1 to it triggers sampling. Writing a 0 aborts a currently running sampling operation.
While BeagleLogic is running a sampling operation, this blccks and returns the sequence number of the last buffer written.

lasterror [readonly]

Reading this attribute blocks until the current sampling operation is in progress. It returns 0 if no buffer overrun had occurred during transfer; kernel logs are to be inspected if this is non-zero.

filltestpattern [writeonly]

Writing 12345678 into this causes the buffer memory to be filled up with increasing 32-bit integers. Used for checking buffer integrity and testing purposes only