Jump to content

Recommended Posts

Posted

Hi all, Im scanning barcode with my Barcode Scanner with COM Port (Honeywell N56X0 - if it helps)  and I need to print scanner output into a .txt file. I've made code, that connects to the scanner, but can't find a function to print/save output form a scanner...

It's quite hard for me to understand functions for COM from this .au3 files from this thread, because Im a beginner in autoit and these descriptions are hard to read for me. I have also an error, that says "Parameter is incorrect" when I run script and scanner is running, but I have "@ScriptLineNumber" that does not show me, where error is hiding...

And this is my code:

#include <CommAPIConstants.au3>
#include <CommAPI.au3>
#include <CommAPIHelper.au3>
#include <CommUtilities.au3>
#include <CommInterface.au3>

#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

Main()

Func Main()
    Local $sResult = COM()
    Switch @error
        Case 0
            MsgBox(64, "Result", $sResult)
        Case -1
            MsgBox(32, "Error", _WinAPI_GetLastErrorMessage())
        Case -2
            MsgBox(32, "Timeout", $sResult)
        Case Else
            MsgBox(32, "Error", "Error " & @error & " in line " & @ScriptLineNumber)
    EndSwitch
EndFunc

Func COM()
    Local Const $iPort = 1
    Local Const $iBaud = 9600
    Local Const $iParity = 0
    Local Const $iByteSize = 8
    Local Const $iStopBits = 1
    Local Const $sCommand = "Command" & @CRLF

    Local $hFile = _CommAPI_OpenCOMPort($iPort, $iBaud, $iParity, $iByteSize, $iStopBits)
    If @error Then Return SetError(@error, @ScriptLineNumber)

    _CommAPI_ClearCommError($hFile)
    If @error Then Return SetError(@error, @ScriptLineNumber)
    _CommAPI_PurgeComm($hFile)
    If @error Then Return SetError(@error, @ScriptLineNumber)

    _CommAPI_TransmitString($hFile, $sCommand)
    If @error Then Return SetError(@error, @ScriptLineNumber)

    Local $sResult = _CommAPI_ReceiveString($hFile, 5000)
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

    _CommAPI_ClosePort($hFile)
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

    Return $sResult
EndFunc

And I want to connect to a scanner, scan Barcode then save this output to a .txt file on my PC.

Posted
17 hours ago, FrancescoDiMuro said:

@Gonz4les

Are you able to read data from the scanner? :)

Ummm... I can read data from using i.e. PuTTY, but in the other way, I don't think, that I have proper tools nor script for this to see actual data from scanner.

Posted

Ok..looking at the manual, if connecting across COM (RS-232) your baud should be 115200. Once its connected, do you have a good bar code to scan to see if you get one beep? 

Just a side note..You really need the N56XX Decode Engine manual to accomplish what your attempting. And even then, it reads horribly so you will be putting a good bit of time in learning its coding scheme.

Posted

Don't most barcode scanners work like a keyboard, and usually directly input the characters scanned?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted
On 9/13/2019 at 5:13 PM, Fractured said:

Ok..looking at the manual, if connecting across COM (RS-232) your baud should be 115200. Once its connected, do you have a good bar code to scan to see if you get one beep? 

Just a side note..You really need the N56XX Decode Engine manual to accomplish what your attempting. And even then, it reads horribly so you will be putting a good bit of time in learning its coding scheme.

Ah yes, Im working on 9600 BAUD here, because I got it from work for my own use (not commercial nor for work purposes), so I've decided to stay with it. And yes, I got good barcode and it's beeping only once, so it's good :) And if it will be the case, that reading it hard, so... I guess... it will be hella difficult then 😅

But thanks for guiding me, I'll search for Decoding Engine :)

Posted
On 9/13/2019 at 5:44 PM, BrewManNH said:

Don't most barcode scanners work like a keyboard, and usually directly input the characters scanned?

I've heard the same, some time ago... I will try to look for some functions for keyboard and try to 'catch' Barcode Sanner input from it

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...