metRo_ Posted March 14, 2017 Posted March 14, 2017 Hello all, I was reading the following topic when question myself about the advantages of write a driver for a device instead of write the SPI communication stuff on my application like vlad59 that use a python script to access the devices. Thank you
zador.blood.stained Posted March 14, 2017 Posted March 14, 2017 2 minutes ago, metRo_ said: I was reading the following topic when question myself about the advantages of write a driver for a device instead of write the SPI communication stuff on my application like vlad59 that use a python script to access the devices. It's not about creating a driver. It's about creating a configuration that would allow loading already existing kernel drivers. It doesn't matter much for simple I2C/SPI sensors, but it is required if you want to use advanced features like triggers, interrupts, automatic calculations or want to have better performance and reliability (if you want to read the sensor as many times per second as possible and don't want to rely on userspace code)
vlad59 Posted March 14, 2017 Posted March 14, 2017 I tried to talk (bitbanging) with a DS18B20 (One Wire temperature sensor) some years ago with a pretty loaded Raspberry pi : I started with Python and it worked 30% of the time, with C 50% of the time. All because of timing issues / preemptive kernel / threads ... With the kernel module, I had almost no problem. Here I saw a big win with kernel drivers. With I2C sensors I never had to tweak anything even if I used cpuburn at the same time but I may be lucky. But I agree with Zador, it heavily depends on your use case, I check the value of ambient temperature every 5 minutes so there's nothing critical here. If we talked about relays it's another story.
metRo_ Posted March 14, 2017 Author Posted March 14, 2017 Thank you both for your explanation. Do you recommend any good documentation on how to create a kennel driver for a simple temperature sensor out example?
Recommended Posts