How can i make my RS232 cable setup so that from Java, i can turn on and off the 12voltage lights? [closed]

StackOverflow https://stackoverflow.com/questions/7437799

Pregunta

I have a 12volt light + Battery.

When i connect + and - the light turns on. Now how can connect that + and - wire to my RS232 cable which is connected to my Java application. And from Java button press, i want to turn the light on instead of doing it by my hands.

Please advise how i can do this real world setup?

¿Fue útil?

Solución

You'll need a device on the other end of the RS-232 cable to convert a command to turn on the light into the action of applying power to it. A serial bus isn't intended to control discrete outputs (barring any silly tricks).

Something like this 8-channel RS-232 relay board should work just fine.

Otros consejos

There is a hardware piece of this puzzle that is still to be solved, but then there is a software piece too. Since this is a software development site (and Nick already mentioned the hardware piece), I'm going to assume your question is about the software piece.

Java does NOT have RS232 support built in. You can write a library to do this using JNI, or you can use one of the many out there already. I suggest the RXTX. I've written a simple java interface to several RS232 devices using the gnu.io.* libraries in RXTX and it's not too hard, though often requires careful testing, a very good reference to the communication spec the hardware vendor is using, and some manual dexterity if you're wiring things yourself.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top