Intermec ck1 Reference Guide
Chapter 3 — Scanner Support
130
CK1 SDK Programmer’s Reference Manual
Example Code
This section provides example code for scanning bar code labels.
Scanning Bar Code Labels
The program uses TFmBarcodeReaderCreate to create the graphic
interface. The main function starts the connection to the hamster daemon
to enable the bar code and get the bar code that is waiting to be read. It
uses otk_app_register_fd, which has GrRegisterFd in Nano-X check that
there is a bar code to read. After getting the typed bar code from the
daemon (OnScanned), it changes the label to display the bar code name
and changes the content of the entry. The application redirects the event
handler of the main form to check if a key is pressed (grab_event). Because
it uses tpt_Scanner, the application should read the bar code from the
daemon itself. If it uses tpt_ScanKey, the daemon generates keyboard
events to key in the bar code scanned that gets more time to key in.
interface. The main function starts the connection to the hamster daemon
to enable the bar code and get the bar code that is waiting to be read. It
uses otk_app_register_fd, which has GrRegisterFd in Nano-X check that
there is a bar code to read. After getting the typed bar code from the
daemon (OnScanned), it changes the label to display the bar code name
and changes the content of the entry. The application redirects the event
handler of the main form to check if a key is pressed (grab_event). Because
it uses tpt_Scanner, the application should read the bar code from the
daemon itself. If it uses tpt_ScanKey, the daemon generates keyboard
events to key in the bar code scanned that gets more time to key in.
Scanning Bar Code Labels Example
Filename: main.c
Using October widget to scan the bar codes using tpt_Scanner.
#include <otkapplication.h>
#include <otkcontrol.h>
#include <otkentry.h>
#include <otklabel.h>
#include <otktitlebar.h>
#include <ScClient.h>
#include <eslib_buzzer.h>
#include <eslib_led.h>
typedef struct
{
OtkControl cntlMain;
OtkLabel lblType;
OtkEntry edtBarcode;
OtkTitleBar tbMain;
unsigned char textBuffer[256];
} TFmBarcodeReader;
static int Hamster_Handle = -1;
static void TFmBarcodeReaderCreate(TFmBarcodeReader*);
static TFmBarcodeReader fmBarcodeReader;
#undef ENABLE_NLS
#ifdef ENABLE_NLS
#define _(x) gettext(x);
#else
#define _(x) (x)
#endif
#define N_(x) (x)
static OtkWidgetEventHandler prev_handler = NULL;
Using October widget to scan the bar codes using tpt_Scanner.
#include <otkapplication.h>
#include <otkcontrol.h>
#include <otkentry.h>
#include <otklabel.h>
#include <otktitlebar.h>
#include <ScClient.h>
#include <eslib_buzzer.h>
#include <eslib_led.h>
typedef struct
{
OtkControl cntlMain;
OtkLabel lblType;
OtkEntry edtBarcode;
OtkTitleBar tbMain;
unsigned char textBuffer[256];
} TFmBarcodeReader;
static int Hamster_Handle = -1;
static void TFmBarcodeReaderCreate(TFmBarcodeReader*);
static TFmBarcodeReader fmBarcodeReader;
#undef ENABLE_NLS
#ifdef ENABLE_NLS
#define _(x) gettext(x);
#else
#define _(x) (x)
#endif
#define N_(x) (x)
static OtkWidgetEventHandler prev_handler = NULL;