Navicerts
asked on
Com1 Communication
Hello,
I have some scales that I am trying to connect to a PC via COM1 and send data back and forth. Fortunately when I first created the program COM1 was available and I could see that my code worked, I opened the port sent a "print command" to the scale and received a weight on the PC. However, the next day I was getting an error message that said "not authorized to use COM1", or something to that effect. After some reading I found that it could be mouse drives taking up the port (even though the mouse is USB) but I never got it to work. The next day I re-boot and get a new error message "Com1 already open". It could be the mouse still, maybe a modem - I don't know.
Is there some way to either reserve this port for the scale through windows or at least find out what program is using the port and blocking me out? I can go into system > hardware and see COM1 but I am not given any indication of what is utilizing it.
Any ideas?
Thanks!
I have some scales that I am trying to connect to a PC via COM1 and send data back and forth. Fortunately when I first created the program COM1 was available and I could see that my code worked, I opened the port sent a "print command" to the scale and received a weight on the PC. However, the next day I was getting an error message that said "not authorized to use COM1", or something to that effect. After some reading I found that it could be mouse drives taking up the port (even though the mouse is USB) but I never got it to work. The next day I re-boot and get a new error message "Com1 already open". It could be the mouse still, maybe a modem - I don't know.
Is there some way to either reserve this port for the scale through windows or at least find out what program is using the port and blocking me out? I can go into system > hardware and see COM1 but I am not given any indication of what is utilizing it.
Any ideas?
Thanks!
Imports System
Imports System.Text
Imports System.Drawing
Imports System.IO.Ports
Imports System.Windows.Forms
Imports System.IO.Ports.SerialPort
Public Class Main
Public Delegate Sub myDelegate1()
Private Sub DataReceived1(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SartoriusQC.DataReceived
ScaleOutPut.Invoke(New myDelegate1(AddressOf UpdateScaleOutPut), New Object() {})
End Sub
Public Sub UpdateScaleOutPut()
MsgBox("Updated.")
Try
With ScaleOutPut
.Items.Add(SartoriusQC.ReadExisting)
End With
Catch ex As Exception
End Try
End Sub
Private Sub ExitApp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitApp.Click
If SartoriusQC.IsOpen Then
SartoriusQC.Close()
End If
Try
SartoriusQC.Close()
Catch ex As Exception
End Try
Application.Exit()
End Sub
Private Sub Openbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Openbtn.Click
If SartoriusQC.IsOpen Then
SartoriusQC.Close()
End If
Try
SartoriusQC.Open()
Catch ex As Exception
End Try
End Sub
Private Sub Closebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Closebtn.Click
If SartoriusQC.IsOpen Then
SartoriusQC.Close()
End If
Try
SartoriusQC.Close()
Catch ex As Exception
End Try
End Sub
Private Sub DataXferbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataXferbtn.Click
Try
SartoriusQC.Write(Chr(27) & "P" & Chr(13) & Chr(10))
Catch ex As Exception
End Try
End Sub
End Class
untitled.bmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.