Changes between Initial Version and Version 1 of Java


Ignore:
Timestamp:
Jun 18, 2009, 4:45:14 PM (15 years ago)
Author:
jsandahl
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Java

    v1 v1  
     1 Requrements =
     2
     3To be able to use your TellStick from Java your OS must look at it as a serial unit. In Linux this is relatively simple as the unit is installed as a usual unit under /dev and you can then use e.g. javacomm to work with the unit. In Windows it is harder as the unit does not show up as a usual serial connection. You can use JNI to call one of the DLL's that exist to communicate with TellStick. If there will be VCP-drivers for Windows (Virtual Communication Port, make a USB-unit look like a regular serial port) the same example as for Linux can be used.
     4
     5You also need a deveopment kit for Java and the possibility to edit your own softwares. The simplest solution is to use one of the free development environments that are available:
     6  * [http://www.netbeans.org/ Netbeans]
     7  * [http://www.eclipse.org/ Eclipse]
     8
     9Development kit (JDK):
     10
     11    * Sun's javahemsida
     12
     13It is very simple to write a class in javacomm representing your TellStick making it possible for you to send the right strings to it. Remember that the Java coding usually is unicode but when you work with TellStick you want the regular 8-bits ASCII. This means you have to be extra careful if you are to send non-ASCII-letters and digits (e.g. åäö). Also remember the data type in java is byte 8 bits while a char can contain a "java sign" (normally 16 bits).
     14
     15For a simple start project you can retrieve [http://flax.homelinux.org/~flax/rfcmd_java.tar.gz Simple project in Netbeans] and look in the code. TellStick has an own class and there is a first try to create a hierarchy to manage several types of units.
     16
     17In the example (which is a straight adjustment of rfcmd.c) the following is assumed about the managed units (NEXA):
     18
     19* A command to a remote unit is 12 bits long. The bits are sent in reverse order (low to high) and in the order house (4 bits), channel (4 bits) and command (4 bits). Command is somewhat special as bit 1 is zero, bit 2 and 3 in the block have to be ones, while the command is stored in bit 4. (i.e. in the normal order command is always 011X, where X is one for "one" and zero for "off")
     20
     21House is given as A-P (numerical value 0-15) channel is given as 1-16 (numerical value 0-15)
     22
     23In the string that is sent the following is applied: The string is started out with the character "S", the bit string is then sent with the string " `` " for a one, the string " ` `" for a zero and is ended with the character "}+".
     24
     25Example: House C, channel 5 and the command "on", leads to numerical house = 2, channel = 4 and command = 1. Bit pattern: (command)1110 (channel)0100 (house)0010. As we have to send them in reverse order the pattern to send is: 010000100111
     26
     27After conversion to strings for one/zero we retrieve:
     28
     29{{{
     30
     31" ` ` ``  ` ` ` ` ` ` ` ` `` ` ` ` ` ``  ``  `` "
     32    0   1   0   0   0   0   1  0   0   1   1   1
     33
     34}}}
     35
     36Add start/end characters: "S ` ` `` ` ` ` ` ` ` ` ` `` ` ` ` ` `` `` `` }+"
     37
     38About the same procedure is used for other types of units but the represenation for one/zero can differ. Se rfcmd.c for example. Eventually also the order of the bit string can vary.
     39
     40I klassen NEXAUnit.java finns en del kod som kan vara till hjälp.