OutputStream problem

Hi,

I am using java comm API to send some cmd to a bluetooth device which is working fine if I turn on the device before I send the cmd. But if I try to send out cmd before the device has been turned on. The program would be stuck at g_os.write(sendCMD);

code:

CommPortIdentifier g_portId = CommPortIdentifier.getPortIdentifier(portname);

g_sPort = (SerialPort)g_portId.open("test", 30000);

g_os = g_sPort.getOutputStream();

g_os.write(CMD);

There isn't any error or exception message. Any one has any idea why this problem is caused and how to fix it?

Any help is appreciated.

Thanks

[646 byte] By [cutsethuanga] at [2007-11-27 7:44:18]
# 1
Does adding a g_os.flush();after the write help?
xiarcela at 2007-7-12 19:24:57 > top of Java-index,Java Essentials,Java Programming...
# 2
> Does adding a > > g_os.flush();> > after the write help?Seeing as it hangs on the write, it may take the OP a while to respond :-)
Hippolytea at 2007-7-12 19:24:57 > top of Java-index,Java Essentials,Java Programming...