Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to Code for a Barcode Scanner

Status
Not open for further replies.

AbidingDude

Programmer
Oct 7, 2012
74
0
0
US
I probably should have posted this here initially. But I posted it in the C language section instead:

A while back, my brother found some abandoned items at his work place. One of the things he found was a barcode scanner. With me being more into computers and electronics than him, he figured I might have more use for it.

Apparently it's a SerialIO LaserChamp. It hooks up to a serial port, and connects to the scanner by a tip-ring-sleeve connector (tip to pin #2, ring to pin#3, and sleeve t pin #5).

I downloaded the developer guide PDF from SerialIO's website. I threw together some quick code using my old Borland library functions from bios.h, but I can't get much useful information out of the scanner.

The code was copied from an example file. If I take a battery out of the scanner and put it back in, the scanner initializes with legible text giving me the scanner ID, firmware version, etc. But everything I scan givers me the same output. It's always:
☻210720600210630001
That's all I can get from it. The guide said to send it any character to wake it up, then send it the character 'W' to invoke the "Who" command (so I can see it's config info). But it doesn't seem to respond to any input.

Here's what I compiled:

[pre]#include <bios.h>
#include <conio.h>
#include <dos.h>

#define DTR 0x01 // Data Terminal Ready
#define RTS 0x02 // Ready To Send
#define COM1PORT 0x0000 // Pointer to Location of COM1 port
#define COM2PORT 0x0002 // Pointer to Location of COM2 port
#define COM1 0
#define COM2 1
#define DATA_READY 0x100
#define FALSE 0
#define TRUE !FALSE

#define SETTINGS (_COM_4800 | _COM_NOPARITY | _COM_CHR8 | _COM_STOP1)

int main( void )
{
int in,out,status,DONE=FALSE;
int far *RS232_Addr;

/* Determine port location of COM1.
0x40:0x00 = COM1 I/O port address
0x40:0x02 = COM2 I/O port address
*/
RS232_Addr = MK_FP( 0x0040, COM1PORT );
if( !*RS232_Addr )
return -1;

_bios_serialcom( _COM_INIT, COM1, SETTINGS );
cprintf( "... BIOSCOM [ESC] to exit ...\n\r" );

while( !DONE ){
/*Reset DTR and RTS to prepare for send/receive of next character.*/
outportb( *RS232_Addr + 4, DTR | RTS );

/* Get status of com port.*/
status = _bios_serialcom( _COM_STATUS, COM1, 0 );

if( status & DATA_READY ){
/*There's a character on the port. Get it and echo.*/
if((out=_bios_serialcom(_COM_RECEIVE, COM1, 0)&0x7F) != 0)
putch( out );
}

if( kbhit() )
/* Key has been struck. Get it and send to port.*/
if( (in = getch()) == '\x1B' )
/* User pressed ESCAPE. Don't send to port.*/
DONE = TRUE;
else{
/* Send character to com port.*/
_bios_serialcom( _COM_SEND, COM1, in );
}
}

return 0;
}[/pre]


I've actually never coded anything for serial ports before, nor barcode scanners. I'd love to hear any insight on this!
 
So I printed out a couple of the bar code pages, and I can't get either of them to read. First I printed it out on plain paper. I figured there was just too much bleed. Then I tried heavyweight matte paper. They printed a lot more cleanly but it still won't read any of them.
 
Is this what you have?


'No longer manufactured' is often code for "doesn't work worth a crap".


Separately,

I remember one of our MEs going nuts trying move a barcode scanner (old, simple) with an air cylinder, slow enough to meet the EE's spec of 15 inches/sec.
Nothing worked until the ME read the scanner spec, which stated a _minimum_ scan speed of 15 ips. Arrogant EE didn't bother to specify what the limit was.
I think the limit came from the limited buffer size; the scanner would record black/white for a certain period of time, at a constant rate in time,
then go back over the data array to figure out which bars were wide and which were narrow.
If the scanner was moved too slowly, you only got a partial scan and the checksum was wrong.
 
Yes! That is the one I have.

Gotcha. I'm just about ready to chalk it up to not working worth a crap.

Probably why it was abandoned in the first place.
 
Note that the one I cited sends its data via Bluetooth.
It's possible that the serial port is only used at the factory, and may be undocumented.
 
I wasn't. I'm assuming mine is an older pre-Bluetooth model.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top