using java and usb: Which api? jsr-80, jusb, ...? - java

I would like two java programs to communicate directly over the USB without going through a device or cable. Don't ask me why, I don't know the details or reasoning behind this decision.
I have found jusb and jsr-80 to be two java/usb APIs to do this. They work on linux AND windows - I will need capabilities on both.
Question:
Which is more standard and accepted? Which is more stable? Which is easier for my task? Are there other standard or common java/usb APIs out there?
I'd like to hear your guys' experiences with these or other java/usb APIs.
Thanks,
Jbu

Well both of these implementations have their limitations specially on windows. They both lack support for Bulk Transfer on windows.
There is a commercial library JCommUSB available at www.icaste.com

I would like two java programs to communicate directly over the USB without going through a device or cable
Huh? USB connects a device to a host via a cable.
edit: If I had to quickly use two Java programs to communicate, one on a device and one on a host, I would almost certainly use the USB link (configured that way outside of the scope of Java) to act as a serial stream and use a serial library like rxtx.

Related

Play DRM encrypted video stream with "pure" Java

I am investigating whether is it possible (I am sure it is, I mean simple way) to build a Java-based client desktop App to play DRM protected video stream.
DRM: DASH CENC DRM1, PlayReady, Widevine Classic\Modular, FairPlay.
VLCJ supports the input-from-memory feature to implement custom protocols or DRM but it looks like a painful digging into DRM specifications.
There is a Node.js open-source project DOWNstream for Electron which can help with Widevine DRM.
The article describes Java and Electron integration (source) but I guess it is accidental complexity in this case.
Previously I didn't face with video-streaming domain and I wouldn't like to reinvent the wheel so my questions are:
It seems that there are no "pure" Java implementations. Why? Because of format wars? security issues?
Do you happen to know any simple way (DalvikVM supports Widevine out of the box) to create App without involving "browser techs" like JS?
Thank you. I would appreciate hearing your thoughts.
I think looking at how the DRM's are provided on platforms may help you understand the options and let you think about how you want to approach your solution.
The DRM client functionality, i.e. the DRM functionality which resides on a phone or tablet or laptop etc as opposed to the DRM server side functionality, is generally built in by the device or OS vendor when it the device or OS is being produced/manufactured. For some DRM's on some devices it is also possible to add it via a SDK.
Most DRM's are used via 'native' players in mobile devices and tablets and via the browser on PC's, laptops etc so this is the usual default that you can generally rely on to be supported. Smart TV's and games consoles are more varied and can be either via browser or native depending not he device.
Recently, nearly all mobile and tablet browsers have added support for browser based DRM also, but many DRM's on laptops are restricted to the browser, or more specifically the CDM (Content Decryption Module) browser add on which is DRM specific.
There are DRM's which are supported outside the browser on PC's and laptops - for example Windows based devices will generally support PlayReady DRM in a way that can be accessed by applications. Microsoft provide more infomrtaiopn on this here:
https://learn.microsoft.com/en-us/playready/overview/developing-applications
There is a nice diagram which summarises different devices at the above link which I've copied below also as it helps explain:
I am not aware of a similar Widevine or FairPlay support on PC's or laptops although ones may exist or be in development.
So, going back to your problem, the reason that most cross platform applications use Javascript and browser technology for DRM on laptops and PC's is not really a language issue, rather it is because via the browser is the only way to access the DRM functionality on some laptops and PC's.
For Windows you have the option to use the Universal Windows Platform API but this still may not give you want you are looking for and is Windows and PlayReady specific.

Best way to deal with COM ports for a cross-platform program?

I am writing an application which need to send data to a serial device attached to a COM port.
I am confused as to what is the best way to deal with such a device?
Shall I write the communication module in C++ or shall I write this in Java?
I want to run the application on Windows as well as Linux.
On Linux I would recommend libserial. You could also consider using Python. There is a multi platform pySerial module. If you decide for Java, rxtx is a multi platform library. On Windows you may use the Windows API for serial communications and combine it with libserial using #ifndef as #Dharma suggested.
I recommend you:
Boost ASIO
QextSerialPort (based on Qt)
You can write the module in c++ by specyfying the #ifndef "_WINDOWS_CODE" for windows code and else part for the linux code.
while compiling in Vc++ put the (_WINDOWS_CODE)macros in the projecty settings
and in gc++ remove the macro from project file
COM port is just a plain bit pipe. The APIs are expected to be fairly simple. In C++, the world has much more experience with writing to ports.
Other question would be - do you know what port number it is? There're several ways to find out which one is yours, like setup API on windows.
My suggestion, if you want to run you application in both linux and Windows, go for JAVA!. you can run your program without any need of compilation. otherwise you have to distribute seperate binary for both Windows and Linux.
Also programming model in both windows and linux for accessing SerialPort in C++, As i am preliminary a Windows C++ developer, you can use CreateFile WIn32 Api to access serial port.
shall i write the communication module
in C++ or shall i write this in JAVA?
Which are you more familiar with? Are you limited to these two languages? You could also use python with pyserial.
Are you doing this as a personal project? Is it for work? Is someone else working on this with you? What are they more familiar with?
For C++ you could use Boost.Asio.
For Java ... I don't know.

How can I use Java to communicate to device through USB port?

I just recently learn Java and try to communicate to the device through USB port connection. I've have used C# with OpenNETCF which allows me to send file and retrieve file on the device through USB port; how can I achieve this with java?
I seearch on stackoverflow thread, How to communicate with a USB device under Windows and Java?, the comment made by christoffer is to hack the native code, but I don't quite which native code api that he referred to. RAPI, maybe?
The only USB API I could find for Windows is here. Seems as if it has limited functionality, but it might suit your needs. A more complete UNIX API is also available.
ETA: Found a link to the official Java USB implementation, but looks like the windows version is still in alpha.
The native code API I referred to was the Windows DDK, i.e. the Driver Development Kit. The modern version seem to be called Windows Driver Kit, so google for Windows WDK :)
There should be a few C samples on how to communicate with USB devices, and it should be pretty straightforward to write a JNI wrapper from those.
As a quick thought, you could use JNI, the Java Native Interface. I've never used it myself though.
I found this page that explains how to perform a communication between a microcontroller and a java application: http://javausbapi.blogspot.com/
The Best way I found to communicate with USB is through RxTx library.
You can find an example of the usage here:
http://www.snip2code.com/Snippet/1044/Java--read-from-USB-using-RXTX-library

How to communicate with a USB device under Windows and Java?

I'd like to communicate with a USB device under Windows and Java but I can't find a good library to do so. I don't want the user to have to install any extra hardware or device drivers to make this work. That is, I want to be able to interact with USB just like other Windows applications do.
I am familiar with jUSB and JSR 80 but both seem to be dead projects (at least for Windows).
libusb-win32 requires you to install their generic driver, which then makes a USB device available to you. I'm not sure that it's possible to do driver-less access of an USB device unless the device belongs to one of several standard classes (storage and HID, in particular).
There is a Java wrapper for libusb-win32 which might work for you. I haven't used it myself, though.
I did quite a bit of research on this some time ago, and the unfortunate fact was that all the useful free USB+Windows+Java projects were dead. There is commercial and expensive (price $39.99 is not per developer, but per copy of your software sold!) JCommUSB library which probably works, although I have no experience of it; we had to build our own custom C wrappers to the USB drivers and communicate with them through JNI.
The fastest and easiest way is to hack some native code :)
I wrote a small wrapper for HID devices that enabled my Java applications to read data from CalComp digitizers, so it's definitely doable and not too hard. The bad thing is that my work is still proprietary code owned by my former employer, so for legal reasons I can't release that as open-source -- yet.
The good thing is that you can get a flying start with the HID example code from the Microsoft DDK :)
Communication between Windows and a USB device by java.
http://javausbapi.blogspot.com/2010/05/java-usb-api.html
An example is conducted for a Freescale microcontroller

Is Java the best language for Mobile App Devlopment?

I was wondering what are the benefits of using anything else but Java for Mobile Application Development.
I do think that yes, Java is the most common language for devices, with two exceptions:
Windows mobile applications, that are frequently built in C++ but that will be built more on the .NET framework in the future.
iPhone applications, that use Cocoa and Objective-C.
Java is the most ubiquitous and for that alone it is your best choice.
You have to use whatever the phone vendor(s) that you intend to support will provide. As most provide Java, but only some provide other things, if you want to support a range of handsets, you probably need to use Java for at least some of them.
Your client (be they internal or external) will need to decide what handsets to support, and you then need to base your decision on supported handsets.
It's not entirely impossible that you'll have to ship versions in different programming languages, which may make code reuse more "challenging". It all depends on your requirements. Nobody on this site can tell you what they are :)
It really depends on what you're trying to do.
Java, whilst ubiqutious does have speed disadvantages. Also it's not "write once, run anywhere" as it is on the desktop space, as different manufactureres, even different devices have different sub-sets of java installed each with differening inclusions of APIs.
Using native code is going to be more efficient, whilst more difficult to port. It provides a more direct representation of the devices capabilities without the sandboxing of a VMs Apis.
Alternatively, you could use a language like C which whilst isn't strictly portable, will have implemenations on many devices with minor tweaks to make, whilst retaining a lot of the speed beenifts of such a language. (OpenC on S60/Symbian), C on Palm etc.
It depends on what you see as the future of the the mobile space. If the iPhone turns out to be as popular as the iPod, then no, Java probably wouldn't be the best choice.
One thing to consider is that at some point there may no longer be such thing as an iPod Nano, perhaps the Touch will be the only iPod available. In that case, every single iPod out would support Apple's iPhone OS and the number of iPhone OS mobile devices would far exceed those of Java.
Five years from now perhaps "Cocoa vs. Android" will be the new Mac vs. PC. In that case, Java could be just as good as Cocoa.
The only reason I can think of is that you wouldn't need a Java runtime on the target device.
Palm, for instance, allows you to code in C and talk directly to the OS routines in ROM. The C code compiles directly to the machine language without needing a runtime.
before one can provide a speculative answer to such a trivial question there are other variables that need be answered. What kind of phone application does one want to develop.
e.g. you can use xhtml for something that does not need to connect to the phones' core features.
and when you need to connect to the phone software or hardware you have can use java,python,c++,windows mobile or the new kid on the block android.
Java is the best if you want to support multiple phones, however J2ME is a limited environment. If you are doing homebrew development then develop for whatever your own phone uses, for commercial development then Java is the most widespread (and there are companies that can port Java to other platforms).
One of the advantages of using native code is your are closer to the hardware, on a mobile phone this means you might be able to take advantage of features which are not exposed to the virtual machine upon which your Java application is running, the promise of Android is that everything is a lot more exposed that it is with a typical Java Mobile implementation
Best is to go to nokia, apple microsoft or google web sites or whaterver and see what developer tools and resources are available and choose the one you want to develop for all of them are very good as good mobile app developers can help increase their market share.
Depends on what Application you are trying to write.
If its a simple service / data provider I would use HTML and CSS via a framework like
jqTouch, jQuery Mobile, or http://www.sencha.com/ as these will run on mostsmart phones and you can package them into a binary app using something like http://www.phonegap.com/ this will allow for sliding, GPS, local file storage using HTML5
If you need to a database, motion sensing, bluetooth, game type application then you could look at
http://monotouch.net/
http://monodroid.net/
That lets you write c# .net code and deploy onto any platform do you should be covered for windows mobile, android and iPhone.
There is also http://rhomobile.com/ that lets you write applications for all mobile platforms using Ruby.

Categories