AbidingDude
Programmer
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!
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!