I'm currently doing a project where I have to interact with a circuit I made through the parallel port of a computer. However, my computer doesn't have a parallel port so I borrowed a Parallel to USB adapter cable. The cable didn't come with any drivers, but it's recognized by the device manager as a "USB Printing Support" controller, under the USB section.
It seems that old parallel printers can be plugged in and work properly without any problems. So my question is, if I write a program in Java that tries to interact with a parallel port directly, will it work? And if not, can anyone give me some pointers as to what I need to do to interact with it?
Thanks.
I think you should head toward javax.comm library here.. there is also a different version that is supposed to work better, called librxtx.. take a look here (it's a pluggable replacement for javax.comm)..
I used both of them for an embedded device and they worked great, they manage serial and parallel port.. maybe also usb in your case.
I can't speak for parallel or Java but I've done something similar with serial-via-USB and C#. In that case it was exactly the same as a native controller. YMMV.
As for testing things: get an old dot-matrix printer (and put it in hex dump mode if you really want the nitty-gritty).
If you really want drivers for the thing, find a utility (I think the windows device manager can do it) that gives you the vendor ID and product ID numbers and from those you can look up all kinds of fun stuff (many Linux distributions have a plain text file that maps the numbers to the name of the manufacturer and what not) that plus Google should give you a driver installer.
You need java parallel port drivers which I haven't found for free. You'll have to pay for the driver for Windows.
I think there might be some free drivers if you use Linux.
USB "parallel port" adapters and cables generally aren't. They contain chips that emulate USB printers and send the print data out the parallel port like it might be sent to a similar printer using a parallel (printer) port.
Unless the device you have is actually a printer, there are probably very few (if any) adapters that will work.
There are ways of attaching GPIO "parallel"/bus pins into USB including certain FTDI chips, UARTs and various microcontrollers. If you can write software to use one of these, it could let you drive arbitrary circuits the way olde PC parallel ports were (not through the same MMIO, though).
Related
I'm in a project that must perform "tests" on USB Pen Drives.
For that, I'm using a USB Hub (49 port Asic Miner - I'm using it due the number of ports).
I intend to plug 49 USB Pen drives on the HUB and test them using a Linux Java App. The test consists on "check if it is recognized", "storing and deleting data" and "check the size".
My problem is on the first step. If there is any Pen Drive that is not working properly, the system will recognize 48 pen drives, but I'll never know the specific device that is not working.
My question is: Is there any way to know the address (or something like that) of a specific usb port on a usb hub? For example: If I connect just one USB Pen Drive on port "34", my software will know that the device is connected on that specific port.
Thank you very much for your time and for your help!
Use Runtime to execute the Linux command mount. It will list all devices currently mounted, manually or automatically, like:
/dev/sdb5 on /media/xdrive type ext4 (rw,nosuid,nodev,uhelper=udisks)
/dev/sdj1 on /media/Website type vfat (rw,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,flush)
Here, second line describes the USB stick I have just plugged in (running Ubuntu). It can be easily recognized from the filesystem (vfat, and the hard drive above uses ext4) and it is mounted on /media/Website (because 'Website' is the stick label that has been used when formatting the stick in vfat). It should be trivial to parse the output and locate the mounted sticks (when formatting, I suggest to give the known labels matching the stick numbers).
If needed, you can put more information into the small file directly on the stick.
You can capture the output through the Process.getOutputStream().
When done, you can safely unmount the sticks before pulling them out:
umount /media/Website
You should check these libraries jUSB and usb2java (they are a little out of date though).
However JNI will allow you to create an interface that interacts with different Operating Systems. This would allow you for cross-platform functionality. I'd look into libUSB (because you are looking for Linux) for a good start!
Hope that helps! :)
I am looking to record movement based on GPS, and plan to record it on the laptop that is in the vehicle. It looks like GlobalSat BU-353 is a good pick, but I am not clear on how to write a program for the actual receive/record. The existing answer seems to be fore Serial, and does not appear to be helpful for USB systems. I could use a USB-to-serial converter with a Serial based GPS device, but I don't like this complexity.
Can you point me a working example? I don't mind using a foreign language (Python perhaps), as long as I can run it on Windows without too much installation/programming headache. Please point me to evidence that this can be done, and how. Preferably a working example that was tested with x USB receiver.
Also I would like information on what the risk of compatibility problems there would be. I would expect that there are many programs out there along with many GPS devices so that a standard has been established (like USB cameras), but is this really the case?
Look up Prolific Technology USB-to-serial converter software. You install it, then your USB device data can be read off of one of Windows COM ports. I'm using the RXTX library to read the com port that is getting my USB data (RXTXcomm.jar).
It's a bit of a pain, because you don't know for sure which COM port is going to be used, it can depend on the order things are plugged into the USB ports on the machine, etc. On some machines, the same physical USB port tends to gravitate towards the same COM port, however, so maybe that will make things predictable enough. Anyway, that's what I'm using to read USB data. At least it's the installed converter, which does not involve code, and everything is java from there.
Yes, there is a defacto standard for the GPS output, the NMEA data strings. All the USB GPS devices I've come across use this. Essentially, as soon as they're turned on (which means as soon as they're plugged in), they start emitting strings of data in the NMEA format. The first letters designate what kind of record is being reported, and the rest of the string is the data. I'm sure some of them also have query capability, etc., but given the nature of GPS programs in general it also works in a lot of cases just to have the device spit out the characters until someone unplugs it. Each string is less than some reasonable maximum number of characters (80? 132? don't remember), and is terminated with some kind of EOL. My code reads them all and only processes the ones it's interested in.
Hope that gets you started.
I want to use a program written in a high level language like Java or Python to talk to a GSM Modem.
I want to be able to tell the modem what number to call and when to call it. I also want to be able to read and send text messages.
I do NOT need to handle voice transmission in either direction of the call.
I'd appreciate recommendations of any applicable libraries and specific modems that are good to start with? I like Java but am willing to try something else.
Thanks
There are a set of relatively standard "AT" commands that can be used for these types of operations - including placing phone calls and sending text messages. Some details around this are at http://www.smssolutions.net/tutorials/gsm/sendsmsat/ and http://www.dreamfabric.com/sms/ (simply first results of a little online searching).
A little more online searching yielded a Java-specific example at http://www.java-samples.com/showtutorial.php?tutorialid=22 .
I had done a little bit of this in Java a number of years back, using the Java Communications API - available at http://www.oracle.com/technetwork/java/index-jsp-141752.html . (My purpose was for interfacing with the phone book on my phone, but this also should have worked with interfacing with the SMS system.)
Almost all modems and (phones which support tethering to your PC) can do this. All modems are equally good at it.There are no starter's modems. Just go through the AT commands specific to your applications and thats it.
I have a rooted Android device with a USB serial device connected. The device shows up as "/dev/ttyUSB5"
I would like to open the serial port and read/write from it. First and foremost... within Android, will it even allow me to read/open /dev/ttyUSB5? Or within the application will I be prohibited from touching /dev ? If I cannot touch anything in /dev, then this is all irrelevant.
However, if I can, then I am wondering if it is possible to import javax.comm so that I can communicate with the serial device.
As of right now, I am able to get around this by spawning a native C application which opens the serial port, then I use a socket to read/write to the serial port in Java. However, it would be much better to do it all in Java.
within Android, will it even allow me to read/open /dev/ttyUSB5? Or within the application will I be prohibited from touching /dev ?
I am unsure if an ordinary SDK application will have rights to this. An application running as root would, if you have a rooted device.
However, if I can, then I am wondering if it is possible to import javax.comm so that I can communicate with the serial device.
Not directly. The build tools don't want you importing java.* and javax.* classes. And, I don't know how quickly javax.comm drops down into native code, even on standard Java.
What you can try is see if Apache Harmony has an implementation of javax.comm, and take a look at it. If it seems like it will fit your needs, you can copy the relevant classes, then refactor them into a new package (e.g., org.gynchis.comm).
However, the best overall answer, if possible, is to try to stick with the ADK and the new USB classes added in API Level 10. I'm not a hardware guy, so I have no idea if what's in there will meet your needs, or if you have a device that is on a new enough Android version to have that support.
Yes you can use the /dev/tty* to access your serial port. Check this out :
serialport-api. I tested it but of course, you need to have your /dev/tty* with the proper rights set. This is in the init.rc file (chmod 0666 /dev/ttyUSB5). If you are working in an embedded system, it's easy to fix. If you want to work on an "off the shelf any tablet on the market", it's more complicated. I believe the only way is to root it. The only drawback of that package is it seems to use a thread that constantly poll the inputstream which makes me believe it is not very CPU/battery efficient. I'm looking for a way to just get something that would wakeup my thread when data is available on the reception side.
Looking for a way to read the unique ID / serial# of a USB thumb drive;
please note that
- I am looking for the value of the manufacturer, not the one Windows allocates for it.
- I need to support multiple OS (Windows, Unix, Mac), thus needs to be a Java solution
The idea is to be able to distinguish between different USB thumb drives.
RXTX is the way to go. In the world of model trains, JMRI (Java Model Railroad Interface) has become very popular. JMRI runs on all platforms (Windows, Linux and Mac) and communicates with a variety of USB based devices (command stations). RXTX is in fact used by JMRI.
You might give a look at the following projects:
javax-usb and jusb. They seem to support Linux and Windows.
Anyway, since USB access in Java requires the use of native libraries, you might not achieve the required portability.
I've never tried using it (it's been on my todo list for a good few months now), but there is the "marge" project on java.net:
http://marge.java.net/
This should let you connect to bluetooth devices (although I don't think it is 100% feature complete, there is demo code on there), and then the ClientDevice class has a "getBluetoothAddress" method which I believe should be unique to that device
http://marge.java.net/javadoc/v06/marge-core/net/java/dev/marge/entity/ClientDevice.html
As I say though, I've never tried it...
I have never investigated this thoroughly, but from memory the RXTX library implementation of the javax.comm packages are supposedly very good and now have USB support.