| Forum: System Design |
28. Jul 2008, 03:27 CET | Link |
I think your project needs to detach itself from Linux-only. As soon as you focus solely on Linux, you are restricting the applicability.
Your product should be aimed squarely at HA integration on whatever (Java) OS. Your hardware will never keep up with innovations in the market. And the hardware doesn't matter. The issue is software and the means to quickly integrate whatever you (or I) choose to buy. There are all kinds of hardware out there and what ever you can make it for, someone will come up with something better that will fossilise yours for lower $$.
And another point, one day you may need to sell your house. Geekware is a hard sell!
You need a system where the individual bits work independently and have channels (technicians) of commercial support. The HA integration should only add functionality to a initial system which should provide basic service (light switch makes lights go on).
For most of this integration work, the OS platform does not or should not matter. For example, forget C. Pointers?! No classes!? You will end up doing stuff you really should not. For most of this driver stuff, speed of execution is a non-issue. The device streams come at 9600 baud and your processor is >500MHz! Even the IP HA devices often only commit to 10-base T.
Using Java as platform, you can without too much effort write stuff that is platform independent. I am by no means a Windows enthusiast. My server runs XP which is not a good choice. It could use Linux, but then one of my purchased HA server apps only runs on IIS. I would have to learn Linux and I would have to use command line. Gave up that when my Radio Shack PC died and besides I can't touch type!. This integration stuff can and should run on any platform and should not be dependent on the OS. I do not see too much downside (in terms of time spent on software) to this.
My server is some kind of Asus small board running a Centrino processor and XP so the whole thing runs on about 100 watts. I control it with Remote Desktop. There is a fan, but it never runs. It runs IIS, Tomcat & MySql. It isn't particularly fast ( I never measured but it seems to work). It cost less than $800.
The rest of my HA stuff cost more than ten times that! Got a 61" plasma? Got a gigawatt AVR? Got a BluRay? Got twenty 110V switches at $50? Got 6-zone sound. Got a woofer? Got fifteen irrigation gizmos? Got wiring? I don't have all these, but many do.
iPhone is most definitely geeky. $200 down and then $65/month for three years minimum, that's $2540. Only in Canada! For one remote!!
Why the effort to avoid server side code and put it in your iPhone? Crazy! I would like to start with Eclipse & GWT & MySql & JFree..., - or something like that. The client? Any browser.
Why fool around with embedded Linux? Platform independence would extend the interest. You would get more than 31 members (on my screen).
Imho change your reference platform to be any Java 5 platform! Not much to lose. A lot to gain. Maybe keep what you got, but extend the scope.
Is this for a select group of Linux/iPhone I-will-solder-it geeks or aiming at the bigger issue of better HA control?
Pheww!
Your product should be aimed squarely at HA integration on whatever (Java) OS. Your hardware will never keep up with innovations in the market. And the hardware doesn't matter. The issue is software and the means to quickly integrate whatever you (or I) choose to buy. There are all kinds of hardware out there and what ever you can make it for, someone will come up with something better that will fossilise yours for lower $$.
And another point, one day you may need to sell your house. Geekware is a hard sell!
You need a system where the individual bits work independently and have channels (technicians) of commercial support. The HA integration should only add functionality to a initial system which should provide basic service (light switch makes lights go on).
For most of this integration work, the OS platform does not or should not matter. For example, forget C. Pointers?! No classes!? You will end up doing stuff you really should not. For most of this driver stuff, speed of execution is a non-issue. The device streams come at 9600 baud and your processor is >500MHz! Even the IP HA devices often only commit to 10-base T.
Using Java as platform, you can without too much effort write stuff that is platform independent. I am by no means a Windows enthusiast. My server runs XP which is not a good choice. It could use Linux, but then one of my purchased HA server apps only runs on IIS. I would have to learn Linux and I would have to use command line. Gave up that when my Radio Shack PC died and besides I can't touch type!. This integration stuff can and should run on any platform and should not be dependent on the OS. I do not see too much downside (in terms of time spent on software) to this.
My server is some kind of Asus small board running a Centrino processor and XP so the whole thing runs on about 100 watts. I control it with Remote Desktop. There is a fan, but it never runs. It runs IIS, Tomcat & MySql. It isn't particularly fast ( I never measured but it seems to work). It cost less than $800.
The rest of my HA stuff cost more than ten times that! Got a 61" plasma? Got a gigawatt AVR? Got a BluRay? Got twenty 110V switches at $50? Got 6-zone sound. Got a woofer? Got fifteen irrigation gizmos? Got wiring? I don't have all these, but many do.
iPhone is most definitely geeky. $200 down and then $65/month for three years minimum, that's $2540. Only in Canada! For one remote!!
Why the effort to avoid server side code and put it in your iPhone? Crazy! I would like to start with Eclipse & GWT & MySql & JFree..., - or something like that. The client? Any browser.
Why fool around with embedded Linux? Platform independence would extend the interest. You would get more than 31 members (on my screen).
Imho change your reference platform to be any Java 5 platform! Not much to lose. A lot to gain. Maybe keep what you got, but extend the scope.
Is this for a select group of Linux/iPhone I-will-solder-it geeks or aiming at the bigger issue of better HA control?
Pheww!

There is no hard dependency on any particular operating system. We plan to isolate Java processes from system processes through IP sockets. All the intelligence will be handled by platform independent Java software.
Sure, that's what we will do. And in addition we'll provide a client that has full access to the native capabilities of the iPhone/iPod touch platform. And maybe even clients for other platforms, if they have interesting native features you can't get access to with Javascript (Nokia tablets).
Also, the iPod touch is $350 and will hopefully fall below $200 in the next 2 years. It would be interesting to know if there is any other touchscreen handset that would have the same features at that price point - and an installed base of millions.
You need native drivers at some point (see the work that Neil is doing on the CM15A for example). So you have to have an OS. As CB pointed out, the design right now is in different process spaces and we communicate via calls.
But we try to keep, the C layers simple (pipes of bytes) and all the mapping is done in the java layers, the protocol intelligence would be in java. Easier to write, install (dynamic, no restart) and maintain.
What you are focusing on is the reference implementation, We talk about java a lot there as well, I don't know if you have noticed.
Slow down Robin, we use java as the platform! The bytes are formatted and made sense of in the java layers. Integrating all the proprietary protocols in a best of breed HA installation should be done in a environment like the ORC.
You are right, what are we thinking! owning an iPhone! Insane!
In all seriousness I would love to see a level of integration with KNX and US providers for example (anyone know anyone from Siemens here :) so we could choose cool in wall panels a la Lutron but from a variety of vendors.
Well yes and yes, we are actually quite snobbish in who we like to hang around with. That being said, democratized HA control, integrated HA, easy to program HA, easy to install and maintain HA are all valid goals. We are trying to figure out what it means to us exactly and your feedback is appreciated.
Take a deep breath, stick around, Saw your post on cooler about your company. Maybe ORC could be the base for a future controller of yours? It is still early but as an integrator, OR could offer standardized programming models. From the java world at JBoss we had state machines, workflow engines, scripting languages, visual web tools etc. You seem to have a keen interest in seeing a common programming model emerge and some specific thoughts on UI design. Do check out the notes about the current thinking and feel free to discuss.
Welcome to OR. PS: do check out the button on the top right it does give you great tips for formatting your post. A tip is to turn on so you know when you went wrong. It is a bit stiff at first but it works well and it looks good.
Well yes. Looks like I had a case of the diarrhea yesterday!
I have just been looking at ancient code I have for two instances of drivers I have written.
One is in Java for the HAI OmniPro. It uses comm.jar for all the really low level stuff. That is used by a class
public class HaiConnection { public boolean open(String comport, int baudRate); public boolean isConnected(); public boolean login(); public boolean getResponse(MessageInterface outMsg,MessageInterface response); public boolean receiveMsg(MessageInterface response); private void sendMsg(MessageInterface outMsg); }Within this code, two key lines (for the discussion here) are: The tricky thing in this code is sorting out the solicited input from the unsolicited input noting that the unsolicited stuff is not well-documented.Higher level classes create messages, such as
public class RequestThermostatStatus extends Message { byte[] thisMsg = { 0x5A, 0x03, 0x1E, 0, 0, 0, 0 }; public RequestThermostatStatus(int firstZone, int lastZone){ msg = thisMsg; msg[3] = (byte)firstZone; msg[4] = (byte)lastZone; calcCRC(); setCRC(); } }Further up there is a lineif (!hai.getResponse(new RequestZoneStatus(first, last), zoneStatus)) { System.out.printf("\nNo or bad response from HAI"); return false; }That's enough to see how my drivers work.To me it is proper that all this logic is in Java and platform independent. I don't know where I got comm.jar from, but hopefully there should be a Linux and a Windows and a Mac version.
The other driver is for a Denon AVR4306. It is written in Lua and uses the Girder gip class for low level access. gip stands for generic IP and comes with girder as a library. Its code looks something like this (I will edit it a bit to make it more concise)
--[[ Denon 4306 AVR --]] avr ={} --[[ AVR callback function. Handles unsolicited events from the Denon Callbacks on the Socket object are made when connections are made or broken, when data is received or when errors occur. Usually these mean someone is fiddling with the knobs and selecting a new mode. --]] function avr.CallBack(data,code) if ( code == gip.CONNECTIONCLOSED ) then print("Connection Closed") return end if ( code == gip.CONNECTIONESTABLISHED ) then if ( data == 0 ) then print("New IP connection to AVR 4306") avr.state = "open" else -- data ~=0 print("New Connection Failed. Data(error?): ", data) end return end --print("AVR callback data:",data," Code:",code) end --[[ Open the socket in the AVR on the Telnet port (23) & register a callback --]] function avr.init() print("Open socket to avr") avr.state = nil count = 0 socket = gip.Open('192.168.002.7',23) socket:Callback(2, '\r', 1000, avr.CallBack)-- 1s timeout while avr.state == nil do win.Sleep(50)-- ms wait for callback - does not work?? end print("avr socket:",avr.state) end function avr.write(something) win.Sleep(500) if avr.state ~= "open" then avr.init() end --print("Writing to AVR socket:", something) socket:Write(something) end function avr.on() avr.write("PWON\r") win.Sleep(1000) print("AVR on") end function avr.off() avr.write("PWSTANDBY\r") print("AVR off") end -- avr input source --available args: PHONO, CD, TUNER, DVD, VDP, TV, DBS, VCR-1, -- VCR-2, V-AUX, CDR/TAPE, AUXNET, AUXIPOD, ? function avr.selectSource(src) avr.write("SI"..src.."\r") end -- avr sound mode --available args: DIRECT, PURE DIRECT, STEREO, MULTICH IN, MULTI CH DIRECT -- MULTI CH PURE, DOLBY PRO LOGIC,DOLBY PS2, DOLBY PL2X, DOLBY DIGITAL, -- DOLBY D EX, DTS NEO:6, DTS SURROUND,ES DSCRT6.1, DTS ES MTRX6.1, WIDE SCREEN, -- 5CH STEREO, 7CH STEREO, SUPER STADIUM, ROCK ARENA, JAZZ CLUB, CLASSIC CONCERT, -- MONO MOVIE,MATRIX, VIDEO GAME, VIRTUAL,, MPEG2 AAC, AAC+DOLBY EX function avr.soundMode(mode) avr.write("MS"..mode.."\r") end -- avr master volume increase function avr.masterVolumeUp() avr.write("MVUP\r") end endYou don't need to now too much about Lua to follow that. The functionality provided by gip is already in Java. Open a socket. Listen on it...
Back to philosophy.
(IMHO) This is the kind of 'driver' code that you want lots of for lots of devices. A good point was made elsewhere that you won't own all of these potential devices but you do want a library of implementations. How to standardise it a bit? Good base classes or interfaces.
I can envisage a generic IR device class that could initialise itself by reading a csv or JSON file of codes and interface with USB-UIRT or Global Cache or any IR hardware using JNI (isn't it). Such code could handle a huge range of IR devices. Or you could download the codes as xml (I suppose) from the IR database.
An issue would be what is the interface of a driver. What methods does it have? How does it expose what it can do? Is a driver really a bean?
Creating the gui is then a case of mapping gui widgets to driver (bean?) actions. Not too difficult if actions have no arguments.
Hibernate does some of this mapping stuff in xml. It is readable, but not an exciting read.....
Enough. - Mapping should be in a different topic.
I decided to wait to post, how dare Robin denegrate my Linux! ;-) (See my sig if you don't quite get the humor, if it still doesn't make sense, ignore it).
I don't know, there seem to be only two of us (MarkS and I) who can wield a solder iron properly. The rest are just programmers (that's going to get me in trouble ;-). I don't know about MarkS but I can code too (which is not the same ting as programming).
All kidding aside, the reason for Linux on the reference implementation (the ORC) was it was cheap, enough of us are familiar with it and it fits well on smaller systems such as the controller.
On the Java side I think we settled on the network daemon type interface. OS differences are now gone. I was thinking about that last night. Such a daemon could be written for any OS to hide it's device interface details from the Java programmer. One thing that doesn't translate well between OS's is the device interface (not everything is a serial port). Windows has the HID on the USB (for some devices), Linux kind of has it but it's different (but Unix folks prefer /dev/xxx devices) and on other OS implementations, ..., well I don't know. At the moment we're not that far along to actually have a lot of code written. Once a daemon is written the Java remains the same. The daemon also allows for devices that are not directly connected to the host controller but are reachable over a route-able network (they could be worlds away).
I see being cross platform as being a good thing. It was one of the things that worked well in the Misterhouse project. I see no problem with that. As for the starting off with the Geek crowd well that's a necessity. If the average folks could do this already the project would have done. But as we are just starting out we have geeks with egos running the asylum. ;-) Eventually the normal folks will get to running things and we'll either be put back in our padding rooms with full length formal wear, crayons, soft food and a keyboard or we'll run another asylum. :-)
Author: Linux Smart Homes For Dummies
Well congratulations on mastering the markup language so fast, you are a quick study.
GAH! HEX CODES!!
pant! pant!
Ideally we would externalize these in machine readable format hence the xml in Hibernate for example. You may want to read up the notes by CB on Beehive, a lot of work and thinking is needed there to achieve the database you refer to (see under Misc).
Neat!
GAH! NON-STANDARD ABBREVIATIONS!!
See point about externalizing the proprietary lingo so we can map a more standard message format like KNX. Then you can isolate all the local stuff in the java driver, makes sense to me.
Well you may want to check out the discussions with Neil and Juha, they are both going through the moves of defining a driver for X10, CM15A (reference implementation on Linux :). I will go through the moves of a KNX driver. We are thinking about an INSTEON driver etc. Maybe an OmniPro driver integration would help us? You obviously have been through the moves of writing your own driver. Maybe you can help them.
Also they defining a packaging for such a driver. Once you define you have an omnipro installation, we would indeed download a bean that is a java representation of your device. The point is standardizing packaging so we can simplify installation and maintenance.
yes, see Beehive, you may want to help there as well. Stewart Allen from Tonto has offered to help us if we want to take the project. We will be interested in the CCF data as a populator for Beehive. Defining the format, as you point out doesn't make for an exciting read but is an important step.
Could very well be a bean. Not truly relevant as long as it is a dynamic profile and this is a function of the classloaders not of packaging. We are using a JBoss base to have access to these distributed classloaders (so you can load a class from a URL, in this case www.openremote.org. You instantiate the classloader with the URL and you can remote load, as simple as that. We will want to explore the implications for installation and maintenance of the controllers.
See UI discussions. There is a layer of abstraction here, so we can have custom remotes, even profiles that are really a selection of a subset of the commands externalized by the device. The idea is that the cocoa application reads an XML file that describes the UI, we would generate these from a web application of , we plan on using GWT for that.
Right now we are steering away from comms.jar to increase the reliability of the system. The assumption here is that Neil can code a daemon that doesn't crash left and right ;-) But the point is that even if it occasionally trips up, we'll just restart it without affecting the rest of the controller functionality or responsiveness. We get subsystem isolation via OS process spaces.
Should that plan fail, we can always fall back to comms.jar. And if somebody does provide a driver to a device we don't provide an integration for, and it does rely on comms.jar, we can still use it. Either short or long term. Depending on the level use, reliability and the comfort level of the community in case of a failure.
Java frameworks have evolved far enough that we don't necessarily need to lock things down with base classes or interfaces. Introspection of class members and annotations or XML configuration enables flexibility for implementors to follow their own programming models. I'm leery of locking things down at this point when it is not clear how people will want to use this thing we are building.
The goal is to have a normalized device database, as was mentioned elsewhere.
In the interim, csv or other formats for bean class to initialize itself is quite plausible. The middleware is generic enough to handle such a case.
Doesn't really matter. It's a component with an arbitrary interface. We've supported this in middleware for quite some time.
What matters is the metadata that allows input commands (HTTP, IR) to be mapped to the driver methods.
This is metadata. Several specifications and implementations have solved attaching arbitrary metadata to a class.
To an extent that it wants to integrate with the middleware, yes it is.
Juha Lindfors
Co-Founder OpenRemote
Join OpenRemote Chat
If comms.jar has bugs (I don't know), isn't the right approach to write a new comms2.jar that doesn't have bugs. Device driver bugs can crash the whole OS, so the device driver ought to be small tight code that just connects the hardware to the app and not much more. In this case (comms.jar) an RS232 driver.
Above this layer is the packetisation, hex codes and asynchronous stuff that is different for every device. Given that this will have more bugs than the former, it should run in user space where it can exception rather than crash.
Custom drivers should only be needed when you have a custom hardware interface, for example a parallel port that drives relays or an embedded sub-micro controller where you really need to know the hardware.
Anything IP or RS232 should use heavily reused code that really works. Comm.jar or a derivative or replacement.
I liked the BT Serial dongle that was showcased here the other day. This way we can put a dongle in the back of a TV and BT to it from the ORC without any other physical connection. If that is what you want to program, just start coding it will control your TV... methinks you got your itch...
we got a winner!
My Panasonic plasma TVs have a pretty dumb IR interface. There are some discrete codes though for on/off.
If you did into the menus, deep down, there is a Linux acknowledgment. My TV runs Linux!
I'll wager that one could hack into that. I'll bet service guys have an IP header that gives access to that.
Don't look at me!
Many Panny's have RS-232 ports, which would make it much easier to integrate, what is the model number of your plasma?
RIGHT! :-) I think that Linux has had such protection since early on (same thing with Unix and jsut about every modern OS). I've written all sorts of bad code while experimenting and I haven't crashed the system. I'm pretty good at crashing things, that's why I was hired at the labs.
Sorry for the late replies, had a very bad day at work. I lost two Ethernet switches and an ancient server (Fedora 4) due to power problems. They were bringing in a new 13Kv into the complex and some of the old equipment did not survive power up. I'm still trying to rebuild my test bed. I was at work until 8PM, long day.
Hey, I'm writing kernel space drivers. :-) But as Juha has said the drivers are just juggling bytes as quickly as possible and don't do a lot. That's the way all device drivers should work, don't do more than the absolute minimum. Slightest slip and poof you're rebooting everything (this is true of any OS). I don't know why everyone freaks with C, it's a lot better than assembly language. ;-) My object are made up of bits. Most of my work is at the lower levels.
The daemons should be very stable. I've run most of this code on my Fedora server for a long time. Other than power problems in my home and bad hardware my systems stay up for months. In the past I've used CGYWIN to compile the Unix code to operate under Windows. It's worked well but I'd prefer native Windows code. I'm not a Windows person so we'll probably someone to help me with that. But that's later.
Author: Linux Smart Homes For Dummies
All software has bugs :-)
The problem with JNI bugs is that they have potential to bring down the JVM with them. I'd like try and keep the JVM around even if it can't tell the client anything other than
And that's also a problem. So I'm counting on a modern Linux kernel having a sufficient protection from a user process reading and writing bytes. Linux can do this, right? Right? It's not like we're writing a real driver here in the kernel space, just a process that reads and writes thru the actual kernel driver? Anyway, we're getting into Neil's domain here, he can correct me if I am wrong.
the daemon doesn't do anything other than pipe bytes through for us. In that sense it's no different from Java Comms. There's no logic in it. Just that we partition the system to two processes. Instead of JNI we use sockets.
We're not writing kernel space drivers.
Juha Lindfors
Co-Founder OpenRemote
Join OpenRemote Chat
When I speak of drivers I'm speaking of code that interfaces to the operating system. This can't be avoided if the device is connected to the box then a device driver is required. Some USB devices are HID but even these devices depend on the USB device driver. I'm not a Java coder, I learned a little in school but I've quickly learned that a lot of what folks say here is well beyond what I know.
The comm.jar doesn't handle anything more than the parallel port and the serial port. A daemon can hide the fact that you're talking a a fancy dll, device driver or peeking/poking (sorry couldn't resist) the bytes into place.
Author: Linux Smart Homes For Dummies
comm.jar doesn't have any issues that I'm aware of (I wrote the how-to afterall!)... if you all want to steer clear of it, that's fine, but it doesn't have any issues that I'm aware of... all of my stuff runs fine without issues using Trent Jarvi's version (as referenced by my how-to: http://www.agaveblue.org/howtos/Comm_How-To.shtml).
However, I still highly recommend partitioning anything that talks to hardware from the main JVM that way it is easier to re-start individual things as needed as opposed to having to restart the entire JVM...
As I stated early on, we can always install two JVM's, one full-featured JVM for the main JBOSS stuff, and then one scaled-way-back jvm for dealing with hardware interactions (all we need is some basic stuff with networking... an old java 1.1 or scaled back 1.2 vm would work fine for that stuff).
I know that this may sound hackish, but it may be worth doing.
Add a little tequila... to your Java http://www.agaveblue.org
Robin, don't know how I missed this thread. Regarding your Omni pro Java code, I just started writing the same thing. My idea was to pair it with Apache Axis and have a soap/rest/json interface to the omni (how cool to have a web services enable home!), I'm tired of trying to port it to this language or that language, having a web service enabled server would be heaven. I was planning on releasing this as a GPL'd project. Is your source code available for such a project? I have a C implementation I wrote for my iPhone app H@me which I hope to release as open source one day (its rather customized for my app), I also have a ruby proof of concept I'm currently writing for inclusion into the LinuxMCE project so I have some experience with both the original omnilink protocol (serial,udp up to 2.16) and the new omnilink II spec (2.16 +, uses tcp and event driven notification). I would be willing to do the work to UDP/TCP enable your stack as well as port it to the new omni spec.
It would save me alot of time to start with your code, I'm spread thin as it is between a couple HA projects.
Thanks! Dan-
Robin and Dan,
We would welcome such a project. I hear everyone is spread thin but starting a project and getting it some visibility is not something that will cost you a lot more compared to what you are doing already. Open Source can help as long as someone is the driver.