Friday Oct 11, 2013

Halloween: Season for Internet of Spooky Things (IoST) and Java Embedded (Part 1)

It's Halloween time! And, you know what that means. Ghost stories... WooooOOOoooo... Not many people know this, but the Oracle office in Santa Clara, Calif. (formerly the Sun Microsystems, Santa Clara campus) where I happen to work, was built on the same site as the Agnews Insane Asylum which was orginally built in 1885.

Unfortunately, in 1906 the original Agnews Asylum suffered a fire during the San Francisco earthquake and became the site of Santa Clara Valley's "greatest loss of life" resulting from the quake. 117 patients and staff were killed and buried in mass graves on the site (same place as where I work now). The main building (seen in the photo) and some others were irreparably damaged. Ever since then, there have been strange reports of workers witnessing apparitions, hearing strange laughter and screaming, sensing cold spots and seeing freezer doors fly open violently and eject their contents (which is pretty darn scary, if you ever saw what's been left and forgotten in our breakroom refrigerators over time by co-workers).

Quite frankly, late some evenings, after a long day at work, I've smelled something strange burning in the air. Usually, it's someone who microwaved their popcorn too long in the breakroom. But, it could be ghosts...

See:

Agnews Insane Asylum

Here's a quote:

 Following this disaster, Agnews was 
 reconstructed in the so-called 
 Mediterranean Revival style, 
 resembling a college campus of 
 two-story buildings; it re-opened 
 circa 1911 as Agnews State Mental 
 Hospital.

That second mental hospital mentioned in the above quote lasted until Sun Microsystems demolished it and built an office complex on top of that, then Oracle acquired Sun Microsystems including the Santa Clara campus and here we are today.

So, what better way to celebrate Halloween than by building an Internet of Spooky Things (IoST) ghost sensor connected to a Raspberry Pi running Java Embedded to track ghosts in our office building. I'm going to show you how you can build this too for your Raspberry Pi then run a Java Embedded app to collect ghost analytics.

We'll see how many ghosts we can detect with our IoST gateway device here at the Oracle Santa Clara campus office by placing my embedded device and sensor in different locations throughout our office building in the next few weeks... WoooOOOooooo... Stay tuned...

See the series of posts for the steps to this cool demo:
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 1)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

Saturday Oct 05, 2013

Silicon Valley Code Camp Presentation on Raspberry Pi and Java SE Embedded

I gave a technical session presentation as part of the Silicon Valley Code Camp (SVCC) this morning at Foothill College on "How to Develop on the Raspberry Pi with Java SE Embedded". If you were one of the 50+ developers attending my session, thanks for sitting in! Hopefully, I was able to give some good information on how to use Java SE Embedded to program a Linux/ARM development device, like the Raspberry Pi. If you want a copy of my slides, make sure to click on the SVCC link and look for the purple "Session Materials" link to the PDF of the slides.

See:

SVCC: How to Develop RPi

I saw Arun Gupta and Doris Chen there today, too. Nice to see developers presenting technical sessions to other local developers, especially where Java SE Embedded is concerned. Good luck to Stephen Chin tomorrow on his Raspberry Pi Gaming for Kids hands-on lab! That's sounds like fun too.

Tuesday Oct 01, 2013

Even Quicker Guide to Install Java Embedded on a Raspberry Pi

Here's an even Quicker Guide to install Java Embedded on a Raspberry Pi:
 sudo apt-get update && \
   sudo apt-get install oracle-java7-jdk

That's it! It's fast, simple, and easy to remember... It's easy to remember if you find that everything you do after the "sudo" is easy to remember, that is... :-)

See:

Even Quicker RPi Java Embedded

Here's a quote:

 All future Raspbian images will ship 
 with Oracle Java by default; existing 
 users can install it by typing:

 sudo apt-get update && sudo \
   apt-get install oracle-java7-jdk

 We’d like to thank our friends at 
 Oracle for their hard work in making 
 this possible.
You are most welcome! Raspberry Pi and Oracle Java rule!

Monday Sep 30, 2013

JavaOne 2013 Java Embedded Recap (Part 1)

Phew! What a great JavaOne 2013 conference! It was fun presenting and staffing our Java SE Embedded booth this year. I'll be posting some updates of this year's Java Embedded technical highlights. Let's start off with a Oracle OpenWorld 2013 keynote address by Ed Screven and Chris Baker about the "Internet of Things" (thanks to Darryl M. for sending out the link).
If you go to timestamp 10:00, you'll see Henrik Stahl, our Senior Director of Product Management at Oracle, talk about the role of Java Embedded in the Internet of Things.

See:

Oracle OpenWorld 2013 keynote: IoT

Java Embedded and Internet of Things. It's a good match!

Friday Sep 06, 2013

Raspberry Pi playing Cups Pitch Perfect with Java SE Embedded Programming

Here's my Raspberry Pi playing Cups Pitch Perfect with Java SE Embedded Programming. Actually, it's just bumping into a cup.

See:

RPi Playing Cups

And, that's really Sam Tsui, Alex G, Kina Grannis, and Kurt Schneider singing. In case you couldn't figure that out...

Friday Aug 30, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 7)

And, as promised, here's the Java SE Embedded source code used on the Raspberry Pi to drive the Skynet Big Data demo using the Hexbug Spider Robot.

This part of the demo is actually just a first level diagnostic test to run the robot through the four controls: left, right, forward, and back, then loop forever to ensure we have all the connections fully functional.

/*
 * Java Embedded Raspberry Pi Robot app
 */
package jerpirobot;

import java.io.FileWriter;
import java.io.File;
import java.io.IOException;

/**
 *
 * @author hinkmond
 */
public class JerpiRobot {
    
    static final String GPIO_OUT = "out";
    static final String GPIO_ON = "1";
    static final String GPIO_OFF = "0";
    
    static String[] GpioChannels = 
    { "0", "1", "4", "17", "21", "22", "10", "9" };
       
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        FileWriter[] commandChannels;
        
        try {
            
            /*** Initialize GPIO ports for output ***/
            
            // Open file handles to GPIO port unexport and export controls
            FileWriter unexportFile = 
                    new FileWriter("/sys/class/gpio/unexport");
            FileWriter exportFile = 
                    new FileWriter("/sys/class/gpio/export");

            for (String gpioChannel : GpioChannels) {
                System.out.println(gpioChannel);
    
                // Reset the port
                File exportFileCheck = new File("/sys/class/gpio/gpio" +
                        gpioChannel);
                if (exportFileCheck.exists()) {
                    unexportFile.write(gpioChannel);
                    unexportFile.flush();
                }
            
                // Set the port for use
                exportFile.write(gpioChannel);   
                exportFile.flush();

                // Open file handle to port input/output control
                FileWriter directionFile =
                    new FileWriter("/sys/class/gpio/gpio" + gpioChannel + 
                        "/direction");
            
                // Set port for output
                directionFile.write(GPIO_OUT);
                directionFile.flush();
            }
            
            /*** Send commands to GPIO ports ***/
            
            commandChannels = new FileWriter[GpioChannels.length];    
            for (int channum=0; channum < GpioChannels.length; channum++) {
                // Open file handle to issue commands to GPIO port
                commandChannels[channum] = 
                        new FileWriter("/sys/class/gpio/gpio" +
                        GpioChannels[channum] + "/value");
            }
            
            int channum;
            
            // Loop forever
            while (true) {
                
                // First Level Diagnostics: Send signal to each direction:
                //   Left, Right, Forward, and Back
                for (channum=4; channum < 8; channum++) {
                    commandChannels[channum].write(GPIO_ON);
                    commandChannels[channum].flush();
                
                    // Wait for a while
                    java.lang.Thread.sleep(1000);
                
                    // Set GPIO port OFF
                    commandChannels[channum].write(GPIO_OFF);
                    commandChannels[channum].flush();
                    
                    // Wait for a while
                    java.lang.Thread.sleep(1000);
                }
            }
        } catch (IOException | InterruptedException exception) {
            exception.printStackTrace();
        }
    }
}

And if you want to see the whole series of steps that put the whole demo together, just refer to these links:

See the previous posts for the full series on the steps to this cool demo:
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 1)
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 2)
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 3)
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 4)
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 5)
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 6)
Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 7)

Tuesday Aug 27, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 6)

Here's my Hexbug Spider Robot going through his first diagnostics. Awwww.... his first steps. Woogie-woogie.

See:

Skynet Model T-1 First Steps

Soon, little Hexbug Spider Robot will use Skynet Big Data to hunt for Sarah Connor.

Java SE Embedded programming enables this robot to run through his new basic level one diagnostics. I'll post the Java source code in the next blog post. It's all pretty straight-forward if you've been following my posts so far. The hard part will be mounting the laser turret and radar targeting system. :-)

Friday Aug 23, 2013

Qualcomm's Uplinq Mobile CodeFest & Hackathon: 03-05Sep2013 San Diego, Calif

Qualcomm is hosting a a Mobile CodeFest and Hackathon in sunny Sandy Eggo, California on Sept. 3-5, 2013. If you're into mobile app development or like winning prizes, make sure to register to attend.

See:

Uplinq Mobile CodeFest & Hackathon

Here's a quote:

 If you're a mobile app developer, the 
 Uplinq Mobile CodeFest & Hackathon are 
 for you. Seeking education? Spend the 
 day attending CodeFest sessions to 
 get tips & tricks from the experts...
Fun! The best overall app wins $10,000 plus 5 tickets to the San Diego Padres vs. San Francisco Giants game on Wed., Sept. 4. That should actually be the "World Champion" San Francisco Giants. Go Giants! (And, sign up today for the Mobile CodeFest & Hackathon)

Friday Aug 02, 2013

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

Well, as I mentioned to Robert Savage recently, I know how to get to the same speed in Java SE Embedded as the Pi4J Java to JNI library from Savage Home Automation and more importantly to also achieve the same 5MHz max frequency on a GPIO pin as using C native. But knowing how is not exactly the same as implementing, is it? :-) So, I'll show how instead, since showing is the same as implementing, right? ;-) Well, it should be the same. B-)

The approach in theory could use NIO memory mapped buffer that I was originally thinking should be as fast as C native. But in practice anyone that has tried this has gotten a bug where it says "No device found" error when trying to map the /dev/mem of the Raspberry Pi. That's what @Geomancer86 also noticed also, as he mentioned on twitter.

So, what's the deal? It seems Java SE Embedded NIO does one type of file open and mmap down in the native layer underneath java.nio.ByteBuffer that does not allow for opening native memory devices (only real files on the Linux system). But, we need to access /dev/mem from Java on the Raspberry Pi to access the GPIO pins in memory to flip the bits as fast as possible to reach the maximum possible frequency in doing so.

There something we can learn by looking at Gordon Henderson's WiringPi C native code. That is there's a different way of doing the native file open and mmap that's needed, and we know he's doing it the right way since WiringPi can get that 5MHz on the GPIO pins that we want.

See: https://github.com/WiringPi/WiringPi/blob/master/wiringPi/wiringPi.c
Scroll down to line 1319

// Open the master /dev/memory device

  if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0)
  {
    if (wiringPiDebug)
    {
      int serr = errno ;
fprintf (stderr, "wiringPiSetup: Unable to open /dev/mem: %s\n", 
  strerror (errno)) ;
      errno = serr ;
    }
    return -1 ;
  }

// GPIO:

  gpio = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, 
    MAP_SHARED, fd, GPIO_BASE) ;
  if ((int32_t)gpio == -1)
  {
    if (wiringPiDebug)
    {
      int serr = errno ;
fprintf (stderr, "wiringPiSetup: mmap failed: %s\n", 
  strerror (errno)) ;
      errno = serr ;
    }
    return -1 ;
  }

Instead of what NIO does currently, we need to instead do the same as above and then hand back a Java ByteBuffer that is pointing to that GPIO Base mapped in memory. Then we can use java.nio.ByteBuffer to twiddle bits representing the GPIO pins and turn them on/off as fast as possible, which in theory gives us that max 5MHz.

If anyone wants to try this, try extracting just that WiringPi native C code from Gordon Henderson's library (above) and make your own JNI call to it from Java SE Embedded to mimic what NIO does. Then make another JNI call to do a write to the memory just like Gordon does to turn the pin on/off as fast as possible. That in theory should give the max 5MHz that C native can do and have it be accessible from the Java SE Embedded side.

So, that's me showing how it could be done, it's up to someone out there to see if that theory holds up. Any takers? Showing is just like implementing, right? :-)

Wednesday Jul 03, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 5)

Now, here is the connection diagram to connect the wires you have soldered onto your Hexbot Spider remote control, first to a breadboard with four 2N4401 transistors, four 10K ohm resistors, and then to the Raspberry Pi GPIO pins. You can see we are using a breadboard as a staging area for each of the connections that eventually run back to the Raspberry Pi. And, the transistors will act as switches for turning on and off the remote controller buttons from a Java SE Embedded app.

If you need to refresh your memory, below is the Raspberry Pi GPIO pinout diagram.

See:

RPi GPIO Pinout

So, with these two diagrams you should be able to connect your Hexbot Spider remote to the Raspberry Pi. Next up, we will look at how to program the Java SE Embedded app that is needed to run the remote control to make the Hexbot Spider robot move. Fun! :-)

Friday Jun 28, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 4)

Here's the first sign of life of a Hexbug Spider Robot converted to become a Skynet Big Data model T-1. Yes, this is T-1 the precursor to the Cyberdyne Systems T-101 (and you know where that will lead to...) :-) It is demonstrating a heartbeat using a simple Java SE Embedded program to drive it.

See:

Skynet Model T-1 Heartbeat

It's alive!!! Well, almost alive. At least there's a pulse. We'll program more to its actions next, and then finally connect it to Skynet Big Data to do more advanced stuff, like hunt for Sarah Connor.

Java SE Embedded programming makes it simple to create the first model in the long line of T-XXX robots to take on the world. Raspberry Pi makes connecting it all together on one simple device, easy. Next post, I'll show how the wires are connected to drive the T-1 robot.

Monday Jun 24, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 3)

In Part 2, I described what connections you need to make for this demo using a Hexbug Spider Robot, a Raspberry Pi, and Java SE Embedded for programming. Here are some photos of me doing the soldering. Software engineers should not be afraid of a little soldering work. It's all good.

See:

Skynet Big Data Demo (Part 2)

One thing to watch out for when you open the remote is that there may be some glue covering the contact points. Make sure to use an X-Acto knife or small screwdriver to scrape away any glue or non-conductive material covering each place where you need to solder.

And after you are done with your soldering and you gave the solder enough time to cool, make sure all your connections are marked so that you know which wire goes where. Give each wire a very light tug to make sure it is soldered correctly and is making good contact.

There are lots of videos on the Web to help you if this is your first time soldering. Check out Laday Ada's (from adafruit.com) links on how to solder if you need some additional help: http://www.ladyada.net/learn/soldering/thm.html

If everything looks good, zip everything back up and meet back here for how to connect these wires to your Raspberry Pi. That will be it for the hardware part of this project. See, that wasn't so bad. ;-)

Tuesday Jun 18, 2013

Java "License to Code" YouTube Video

Here's a promotional video for the Java EE 7 launch. I'm pretty sure that's supposed to be a Tom Cruise-like character who frees all the Java Developers from the warehouse. And why are all the Java Developers in a warehouse to begin with? Did they do something wrong? Did they forget to buy bulk products at a reasonable price? Maybe Sharat knows? Looks like that's him in the middle of the group.

See:

Java: License to Code

Helicopters, the San Francisco Bay Bridge, BART trains... fresh fruit stands... It's all very frightening. But, in the end, Java Developers rise up and take back Java. All is saved! :-) Thank goodness! Phew! :-P

Monday Jun 17, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 2)

"Get ready for a major remodel fellas. We're back in hardware mode." -- Tony Stark.

Before we can use Java SE Embedded with our Skynet Big Data enabled Hexbug Spider robot, we need a little hardware hacking. Don't be afraid, just a little soldering.

Find the Hexbug Spider remote (little blue box pictured in the top of the photo). Carefully, use a small flat screwdriver and pry apart the four plastic tabs (two on each side). The top of the transmitter comes right off. Then flip it over and find the test points in the photo where we will solder wires onto.

See:

There are 7 contact points:

 1: GND
 2: fwd: Forward
 3: +3.3v (power)
 4: bkwd: Backward
 5: left: Left
 6: channel: A/B select
 7: right: Right
Solder 7 5-inch pieces of wire (each marked differently or having a different color to identify them) on to each of the 7 contact points and run the 7 wires out of the channel hole of the case and snap it back together. Next, we'll connect those 7 wires to the Raspberry Pi so that our Java SE Embedded app can control the remote. Exciting already, eh? ;-)

Tuesday Jun 11, 2013

Skynet Big Data Demo Using Hexbug Spider Robot, Raspberry Pi, and Java SE Embedded (Part 1)

I'm still plugging away at RPi Oscilloscope benchmarking GPIO using Java Embedded in my spare time (stuck on getting NIO to work), but for now I need a break, so I'll go back to another cool use of GPIO using Java SE Embedded and a Raspberry Pi. Here are all the parts I just got for about $30.

I bought everything from RadioShack (except for the RPi), so you can do the same at home.

See:

Here is the list of parts:

 1: *Hexbug Spider Robot (60-013) 
    *ON SALE $5 off until 6/20/2013! 
 2: 100 Ohm resistors (271-1311)
 3: 10k Ohm resistors (271-1335)
 4: Jumper Wire Kit (276-173)
 5: NPN-Type Transistors (276-1617)
The goal is to use Skynet Big Data to make the Hexbug Spider robot move using a Java SE Embedded app running on the Raspberry Pi. So, this should be good... Go grab your RPi and buy these parts at your local 'Shack, then come back here for more instructions... :-D

About

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

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
3
4
5
6
7
8
9
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today