-
Notifications
You must be signed in to change notification settings - Fork 67
Implement new FFM API approach< 8000 /bdi> #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@DigitalSmile Please add implementation of 1Wire support also. p.s. Is it possible 8000 for you to add support of 1Wire in your gpio library? |
I didn't really work with 1-wire devices. Isn't it the protocol that can work above simple GPIO Pin? |
About 1Wire support: there is work in progress by @dariuszzbyrad |
Additionally the FFM-API approach isn't required, as one can directly read the kernel's relevant sys files. E.g. reading a temperature device: String devicePath = "/sys/bus/w1/devices/28-0316a2791cff/w1_slave";
try (BufferedReader br = new BufferedReader(new FileReader(devicePath))) {
String line1 = br.readLine(); // e.g. "00 00 00 00 00 ... : crc=00 YES"
String line2 = br.readLine(); // e.g. "00 00 00 00 00 t=12345"
// Typically you look for "t=NNNNN" to get the temperature
// Here, parse the integer after "t="
String tempStr = line2.split("t=")[1];
double tempC = Double.parseDouble(tempStr) / 1000.0;
System.out.println("Temperature: " + tempC + "°C");
} catch (IOException e) {
e.printStackTrace();
} This is what @dariuszzbyrad has implemented. |
Thanks @eitch , I added this info to a new web page: https://www.pi4j.com/documentation/io-examples/1-wire/ |
Hello guys! |
That calls for a new page in https://www.pi4j.com/featured-projects/! ;-) |
@AlexR1973 from what i can see, there is no other way to read 1-wire devices in the kernel. At least nothing that i can find. if it takes 4-10 seconds, then perhaps its an implementation detail? Do you have any example code? |
@eitch , I have found the next article about working with DS18B20 over 1-wire interface. Please take a look at it - maybe it reveals the details how to get data directly. It is in Russian, but Chrome/MS Edge will translate it to English easily. |
@eitch ,
|
I spent 8 hours yesterday to add support of 1-wire to Orange Pi Zero 3 and Raspi OS. If you interested, I had to do next: Create file sun50i-h616-w1-gpio.dts and put inside: Add to /boot/orangepiEnv.txt: edit /etc/modules-load.d/modules.conf. Add 2 lines: Execute after editing config files: |
@DigitalSmile , BTW could you open a discussion section in your "gpio" project? I have a question about your library and I2C protocol, but don't know how to contact you. I have very simple code trying to get pressure from BMP180. Want to get pressure data from the sensor. My code: _ But all the time I got the next exception: Next code works fine - my relay turns ON and OFF perfectly. Thanks a lot in advance! |
You can simply create an issue in gpio repo, let's discuss it separately. |
Goal: create a plugin, that can talk to hardware using FFM API. It was introduced in JDK22 and is going to replace old JNI in future releases of JDK. For now it is marked for restricted use since next JDK25.
Todo list:
Provider
interfaces (gpio, i2c, spi, pwm)The text was updated successfully, but these errors were encountered: