http://www.perlmonks.org?node_id=117596


in reply to Kludging the serial port

I looked at their docs. The "send" and "data" lines are separate here, and of a polarity that should render them useful with a normal RS232 converter. By "normal", I mean one that converts outgoing CMOS 0V to (+3 to +12V) and CMOS +5V to (-3 to -12V), and vice-versa for incoming RS232 lines. This is to say, it inverts in both directions. This needs to be done for all the signals you use. If it doesn't do this, you're not getting your money's worth, and I'd get a different converter or build one using a Maxim MAX232 or somesuch IC.

Once you have a proper converter, the rest is easy. Pin 2 on your PC's DB9 should map from the note scanner's "data" line. It's easiest if the "send" line maps to one of the handshake lines the PC can control directly, but if it maps to the PC's TX line (pin 3) that's okay too. You just need to send the changer a pulsed BREAK for a period long enough to meet their timing requirements. This is done with: $PortObj->pulse_break_on($milliseconds); What this does is raise the RS232 TX line (pin 3) from -10V, say, to +10V for a period you specify. The converter, by inverting this, will create a 0V pulse on a normally 5V signal line -- just what the scanner wants. Then all you have to do is check your input buffer for the incoming data byte.

With all the means available for doing this right, there just isn't any excuse for kludging the hardware in the manner you describe.