473,403 Members | 2,323 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,403 software developers and data experts.

Dual Serial Ports

I have these two subs that are being called on two different timers
threads. It seems that when I get to the DoDualDSIWorkCOM2 that it
keeps passing in the sender and the e as the first serial com and not
the second serial com? How can I fix this?

Public Sub StartWorkerThreadDualDSI1(ByVal gageType As String, ByVal
comPort As Integer)
Dim expectedBaudRate As String = "57600"

Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoDualDSIWorkCOM1
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select
currentSerial = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker.RunWorkerAsync(New Object()
{currentSerial})
Me.tmrBackgroundWorker.Enabled = True
End Sub
Public Sub StartWorkerThreadDualDSI2(ByVal gageType As String,
ByVal comPort As Integer)
Dim expectedBaudRate As String = "57600"

Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker2.DoWork, AddressOf
DoDualDSIWorkCOM2
AddHandler dataBackgroundWorker2.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select

currentSerial2 = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker2.RunWorkerAsync(New Object()
{currentSerial2})
Me.tmrBackgroundWorker2.Enabled = True
End Sub

Private Sub DoDualDSIWorkCOM1(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer

CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM1(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub

Private Sub DoDualDSIWorkCOM2(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer

CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM2(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub
Oct 14 '08 #1
3 1472
"cmdolcet69" <co************@hotmail.comschrieb
>I have these two subs that are being called on two different timers
threads. It seems that when I get to the DoDualDSIWorkCOM2 that it
keeps passing in the sender and the e as the first serial com and not
the second serial com? How can I fix this?

Public Sub StartWorkerThreadDualDSI1(ByVal gageType As String, ByVal
comPort As Integer)
Dim expectedBaudRate As String = "57600"

Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
Also AddressOf DoMuxWork here? Not AddressOf DoDAIWork?
Don't know if this answers the question.
Armin

Oct 14 '08 #2
On Oct 14, 9:38*am, "Armin Zingler" <az.nos...@freenet.dewrote:
"cmdolcet69" <colin_dolce...@hotmail.comschrieb
I have these two subs that are being called on two different timers
threads. It seems that when I get to the DoDualDSIWorkCOM2 that it
keeps passing in the sender and the e as the first serial com and not
the second serial com? How can I fix this?
Public Sub StartWorkerThreadDualDSI1(ByVal gageType As String, ByVal
comPort As Integer)
* * * *Dim expectedBaudRate As String = "57600"
* * * *Select Case gageType
* * * * * *Case "Mux"
* * * * * * * *AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
* * * * * * * *AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
* * * * * * * *expectedBaudRate = "57600"
* * * * * *Case "DAI"
* * * * * * * *AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork

Also AddressOf DoMuxWork here? Not AddressOf DoDAIWork?
Don't know if this answers the question.

Armin
no that work correctly....What is going on is that my
dataBackgroundWorker isn;t changing to dataBackgroundWorker2?
Oct 14 '08 #3
It looks like you should be validating that comPort is 1 in
StartWorkerThreadDualDSI1, and comPort is 2 in StartWorkerThreadDualDSI2.
Also you have not shown GetSerialPortUsed(comPort). I think you should log
some diagnostic messages there.
"cmdolcet69" <co************@hotmail.comwrote in message
news:4c**********************************@v28g2000 hsv.googlegroups.com...
>I have these two subs that are being called on two different timers
threads. It seems that when I get to the DoDualDSIWorkCOM2 that it
keeps passing in the sender and the e as the first serial com and not
the second serial com? How can I fix this?

Public Sub StartWorkerThreadDualDSI1(ByVal gageType As String, ByVal
comPort As Integer)
Dim expectedBaudRate As String = "57600"

Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoDualDSIWorkCOM1
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select
currentSerial = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker.RunWorkerAsync(New Object()
{currentSerial})
Me.tmrBackgroundWorker.Enabled = True
End Sub
Public Sub StartWorkerThreadDualDSI2(ByVal gageType As String,
ByVal comPort As Integer)
Dim expectedBaudRate As String = "57600"

Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker2.DoWork, AddressOf
DoDualDSIWorkCOM2
AddHandler dataBackgroundWorker2.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select

currentSerial2 = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker2.RunWorkerAsync(New Object()
{currentSerial2})
Me.tmrBackgroundWorker2.Enabled = True
End Sub

Private Sub DoDualDSIWorkCOM1(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer

CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM1(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub

Private Sub DoDualDSIWorkCOM2(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer

CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM2(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub
Oct 14 '08 #4

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

Similar topics

4
by: M. Raab | last post by:
i have written an application that utilizes serail ports. In order not to have to reinvent code, I decided to use John Hind's sample code that he presented in MSDN magazine last year (Serial Comm:...
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
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...
1
by: henrycortezwu | last post by:
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...
3
by: Tom Brown | last post by:
Hey people, I've written a python app that r/w eight serial ports to control eight devices using eight threads. This all works very nicely in Linux. I even put a GUI on it using PyQt4. Still...
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...
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: Nasif | last post by:
Currently I am writing a program which sends and receives messages through serial port to a device. I am using C# and Microsoft Visual studio 2005 for windows program. But my problem is when i try...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.