| | |
serial Port programming
![]() |
•
•
Join Date: Dec 2004
Posts: 489
Reputation:
Solved Threads: 5
Hello there,
I'm trying to emulate a Bluetooth connection via coding the serial port. COM6 on my machine is an outgoing connection over bluetooth... So I'm mocked up the following code:
however the phone notices the connection and establishes it, but only for a second or 2... it doesn't get as far as sending the data.... Can anyone point me in a direction as to whats wrong and why?
I'm trying to emulate a Bluetooth connection via coding the serial port. COM6 on my machine is an outgoing connection over bluetooth... So I'm mocked up the following code:
Java Syntax (Toggle Plain Text)
package btserver1; import gnu.io.CommDriver; import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.SerialPort; import java.io.*; public class Main { static String dataFile =null; /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) { try { CommPortIdentifier pid=CommPortIdentifier.getPortIdentifier("COM4"); SerialPort sPort=(SerialPort) pid.open("Serial Comm Testing",100); sPort.disableReceiveFraming(); sPort.disableReceiveThreshold(); sPort.setSerialPortParams(115200 , SerialPort.DATABITS_8, SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); sPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); //sPort.enableReceiveTimeout(1000); InputStream is= sPort.getInputStream(); OutputStream os= sPort.getOutputStream(); String str="11A41"; int i =13; //char(13) is used for carriage return char extChar=(char) i; str=str + extChar; byte[] outByte=str.getBytes(); os.write(outByte); sPort.close(); } catch (Exception ex){ex.printStackTrace();} } }
however the phone notices the connection and establishes it, but only for a second or 2... it doesn't get as far as sending the data.... Can anyone point me in a direction as to whats wrong and why?
![]() |
Similar Threads
- Send data on a serial port (C++)
- any way to communicate with Serial PORT using JavaScript (JSP)
- need help convert c++ to vb6 serial port (Visual Basic 4 / 5 / 6)
- Can read or write to serial port simultaneously (C)
- Serial Port (C++)
- obtaining data info from device connected on com1 port (C++)
- need help about printer port programming through C (C)
- Serial Port (C++)
Other Threads in the Java Forum
- Previous Thread: JSP vs PHP
- Next Thread: remove the path when printing
| Thread Tools | Search this Thread |
addball android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) button card class classes client code collision columns component constructor crashcourse css database designadrawingapplicationusingjavajslider draw eclipse ee error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image integration intellij j2me java javaarraylist javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia jvm linux loan loop method migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle phone physics plazmic print problem program programming project radio scanner server service set sharepoint smart sms smsspam software sql subclass support swing textfield threads tree trolltech unlimited utility windows





