Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Trying to Code for a Barcode Scanner

Trying to Code for a Barcode Scanner

Trying to Code for a Barcode Scanner

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:
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:

#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


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;
			/* Send character to com port.*/
			_bios_serialcom( _COM_SEND, COM1, in );

 return 0;

I've actually never coded anything for serial ports before, nor barcode scanners. I'd love to hear any insight on this!

RE: Trying to Code for a Barcode Scanner

What OS are you running on? The Borland code you've shown will only work in DOS or Win95/98/ME. It won't work on any of the NT family.

RE: Trying to Code for a Barcode Scanner

I ran it in XP.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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