473,385 Members | 1,587 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,385 software developers and data experts.

Help needed opening serial port in VB.NET

I am having trouble with "ACCESS DENIED" error messages in a VB.NET 2003
application when attempting to open
serial comms ports.

The application has 2 ports that connect via serial cable to 2 different
hardware devices to transfer binary data to the application. The setup
screen enables the user to select COM1 -- COM8 via combo boax for each port.
Then they click "Apply" to open the ports.

The code that I have written to open the ports is shown below. The code
works if you select valid ports first time but if you either select invalid
ports or the same port as previously selected you get the ACCESS DENIED
error.

I have attempted to ensure the port is closed before changing the
parameters. Also, the port gets closed if there is an error.

Any help much appreciated, Thanks.

If MasterPort.IsOpen Then MasterPort.Close()
While MasterPort.IsOpen
End While

MasterPort.Options = New Sax.Communications.SerialOptions(MasterPortname,
19200, _Sax.Communications.Parity.None, 8,
_Sax.Communications.CommStopBits.One, False, True, False, False, True, True)

Try
MasterPort.Open()
Catch exception As Exception
MsgBox( "Problem with Master Port : " & exception.message)
If MasterPort.IsOpen Then MasterPort.Close()
End Try

If HandheldPort.IsOpen Then HandheldPort.Close()
While HandheldPort.IsOpen
End While

HandheldPort.Options = New Sax.Communications.SerialOptions(MasterPortname,
19200, _Sax.Communications.Parity.None, 8,
_Sax.Communications.CommStopBits.One, False, True, False, False, True, True)

Try
HandheldPort.Open()
Catch exception As Exception
MsgBox( "Problem with Handheld Port : " & exception.message)
If HandheldPort.IsOpen Then HandheldPort.Close()
End Try
Nov 21 '05 #1
0 2460

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

Similar topics

2
by: Tomislav Lepusic | last post by:
Hello, I don't know if this is the right group (I'm more in Perl, know nothing about Python), so if you can help me thanks, if not, sorry to bother you. I'm working on my student project and...
2
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. ...
0
by: Srinivasa Ra via .NET 247 | last post by:
(Type your message here) I am writing an application that does lot of read/write's withcomputer's serial port. The application as a whole is workingfine. Current Approach: I have a Timer that...
1
by: David | last post by:
I have written an application in VB.NET 2003 that uses the SAX serial component for RS232 communications with hardware. The program sets up 2 serial ports so that it can talk to 2 different...
4
by: Dave Harry | last post by:
I found the RS232 class from MS's 101 VB samples. Writing to the port works fine. (I've got hyperterminal on the other comm port and a crossover cable between COM1 and COM2) The port is opened...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
1
by: laura salhuana | last post by:
Hi: I am trying to write a serial communication GUI application. My application has the following specifications. When I set my board up in hyperterminal I do the following set up: bits per...
3
by: TC | last post by:
Hey All, I have some classes that I recently built for a website which uses the HttpWebRequest & HttpWebResponse objects from the System.Net namespace. Basically, the classes rap submitted data...
0
by: Wanxi | last post by:
Hi everyone, I am testing one of the example -> <UsingTheSerialPort> at VB101SamplesBCL2. But there are some error which i don't know how to edit. I found some post that having the same problem...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.