Need for Spring ?

I have a setupCar method which initializes the inputs (individual motors)I use on my RPD (Raspberry Pi Driven) Car.  When I look at the code I notice this is not ideal. Too much hardcoded dependencies and this is not really something I want.  Imagine I would like to swtich pins because a pin broke,  …  I would have to modify the method and do a new build.  If I was using Spring I would only have to change the bean xml file and up we go.  I prefer to have some flexibility. As mentioned, Spring might bring the solution but I need to have a look at that and try to find out if I can configure the PI4J depencies in a Spring bean xml file. The source code as it is now, smells dirty.

See source of the method setupCar as it is now here under :

[code language=”java”]
public void setupCar() {
input1 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_02,
input2 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03,
input3 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05,
input4 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06,
leftWheel = new Wheel(0, input1, input2);
rightWheel = new Wheel(4, input3, input4);
wheelAxle = new WheelAxle(leftWheel, rightWheel);
car = new TwoWheelDriveRaspyCar(wheelAxle);


Back from holidays

Hello folks,

I just finished my holidays.  Spend a great time in the Alps in Austria hiking.  Every year I go there to do a shutdown restart so to say :-).  Last year was a busy year.  Now that I am back in town I will gently pickup my Raspberry Pi Developments from where I left them last month.



RMI finally working

My research on how to use RMI wasn’t really a piece of cake.  In a first stage I tried an sample using the rmic to generate the stub which went fairly easy.  But afterwards I found out that this was not really the way to go since this solution was oldfashioned.  I than tried the general accepted way which is described on an Oracle tutorial

Coding went well since you don’t really have to do a lot but getting it to work that was another story.  Starting the service side of the story was a real pain.  You have to use a parameter called “java.rmi.server.codebase” at startup.  The codebase identifies the location of the remote class files or jar containing the classes.  Probably this definition is not 100% correct but it works for me.  Anyway.  I first had to setup a webserver (apache2) which serves the jar file so I can access it via a simple url.  Quite simple.  But the the proof of the pudding is in the eating so I started the server side and it complained that my remote class was not found.  I must have checked tens of times for typo’s but no clue what was wrong.  After some googling I found out that as of JDK 7 update 21, a parameter called “java.rmi.server.useCodebaseOnly” is set default to true, which was not the case before.  As a result (I use JDK7 update 40) the codebase parameter was ignored at startup.  Instead this parameter had to be foreseen for the rmiregistry command and than everything worked well.

So to summarize.  To start the server part you have to do the following (this is in the context of my concrete example)

  • rmiregistry -J-Djava.rmi.server.codebase= &
  • sudo java -cp Example-1.5-SNAPSHOT.jar:.:class:/opt/pi4j/lib/’*’:log4j-1.2.17.jar -Djava.rmi.server.hostname= be.byle.raspycar.RemoteTwoWheelDriveRaspyCar

Having got RMI working, it is time now to continue with the next steps and improving my code.


Have a nice Sunday evening,



Hello, it has been a while since I last wrote something on my blog.  It doesn’t mean that I stopped but only that I didn’t have much time the last weeks.  But I did continue to fine tune the car movements.

During my developments of the RP Driven Car, I was looking for a way to interface with the car.  Just a small interface which I can use to make it go forward, backward and steer.   The key features for the car itself are developed but I need urgently a way to call them in an easy and flexible way so I can test drive the car.  My first thought was to use standard input an use the arrows to control the car.  Problem with the standard input is that each time you pushed an arrow you also have to push the enter to make the arrow input visible and readable from the stream.  So instead of pushing for example the up arrow to go forward I had to push the up and enter.  Which is not really flexible.  I was looking for a solution to deal with that and apparently there is none.  There were some external libraries who could probably do that but I am not in favor of so called exotic code that I would only use once.  Than I came to the id of having a little GUI that could do the trick.  Why not ?  Maybe a little more complicated because of the additional complexity but I am always open to try new things.  I have written applications with a GUI in the past (almost long time ago 🙂 ) but those were Web applications.  Now I mainly do developments in middleware where there is no need for GUI’s.  So I see this as an opportunity to have a look at the technical possibilities to write an interface which will interface with the RP to control the car.  I quickly came at JavaFX.  I have heared about it already several times and at last years DEVOXX conference there was a demo using JavaFX to connect with a Raspberry Pi which worked very well.  That is why I want to try this also out.  I’ll need some time to read about it and start some tryouts to find out how exactly I will do this.  I have not thought yet whether I will setup a webservice on the RP or interface via RMI.  Everything is open.  First I will focus on the simple interface.  It should look like the screenshot here under.  As I said.  Very simple to start with.