| | |
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 |
6 actuate android api applet application applications array arrays automation balls bank binary bluetooth bold business c++ chat class clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse educational error file formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide ideas image infinite ingres integer intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans openjavafx parameter php problem program programming project recursion repositories scanner scrollbar sell server set sms sort sorting sql sqlserver state storm string sun superclass swing swt threads tree websites windows





