I read fxgovers post on controlling a robot from a serial interface ( https://vexforum.com/newthread.php?do=newthread&f=28 ). I want to be able to control my robot from java on a windows/dell computer. I downloaded the rxtx 2.1-7 ( http://jcontrol.org/download/rxtx_en.html ) to access the serial port. Currently, I have been unable to make the robot move, and the output from the robot is very strange. I uploaded all my code in a zip at [http://homepage.mac.com/nadobson/vex.zip . commands.txt shows the basic commands necessary to run the code. The print easyC project contains the code I put on the microcontroller for debugging. myOutput.txt contains the output from the program. One thing that isn’t obvious from the output is the timing. It prints -1 about 2-3 times a second, and whenever “Hello world” is printed, one of those other random numbers gets printed. I have tons of experience with java, but absolutely none in serial communication. The strangest thing to me is the fact that it prints End of File (-1) even when there will be more data. Also, I changed the length of the message to print, and more numbers were printed every two seconds. All I need is some way of getting java to control the robot. I don’t care if I use a jni library, external command, or even visual basic (Although this would be my last choice) . Any help would be appreciated.](http://homepage.mac.com/nadobson/vex.zip . commands.txt shows the basic commands necessary to run the code. The print easyC project contains the code I put on the microcontroller for debugging. myOutput.txt contains the output from the program. One thing that isn’t obvious from the output is the timing. It prints -1 about 2-3 times a second, and whenever “Hello world” is printed, one of those other random numbers gets printed. I have tons of experience with java, but absolutely none in serial communication. The strangest thing to me is the fact that it prints End of File (-1) even when there will be more data. Also, I changed the length of the message to print, and more numbers were printed every two seconds. All I need is some way of getting java to control the robot. I don’t care if I use a jni library, external command, or even visual basic (Although this would be my last choice) . Any help would be appreciated.)
). I want to be able to control my robot from java on a windows/dell computer. I downloaded the rxtx 2.1-7 ( http://jcontrol.org/download/rxtx_en.html ) to access the serial port. Currently, I have been unable to make the robot move, and the output from the robot is very strange. I uploaded all my code in a zip at http://homepage.mac.com/nadobson/vex.zip . commands.txt shows the basic commands necessary to run the code. The print easyC project contains the code I put on the microcontroller for debugging. myOutput.txt contains the output from the program. One thing that isn’t obvious from the output is the timing. It prints -1 about 2-3 times a second, and whenever “Hello world” is printed, one of those other random numbers gets printed. I have tons of experience with java, but absolutely none in serial communication. The strangest thing to me is the fact that it prints End of File (-1) even when there will be more data. Also, I changed the length of the message to print, and more numbers were printed every two seconds. All I need is some way of getting java to control the robot. I don’t care if I use a jni library, external command, or even visual basic (Although this would be my last choice) . Any help would be appreciated.
First, Is your Com Port working, do you have the correct Parameters, (e.g. Baud Rate, Data Bits, Stop Bits).
Can you get the “Hello World” messages in the Terminal Window of the IFI Downloader Tool??? If this works, then try the Java Program, setting the correct Parameters, it too should receive the “Hello World” messages…
My biggest problem was lack of examples. I thought the SerialPort class was an implementation class, and didn’t both casting my comm-port into it. Once I did that, eclipse popped up with the baud rate methods. I got hello world out instantly. One thing is still confusing me: those EOFs are still coming out. Is this standard serial port interface, which overrides the idea the java InputStreams cannot produce more data after EOF?
Output from on-line code wouldn’t have been as easy to debug as “Hello world\n”.
Another thing: how hard would it be to get a serial interface for a linux/osx computer? The programming cable is probably closed-documentation/proprietary/windows only, but are there other usb/serial converters that would work? (The main reason is that the tux ( Black tie - Wikipedia ) I spray-painted onto my robot really won’t look great with windows sitting ontop.)
Good Question… I don’t do Java Programming, the EOF (End Of File??) might be generated when there is a lack of Serial Data, after a Time-Out period… Look throught the Java JAR File to see if you can locate the EOF you are seeing…
You are quite right… I thought that might be the reason for your EasyC Program, but I was not sure what kind of Debugging you were attempting.
) I spray-painted onto my robot really won’t look great with windows sitting ontop.)We are talking Two things here.
First, Software… I would think very easy, especially if you develop it around the RXTX JAVA Communication API, since it is supported on Windows as well as Linux (and Mac and Solaris).
Second Hardware… The Vex Programmer is closed-documentation/proprietary, but for Serial Communication you only need a RS-232 to TTL converter. Before I got my Programming Kit, I used a B&B 232LPTTL, from my work to test the Serial Port. The 232LPTTL seems to be about $40.00 (USD), but a Vex Programming Hardware is $49.45 (USD).
In java, whenever I have read data from an InputStream (Which represents data coming into the program), the data has been any value between 0-255. When I reach the end of the data (I have read everything out of a file or the other host closed the network connection), reading from the inputstream produces End of File aka EOF aka -1. This input has always meant that no more data is coming. I guess I’ll deal with the strangeness.
Would this somehow be able to connect to usb, or would it require a serial port on the computer? The only nine-pin port I could find on the dell was a male port with the label “|O|O|”. Once again, I have no experience with serial ports.
The on-line code works wonderfully right now. I might look into this later, but a linux laptop running ontop of the robot would be extremely easy to control and upload new programs to.
That is what I expected… The EOF of a Physical File is a Very Real Thing… There must be a Time Out, to decide when the “other host closed the network connection”. Possibly you can send data to the Vex often enough that it keeps responding, and the Java InputStream will NOT think that it is EOF…
Do you own the Vex Programming Cable?? There is Three Parts, the 6 Wire cable, the TTL to RS-232 converter (Programming Module with button) and the USB-to-Serial (RS-232) converter (Adapter). Your Dell seems to have a Built in RS-232 Serial Port (The 9-pin D connector), so you can skip using the USB-to-Serial Adapter, just get a 9-pin Male to Female Serial Cable. DON’T get a NULL MODEM cable, just a Straight Through Serial cable. You then can connect the Programming Module directly to your computer, I use a couple different 6 Foot Serial Cables on each of my computers.
Since RS-232 has been on microcomputers since basically the Beginning, every operating system supports it… You just need to learn the Commands to send, and you can send them from any Operating System (OS)… A simple Text Mode C or C++ Program could be written that only would need to have the Specific Serial Serial Routines called for each OS.