Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
when I try to open com port of my barcode scanner, I get error-
a device barcode scanner attached to the system is not functioning

But when I try to open the same com port with Hercules.exe, it opens and work normaly. Here is my code:

What I have tried:

<pre>Imports System
Imports System.IO.Ports
Public WithEvents sp As New System.IO.Ports.SerialPort
If Me.Parity.SelectedIndex = 0 Then
            sp.Parity = IO.Ports.Parity.Even
        ElseIf Me.Parity.SelectedIndex = 1 Then
            sp.Parity = IO.Ports.Parity.Mark
        ElseIf Me.Parity.SelectedIndex = 2 Then
            sp.Parity = IO.Ports.Parity.None
        ElseIf Me.Parity.SelectedIndex = 3 Then
            sp.Parity = IO.Ports.Parity.Odd
        ElseIf Me.Parity.SelectedIndex = 4 Then
            sp.Parity = IO.Ports.Parity.Space
        End If
        If Me.StopBits.SelectedIndex = 0 Then
            sp.StopBits = IO.Ports.StopBits.None
        ElseIf Me.StopBits.SelectedIndex = 1 Then
            sp.StopBits = IO.Ports.StopBits.One
        ElseIf Me.StopBits.SelectedIndex = 2 Then
            sp.StopBits = IO.Ports.StopBits.OnePointFive
        ElseIf Me.StopBits.SelectedIndex = 3 Then
            sp.StopBits = IO.Ports.StopBits.Two
        End If
        If Me.Handshake.SelectedIndex = 0 Then
            sp.Handshake = IO.Ports.Handshake.None
        ElseIf Me.Handshake.SelectedIndex = 1 Then
            sp.Handshake = IO.Ports.Handshake.RequestToSend
        ElseIf Me.Handshake.SelectedIndex = 2 Then
            sp.Handshake = IO.Ports.Handshake.RequestToSendXOnXOff
        ElseIf Me.Handshake.SelectedIndex = 3 Then
            sp.Handshake = IO.Ports.Handshake.XOnXOff
        End If
        Dim sPort As New IO.Ports.SerialPort(Me.ComboBox1.Text, Me.TextBox1.Text, sp.Parity, Me.DataBits.Text, sp.StopBits)
        sPort.Handshake = sp.Handshake
        sPort.RtsEnable = IIf(Me.CheckBox1.Checked = True, True, False)
        sPort.DtrEnable = IIf(Me.CheckBox2.Checked = True, True, False)
        If sPort.IsOpen = False Then
            sPort.Open()
        End If
Posted
Updated 22-Dec-20 0:07am

1 solution

Try testing with this serial port tool: Basic serial port listening application[^]
 
Share this answer
 
Comments
EdikSail 22-Dec-20 9:03am    
the same error, couse I think your tool is maked the same way I am trying to open com port
RickZeeland 22-Dec-20 9:36am    
Are you sure the barcode scanner is using serial communication? Maybe it's a better idea to go to the manufacturers website / forum and look for more information there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900