Thursday Apr 04, 2013

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

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...

About

Hinkmond Wong's blog on making Machine to Machine (M2M) and the Incredible Internet of Things (IoT) smarter with Java Embedded Technologies

Search

Categories
Archives
« April 2013 »
SunMonTueWedThuFriSat
 
1
2
3
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
27
28
29
30
    
       
Today