![]() |
![]() |
|
|
|
|
|
|
|||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||
|
|
|
|
|
|
||||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Home
|
||||||||||||||||||||||||||||||
![]() |
![]() |
I wrote a small Java class library to use Morphy USB-IO devices. It
is still under development, but it currently runs fine under some
limited purposes.
Why I did it?... because I write everything in Java these days. Recently, I'm so Java-biased, so I can't stand the fact I must free (or delete) allocalted objects (memory blocks) manually. I had no choice than using Java to control Morphy USBIO. Overview of the Class LibraryHere is an overview of the class library, explained by an example. An LED FlusherThis is an example to flush an LED connected to USBIO. The LED must be wired to bit 0 of Port #1. Refer to the following schematics.
The controlling program is as follows. import xyzzy.hardware.UsbIo;
class Led
{
public static void main ( String[] argv )
{
try {
final UsbIo.Device usbio = UsbIo.getDevice();
try {
int bits = 0xFF;
for ( int count = 25; count > 0; --count ) {
bits ^= 0x01;
usbio.invoke( UsbIo.WRITE1, bits );
Thread.sleep( 200 );
}
} finally {
usbio.invoke( UsbIo.WRITE1, 0xFF );
usbio.close();
}
} catch ( Throwable e ) {
/* Show any Error/Exception. */
e.printStackTrace();
}
}
}
Let me explain what the parts of the program are doing. Primary USBIO controlling classThe class
Obtaining a USBIO device objectThe program first obtains an object representing a USBIO device. The
USBIO device object is an instance of the class
Invokation of a commandUse Termination of the use of USBIO device objectsWhen application finishes the use of a USBIO device object, it must
call How to get and install the class libraryDownloadingYou can download the class library from Downloading page on this site. Also, you might find many other sites/pages if you searched the Internet, since redistribution is allowed. You can try it if you meet any trouble downloading from here. NOTE: When this page was unreachable for a month, I received an email saying "I tried many Internet search engines to find a mirror download site, but I got none." It's my pleasure to know there is an active user, but I meant it as a joke. I guess nobody want to mirror such a tiny program unasked. I apology for confusing you. Both binary and source forms of distribution is available here. Binary distribution is further divided into a platform independent class file archive (jar file) and optional platform-dependent native code libraries. (Currently, there are no Java API to access USB functionality directly, so use of native code is mandatory.) Installing binary distributionDifferent combinations of OS and Java Environment different binary distribution files. List of supported platforms and their required files are shown on the following table. To run on other platforms, you should get source distribution and recompiling (after some modification if needed.)
In any case, the preferred installation is that prepare for a
dedicated directory (on any location) and put all files in it. To start
an application that uses USBIO class library, you should cd to the
directory and issue the following command. (The following samples assume
you are starting an application
Note that, on FreeBSD (and on other modern posix-compatible operating
systems), you should set Compiling the source distributionSource files are distributed as a .zip file that is compatible with jar. You should use jar or any compatible tools to extract sources from it, so that you can compile them. The Makefile included in the source distribution assumes use of Cygwin tools on Windows. It uses jikes when compile Java source files. Most of the Java compiler should do the job, so you can use your favorit compiler, if you don't like jikes. Native code related parts, however, require special considerations as explained below.
|
|
|||||||||||||||||||||||||||
![]() |
![]() |
|
||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Projects-Lab.com | Circuits-Lab.com | Elektrotekno.com | Free Schematics Search Engine | Electronic Kits | Mobile Phones |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||