[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

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!
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

Open in new window

untitled.bmp
0
Navicerts
Asked:
Navicerts
1 Solution
 
NavicertsAuthor Commented:
I found what was using it.  

1) Disable the serial port via device manager.
2) Re-boot
3) wait for error message (in this case from ActiveSync which was using a USB port but also taking the com for some reason).
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now