Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 7)

$
0
0
Meh. I'm only getting 22KHz (see photo) with this last approach using java.io.FileWriter on the GPIO file handle. That's much slower than the Pi4J Java to JNI library from Savage Home Automation. And, no where close to the 5MHz using C native.

It might be better to continue to debug the NIO memory mapped buffer that I was originally thinking should be as fast as C native. I was getting "No device found" error when trying to map the /dev/mem of the Raspberry Pi. So, it might have something to do with the /dev/mem not actually looking like a file to the java.nio APIs.

I'll start adding some debug lines to my NIO code next to see if I can narrow down the issue. Meanwhile, I'll also try taking out the flush() calls and see if I can eke out a bit more speed from the java.io.FileWriter approach...

/*
 * Example Code
 */
      // Set up a GPIO port as a command channel
      FileWriter commandChannel = new 
        FileWriter("/sys/class/gpio/gpio" +
        GpioChannels[0] + "/value");
      // Loop forever with fastest on/off to GPIO pin
      while (true) {
         commandChannel.write(GPIO_ON);
         //commandChannel.flush();               

         commandChannel.write(GPIO_OFF);
         //commandChannel.flush();        
         }
       } 

More details as I figure out the NIO error message...


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>