I want to develop a Java application to communicate with the device based on Xilinx Spartan 3E Starter Kit.
The board is connected to my PC with USB-to-COM cable (COM is on the board).
What I need is to send some sequences of bytes to the device and than receive the response from it. It is the same way the serial terminals (hyperterminal, minicom, etc) do.
I'm kinda new to Java, so what classes do i need to implement this?
I'm not exactly sure what you mean by "USB-to-COM". Do you mean that the USB connection is accessible as an RS232 serial port on the PC (aka COM port on windows) ?
If so, you should look at the RXTX library here: http://rxtx.qbang.org . It provides support for Java serial port communications on a number of platforms. If you are new to Java, you might not find serial port programming the easiest way to learn Java, but the examples included with RXTX should be clear otherwise.
Related
I add some detail to my question.
I receive on my Xbee device a flow of GPS coordinates but I'm unable to read and stock these data on a buffer.
My Xbee device is connected to my laptop on a usb serial port, that's why I want to create a program java to read and use my data flow sending by the serial port.
I'm searching on internet some code example or tutorials , without enought advices for my understanding, or I just find some dead projects.
I found that it's possible to use jssc library or javax.comm (but I can't download the javax.zip on sun). Do you know an other better USB API ? Could you help me to understand how I can manage to read and stock my Flow of GPS cordinate ?
Forget abut USB, it acts as transparent bridge. What you need is a way to read from the serial port. javax.comm is not (officially) available any more. I have been successfull dealing with the arduino serial port with the RXTX library.
First make sure you see the serial port on your dev machine. This might require to install a driver. Then use a terminal program to connect to the serial port.
Once this is working go on and get RXTX working.
Just in case: You can have only one connection at a time. Make sure that only one of IDE, terminal programm and RXTX is connecting to the serial port at the same time.
I am looking for a library interface to allow me to check what has been posted to a serial port.
To be more precise, I am using a teensy 2.0 to interface with a button. I want to run code within the program without simulating a key press, and thought that printing something to serial would be a easy way to connect to the Java program.
I've once used RxTx library to establish a communication channel between PC and an external MCU via USB port. Worked fine : )
For my self I'm using the jssc library to communicate with the serial port and it's working fine and I here it'll stay that way here's the link : http://code.google.com/p/java-simple-serial-connector/downloads/list
Is it possible to send data from a USB port to a RS232 using java code?
The RS232 is a port on FPGA board and the computer(via USB) is used to send these data.
You can send data to a serial port from Java using a library like PureJavacomm, or RXTX. The latter is a bit of the de facto standard for Java, but has some quircks, while the former is actively developed and seems to work on all current "major" platforms (personal experience).
I need to send some commands using the wireless network from an iPhone application to an Android application. I thought a possible way would be to send the commands as strings over TCP (SOAP seemed a better solution, but it seems some libraries would be necessary and it is not necessary). Is there anyone out there who can address me to some documents or some place to start this kind of applications?
Thanks!
The simple answer to this question is that you need to listen on a specific port number by opening a Server Socket on the Android side, and from the client side (iPhone) open a socket connection towards the Android's IP address and port.
Luckily sockets are a pretty standard thing nowadays and behave typically the same across operating systems, that is Linux, Windows, Mac OSX, and iPhone iOS, Android and Symbian.
The only difference you have is which programming language you need to use. On Android you have to use Java. So if an Android application is waiting for the connection your application needs to open a ServerSocket and listen of incoming connections.
From the iPhone part, your application needs to be developed in Objective C. Nothing fundamentally different, but the programming language is different.
How do I make a J2ME Midlet to communicate with a java program or some application on the pc through the cable connected?
Incredible_Honk is almost right. The key is to use the (standard) system property "microedition.commports". This provides a comma delimited list of the com ports which are available to your application. To open a connection use CommConnection as follows:
CommConnection con = (CommConnection) Connector.open("com:<commport name>");
Usually this will provide access to a USB serial connection, possibly also infrared if available. Iterate through each one to see which one corresponds to the connection you're looking for.
On Windows at least, you will need to install the correct drivers for your handset first. This will then allow you to open a serial connection and communicate with the application.
There is no general way of doing this. It hardly depends on the capabilities of the mobil. Might be that there is some vendor API giving you special access to USB, but I'm not aware of any.
Some phones support communication via serial port connections.
Take a look at the javax.microedition.io.CommConnection interface for more information.
Sonyericsson phones offer a way to debug your midlet on the device and get the console messages back through the cable.