• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Building my own hardware/device

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I had background in C/C++ for making my own PC-connecting device through the old and historic serial port, but that's many years ago when the serial/parallel port were used widely for connecting almost any external hardware to your pc.

Moving on to Java and USB... Frankly speaking, I have no idea and experience with communicating through USB with Java before. Can someone be kind to give me an idea or references for how I can make my own hardware/devices with the ability to control it through Java and USB?

Basically my device is just composed of many LEDs, sensors and motors... nothing high-tech. I just hope I can write a Java application with Swing interface and allows users to control how different component parts work through the interface.

Some of the things I am concerned of:
Do I need to write a driver in any other languages apart from C++? Is there any cross-platform/OS solution to this?
Do I need some hardware to multiplex/control data in between my motors and the USB port?
How does Java communicate with the USB port in low level in terms of bits and bytes?
Are there any open source existing libraries which can be helpful to this project of my own?
Is Java a bad language option for doing this kind of hardware communication work?

Other than suggestions and references, some explanations and samples will be helpful too.

Thank you all in advance for saving newbies like me.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSR 80 pertains to Java+USB
Quick googling gave me this article

This topic is too difficult for "beginning java". Moving...
 
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At the Java level there is little difference between a serial port and a USB device.

Get the right library, select the device and they behave the same.
 
Ranch Hand
Posts: 85
Mac Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't had a lot of luck with JSR80 or JUSB; they seem to be OS dependent at least from the time I spent trying to make them work; and even in that experiment you had to have a certain Linux kernel and USB service to make them work properly. Not sure about windows; maybe there is something more stable.
In regard to RS232/serial, I posted this last week. Hopefully you will find something useful.

I use serial devices all the time because the industry I work in still uses the protocol as standard. As i said above, I've dipped my foot into USB and it was akin to hitting myself in the head with a hammer for 3 or 4 days with no results. I have read other languages like Python (C++?) are better at dealing with USB; ie they have built in/approved APIs that allow you to spend your time developing rather than trying to get the API itself working.

My frank opinion :
You are familiar with how RS232 works from your previous work. The Java SE Socket classes are rock solid and all kinds of examples exists to help you when you get stuck. Drop the 99 bucks for a serial to Ethernet server I linked in the post and assign it an IP. Once you do that Java will communicate using a Socket (which its really good at) and your device will communicate via Serial (Rs232, 484 whatever; just make sure you get the correct serial server) which it sounds like your past devices are good at.
In this model, everyone is good at everything, and most importantly your application and device will be portable. Any OS that has a JVM and can communicate via TCP/IP will run your stuff like a champ.

Thats another big drawback from what I have seen (aside from the overhead of getting the API working in the first place). Assuming you get the API working correctly on your chosen OS, USB or a COM library puts you in a position where you absolutely have to use the OS that you used to develop the application on. As an example, I develop in Linux and most of my deployments are on a Windows flavor; I shudder to think of having to try and get everyone to play nice together when deploying using USB or a COM library.

Not saying it can't be done; I am sure if one was persistent enough, USB or a COM library would work in both environments. Whatever path you choose, I wish you luck. It sounds like a fun project!

 
Joe Areeda
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't done much but working with USB GPS devices was not as painful as Cory's experience. He may very well have better insight than I do.

All device management is somewhat OS dependent. The library I used had the Linux and Windows native drivers I needed. I can look up which one I used but I can't really recommended it beyond it was the first one I found that worked for me. I did not have any OS issues.

You will certainly need to test and debug the device control part of your application on each OS you plan to deploy but I think you'll still see a good amount of OS independence in the whole application.

 
S Chan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for all good advices. They are useful to me.

The OS dependent issue surely is something not so straight forward. I will need to carry out more trail-and-errors tests for that.

Doing it in another language may be quite painful for me, because frankly speaking, I don't know Python and I think I have lost my touch with C/C++ after so many years. I have got used to Java these few years so I thought if it is possible in Java, I would use Java entirely.

Suddenly I feel that I am so new in this USB field and I have a lot to read on.

Thanks, everyone!
reply
    Bookmark Topic Watch Topic
  • New Topic