PDA

View Full Version : Communication problem between javacs and Basic Stamp(sx) via RS232



J.We
08-04-2005, 07:44 PM
I am trying to send commands from a java program (using javacs.comm, java extension communications) to my BSsx. The bauds are off course set to the same on both side. 8-bits, no parity, 9600 b-rate and so on. I have also tried on slower baud rates..

The BSsx is programmed only to listen to the SERIN and GOSUB (drive a stepper motor via Little Step U), when receiving any data (one byte).
The java-program is programmed to locate the COM1, open it, and send one byte data, hold the port open five seconds, and then close the port.

The BSsx program work fine when using a terminal–program (RealTerm), but not with the java-program, and the java program work fine separate to.

Why is my system not working?

Please see attached files, TestMain.java , SerialIO.java (java-files) and TestMain.bsx (basic stamp-file).

Please, if anyone have done anything like this, please give me some advise! If anyone have any type of suggestion on haw to move on, don’t hesitate to reply this.

Regards//jw

Jon Williams
08-04-2005, 08:12 PM
The problem has to do -- I believe -- with what your Java program is doing to the DTR line; that line connects to the Stamp's ATN pin to cause a reset. Check the docs to see if you can change the DTR state.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Dave T
06-23-2006, 12:52 AM
I am also interested in the resolution of this problem since I am also trying to use java libraries to communicate. So far the solution has been to have two serial cables--one with pin 4 removed physically--and one normal. I have to swap the cables each time I want to switch from programming the basic stamp to running my PC program to communicate with the stamp. I know there have been suggestions to insert a jumper or switch, but I wish there was a way to do it in software (i.e. in the Java code). i bet someone, somewhere has resolved this issue and I just need to find where the explanation is!!

allanlane5
06-23-2006, 02:39 AM
Don't close the port in Java. When you open the port, the PC hardware turns 'on' DTR and holds it on. This 'blips' the ATN line (due to a couple of capacitors) which resets the BS2. If you don't close the port, you won't 'blip' the ATN line again.

I don't know if Java gives you the option of opening the port without letting the DTR line transition.

Dave T
06-23-2006, 06:54 AM
Thank you for taking an interest in this issue. I am testing, but don't quite understand why not closing the port could help since all communication problems or successes are already done by the time the port would ordinarily be closed anyway. I don't yet see how to prevent DTR from being affected by opening the port.