473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Virtual Serial Port Bluetooth System.IO.Ports

Hi All,
I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth
Serial Port") using VS2005 System.IO.Ports.

When I ran the ff code below here's what happens.
1) VS2005 Compiles w/o errors
2) My Nokia 6600 prompted me the message "Accept Connection request
from DEMON?"
note: DEMON is my computers name.
3) Using my Nokia 6600, I hit the button that refers to the "Yes"
command.
4) Error prompted at port.Open(), saying that "The network connection
was gracefully closed."

note also that : "Passkey" is enabled on my cellphone/computer and was
entered correctly when asked.

i also so somewhere on the net that baudrate will be ignored for
bluetooth driver will be the one to autodiscover and adjust to whats
the real value? is this true?

i wish to send jpg images to my cellphone using my serial connection,
is this possible? sending out bytes of data?

I've tried using http://32feet.net/ but it proves to be difficult using
OBEX and on the fly sample projects failed to compile on VS2005.

serial connection using virtual serial ports and VS2005's new Serial
Port feature seems the easiest way to go.

Hope anyone can help out on this. I'll be very much gratefull on any
clues/leads/solutions that you may give.

Many Thanks,
Henry :)

Code Used
----------------------------------------------------------------------------------------------------
Imports System.IO.Ports

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim port As SerialPort = New SerialPort("COM19", 9600, Parity.None, 8,
StopBits.One)
port.Open()
port.Write("Hello World")
port.Close()
End Sub
----------------------------------------------------------------------------------------------------

Stack Trace
----------------------------------------------------------------------------------------------------
System.IO.IOException was unhandled
Message="The network connection was gracefully closed.
"
Source="System"
StackTrace:
at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode,
String str)
at System.IO.Ports.SerialStream.InitializeDCB(Int32 baudRate,
Parity parity, Int32 dataBits, StopBits stopBits, Boolean discardNull)
at System.IO.Ports.SerialStream..ctor(String portName, Int32
baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32
readTimeout, Int32 writeTimeout, Handshake handshake, Boolean
dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
at System.IO.Ports.SerialPort.Open()
at WindowsApplication1.Form1.SendSampleData() in E:\My
Documents\Visual Studio 2005\Projects\Bluetooth\Bluetooth\Form1.vb:line
17
at WindowsApplication1.Form1.Button1_Click(Object sender,
EventArgs e) in E:\My Documents\Visual Studio
2005\Projects\Bluetooth\Bluetooth\Form1.vb:line 76
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext
context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
----------------------------------------------------------------------------------------------------

Jan 8 '06 #1
1 10857
Hi Henry,

(You sent me email about this offline, but you didn't say you were using VS
2005, so I assumed that you were using VS 2003.)

Personally, I HATE using the Constructor to configure the serial object.
What I do is to create a simple object (New), then use the individual
properties, such as BaudRate, Parity, DataBits, StopBits, and PortName.
This (IMO) makes the code more readable (sure, a little more verbose, but
you get what you pay for).

Just use the GetPortNames method to see what port names that the serial port
object likes. For example, here is some code that I use to populate a
listbox:

Dim PortNames() As String =

..SerialPort.GetPortNames()

For I = PortNames.Length - 1 To 0 Step -1

lstCommPort.Items.Add(PortNames(I))

Next

As I mentioned in my email reply, I'd need your BT hardware in order to try
to figure out what is going on. It may be easy, it may be hard. Sorry.
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition, ISBN 1-890422-28-2, Mabry Publishing (391 pages, includes CD-ROM).
July 2004.
See www.hardandsoftware.net for details and contact information.
Jan 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JokeR | last post by:
Hi! I've been doing loads of work using RXTXcomm java class lately, and it was used for communication with serial port (the real one, ttyS0) Now, I have a big problem (at least that's what it...
0
by: Helge Jensen | last post by:
Having posted in microsoft.public.dotnet.framework.sdk and microsoft.public.dotnet.framework.wmi without receiving any response, I posthere on the off-chance that someone who isn't following those...
4
by: Frank | last post by:
Hello, how to get information about all serial ports in the PC? I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available...
2
by: Hugh Janus | last post by:
I am trying to receive GPS data into a pocket PC 5.0. I am using the device emulator. The main PC has a bluetooth dongle connected and is bonded with the bluetooth GPS transmitter to COM8. In...
5
by: LongBow | last post by:
Hello, Is there a way, in .NET, to determine what are the avialable Serial (Communications) Ports on a Windows OS and is there a way to determine that port isn't being use other than attempting...
2
by: joaquimfpinto | last post by:
Dear All, I made an app in c# that uses several serial ports. For the serial ports I use a pnp Sunix board, some with 8 serial ports other with 4 or even 2 serial ports. Whenever I use the...
2
by: colin | last post by:
Hi, Im having a tiresome amount of trouble with using a bluetooth serial link. The receiving end is a bluetooth-rs232 module conected to my embeded system. The PC has a little usb bluetooth...
3
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to...
2
by: Dave Harry | last post by:
I'm using the following code to determine the available serial ports: ComboBoxPort.Items.Clear() For Each sp As String In My.Computer.Ports.SerialPortNames ComboBoxPort.Items.Add(sp) Next It...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.