Java – Best Way to Access Hardware per COM Serial Port over USB Adapter

comjavasilverlightusb

We are starting a total new Branch at our firm. I am usually developing database interfaces or internal server/client applications/tools for our company, but I never had to do something with hardware.

Szenario

My Boss want to sell a device, which has a touch-screen to set up the many, many features. However, the configuration of the device can be very time consuming. He wants to give a software free for a good customer and for a litte charge to "small" customers. The customer should only be able to use the software, if he registers at our system, so that he can't copy the software without a notice by us.

Requirements

The device has a build in USB cable. If you plug it in your computer it opens a new COM serial port. The software has the following requirements:

  • Configurating different presents for the device
  • Reading and writing the presets to the device
  • Software will refuse to start, if the user has no registration at our server
  • The user can store his presets at our server and share it with other customers
  • One preset, copied over and over to multiple devices

My boss has seen similar system (he said something about logitech harmony remote controls) and it is now on me, to create the architecture.

Server Side:
The server is not that kind of problem. We have enough different machines to suite any kind of favour (IIS, LAMPP, Apache/Tomcat etc.) I could take MSSQL or MySQL DBase to store the data, thats not the problem.

Client Side:
This is the tricky part for me. I never did something with hardware. My boss suggested I should use Silverlight. I claimed that I want to do it with a native application. But what is the best combination?

  • Total Client-Side (C++, C# or Java are the languages I could write)
  • Mixed Structure #1 Silverlight + Native "Driver" Application
  • Mixed Structure #2 Java-Applet + Native "Driver" Application
  • Browser Only – Silverlight or Java-Applet?
  • Any other suggest

The device is for a special customer group who's getting personal trained with any purchase so security risks like unsafe code or dangerous browser plugins are no negative selling argument.

I did some research about COM Serial Port connection with Silverlight and P/Invoke but I don't want to start without a discussion what would be the best way.

Best Answer

Definitely stay away from Java applets and Silverlight. Both are tricky for users, error-prone, and their future is uncertain at best.

The only tricky part is the client.

For client, I'd take a well-supported cross-platform language. Unfortunately, you can't be sure that a runtime for such a language is readily available on a client machine. So bring it with you.

I'd take Ruby, Javascript (node.js), or Python. Either has a relatively compact runtime, and either allows to create an self-contained standalone app from your program. Accessing COM port should not be hard from any of them. Accessing your server, even easier.

Your client app will likely require a GUI. I'd go for a web UI: start a local web server, stop caring about cross-platform GUI toolkits and the like.

I'd build a version of a client for each major OS type (Windows, OSX, Linux) without much (if any) code modifications, and would distribute it with the device.

The server part is not tricky; use whatever technology you like. For the client-server protocol I'd use REST over HTTP(S); it has the fewest problems with any kinds of network setup, firewalls, etc. It also has excellent tools for troubleshooting.

Another tricky part is server-side authorization. It'd be best if your device had an unique ID, because your program would be much easier to crack than a hardware device.

I don't see why this is needed, though. It's the device that brings you profit. You can't sell more of your support software unless you sell more devices, and the support software is useless without a device. I'd just give the software away. Your software is not unlike a driver. See, graphics cards manufacturers allow to download their huge and sophisticated drivers for free, and feel fine. So will you.

Related Topic