#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
Go to the source code of this file.
Defines | |
#define | MS_DOREAD "<X>" |
Serial trigger character, tells the scanner "read it". | |
Functions | |
int | MSOpenPort (char *) |
Open a serial port connection to Microscan barcode reader. | |
void | MSClosePort (int) |
Close a barcode reader comm port. | |
int | MSReadPort (int, char *, long) |
Read data from a barcode reader (with timeout),. | |
int | MSSendCommand (int, char *, char *) |
Send a command to the barcode reader. | |
int | MSSendQuery (int, char *, char *, long) |
Query the barcode reader and wait for a reply. | |
int | MSReadBarcode (int, char *, long) |
Read a barcode label and return the label text. | |
int | MSReset (int, char *) |
Reset the barcode reader. |
Header for msutils.c. Defines the function prototypes for the functions implemented in isisutils.c. Should be included explicitly by any program that needs to use these API functions.
|
Serial trigger character, tells the scanner "read it".
|
|
Open a serial port connection to Microscan barcode reader.
For socket communications with a network serial port server, we use INET streams (SOCK_STREAM) with a persistent client connection. This is pretty much standard for most devices on the market. For a regular serial port, we set the attributes to as required by the Microscan MS-3 series barcode scanner's serial interface.
|
|
Close a barcode reader comm port.
|
|
Read data from a barcode reader (with timeout),.
The Microscan MS3 barcode reader must be configured to terminate messages with \r (ASCII 13 = Ctrl+M). Note, If select() is interrupted by Ctrl+C, the read is aborted. |
|
Send a command to the barcode reader.
|
|
Query the barcode reader and wait for a reply.
|
|
Read a barcode label and return the label text.
When the serial trigger character is received by the barcode reader, it turns on its laser/LEDs and scan for a barcode label in the beam. The scanning proceeds until either (a) it successfully decodes the label and it returns the label text or (b) the "no-decode timeout" interval expires and it returns a "NOREAD" message indicating it failed to successfully decode the label (or it could also mean no label was in the beam). As a failsafe, we wait for the communications timeout interval for a reply to the read request. This allows us to exit gracefully in the case of barcode reader malfunction or the reader not being powered on. In general timeout should be larger than the scanner's no-decode timeout, typically twice as long. The factory default no-decode timeout is 2 seconds, so a sensible application communications timeout interval would be 4 seconds.
|
|
Reset the barcode reader.
|