lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

question regarding /sys/bus

Fri May 30, 2014 12:10 am

# If your modules are set according to my article in PiMag and you have setup your probe as per Adafruit
# you should just have to change the serial number to yours

Code: Select all

tfile = open("/sys/bus/w1/devices/28-0000053cfcb7/w1_slave")
text = tfile.read()
tfile.close()
1)How does this /sys/bus/w1/device/..../w1_slave got created?
2)when would a device register under /sys/bus/...?
3)when someone open this device file, what's it actually do?
4)can you write something there to? and from the device standpoint , what does writing to file mean?

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

Re: question regarding /sys/bus

Fri May 30, 2014 5:25 am

lilzz wrote:1)How does this /sys/bus/w1/device/..../w1_slave got created?
It gets created when the driver (module) detects the device.
2)when would a device register under /sys/bus/...?
See above.
3)when someone open this device file, what's it actually do?
That depends on the device. It isn't really a file. It's an interface to the driver that corresponds to that device.
4)can you write something there to? and from the device standpoint , what does writing to file mean?
That also depends on the device. Look at the permissions on the file and see if it is writeable. If it is then you may be able to send commands to the device via the file (interface) if it accepts commands.

lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

Re: question regarding /sys/bus

Fri May 30, 2014 6:55 am

thank you.

Return to “General discussion”