Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

bigracefan (Programmer)
17 Feb 04 11:39
I'm having an interesting problem with my computer/barcode scanner.  I'm trying out new barcode scanners from Symbol (model 2204).  My usual code doesn't work with this new model.  You need to connect to the scanner then fire the trigger.  Here is the code that is used:
Using SSIConnect.ocx

Private Sub Form_Load()
Dim Status As Integer
    
    Status = -1
    
    While Status = -1
        With frmMessage
            .Message = "Connecting to Scanner....."
            .Show 1
        End With
       Status = SSIConnect1.ConnectComPort
    Wend

    SSIConnect1.SendCommand (ssiSWTriggerPull)
    
End Sub
'-------------------------------------------
Private Sub SSIConnect1_DecodeDataAvailable(ByVal length As Long)
Dim PNum As Long
Dim PVal As Long
Dim Status As Integer
    
    tmrScan.Enabled = False
    
    Status = -1
    While Status <> 0
        Status = SSIConnect1.SendCommand(ssiSWTriggerRelease)
    Wend
    
    If length > 0 Then
        NumDataChars = SSIConnect1.GetDecodeData(DecodeData, vbString, SSIcodetype)
        If IsEmpty(DecodeData) = False Then
            If IsNumeric(DecodeData) Then
                ScanInfo = DecodeData
                tmrScan.Enabled = False
                Call cmdLogon_Click
            Else
                Status = -1
        
                While Status <> 0
                    Status = SSIConnect1.SendCommand(ssiSWTriggerPull)
                Wend
            End If
        Else
            Status = -1
        
            While Status <> 0
                Status = SSIConnect1.SendCommand(ssiSWTriggerPull)
            Wend
        End If
    Else
        Status = -1
        
        While Status <> 0
            Status = SSIConnect1.SendCommand(ssiSWTriggerPull)
        Wend
    End If
    
End Sub
'--------------------------------------------------------

The problem I'm having is that at some point the scanners starts behaving strangly.  The code above activates the scanner and continues scanning until it sees something. I can run the application for a while and then the scanner does one scan then stops.  Closing the application and recycling the power on the scanner doesn't cure this.   I need to reboot the computer to get the comm port back.  I there a way to make the comm port think that the computer has rebooted?
Dashley (Programmer)
17 Feb 04 16:10
You may have already tried this but did closing the port and reopening it help

mscomm1.PortOpen=False

mscomm1.PortOpen=True
bigracefan (Programmer)
17 Feb 04 16:51
Yes, this was the first thing I tried.  Thanks for the input.  I'm guessing this control automatically times out. Once it's timed out, that's it. Only a reboot will get you back on track.  With this scanner you don't actually use a mscomm1 control. You use the SSIconnect1 control.  It doesn't have the same functionality as the mscomm control.
TheTuna (Programmer)
17 Feb 04 23:23
Is there a close method or a reset method for that control?
Is there an error event available?

No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!  

Ever feel like you're banging your head against a tree?  I did, so I cut down the tree.

TheTuna (Programmer)
18 Feb 04 22:58
See if this might help... I was scanning the API list and stumbled upon PurgeComm and remembered your proplem.  I've never used this, so I did a quick search on Yahoo and found the following information about it:


Public Declare Function PurgeComm Lib "kernel32" Alias "PurgeComm" (ByVal hFile As Long, ByVal dwFlags As Long) As Long

hFile - descriptor of the open communication port file;

dwFlags - task to be performed.

This function can perform two tasks: clear the I/O queue in the driver or finish all the I/O operations. The tasks to be performed are specified by the following parameters:

PURGE_TXABORT — immediately stops all write operations even if they are not finished;
PURGE_RXABORT — immediately stops all read operations even if they are not finished;
PURGE_TXCLEAR — clears the out -queue in the driver;
PURGE_RXCLEAR — clears the in -queue in the driver.
Note

These values can be combined with the help of bitwise OR operation. It is recommended to clear the buffers when I/O errors occur and after the work with the port is finished.



No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!  

Ever feel like you're banging your head against a tree?  I did, so I cut down the tree.

TheTuna (Programmer)
20 Feb 04 20:36
Did you find the solution you were looking for?

No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!  

Ever feel like you're banging your head against a tree?  I did, so I cut down the tree.

bigracefan (Programmer)
25 Feb 04 16:54
According to MS this is for Windows ME/95/95. I'm running XP.
koala15 (Programmer)
25 Feb 04 18:01
Have you tried it? - it will work on NT/2K and XP as well as the other 32 bit MS OS's.

"Life is full of learning, and then there is wisdom"

bigracefan (Programmer)
26 Feb 04 18:27
Hey K,

  No I didn't try it. After looking at the MicroSoft documentation I didn't pursue it.  How do you use it?  I've got an ocx componant that runs a Symbol scanner off of Comm2.  

Public Declare Function PurgeComm Lib "kernel32" Alias "PurgeComm" (ByVal hFile As Long, ByVal dwFlags As Long) As Long

hFile - descriptor of the open communication port file;

dwFlags - task to be performed.
PURGE_TXABORT — immediately stops all write operations even if they are not finished;
PURGE_RXABORT — immediately stops all read operations even if they are not finished;
PURGE_TXCLEAR — clears the out -queue in the driver;
PURGE_RXCLEAR — clears the in -queue in the driver.
Note

I'm not that good using the old kernal32.  How do I define the dwflags?  What is the hFile if I want to clear comm2?

Thanks.
TheTuna (Programmer)
26 Feb 04 20:37
Use your favorite search engine and look for PurgeComm... there should be more than a few sites that detail the useage requirements.

Good luck!

No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!  

Ever feel like you're banging your head against a tree?  I did, so I cut down the tree.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close