[ale] Configure serial port settings at boot

Alex Carver agcarver+ale at acarver.net
Tue Dec 9 10:56:47 EST 2014


That would be great if the printer didn't disable flow control during
raster printing, there's no way to send XON/XOFF characters when the
printer is expecting a raw bitmap. :)  It really does go into dumb mode
during raster printing.  You tell it how many bytes will arrive and it
will assume that the next data received, no matter what, is part of that
bitmap until it has counted all the bytes.  If the serial port eats a
byte, the printer has no idea it happened and will just keep counting
until it reaches the total count of bytes.  So eating a byte here and
there just causes all sorts of confusion for the printer when it's
basing its synchronization entirely on the SYN character and the total
number of bytes that it sees.

Shunting CTS to RTS on the computer side only ensures that the data
doesn't stop (bypasses hardware flow control).  In my case it wasn't
flow control that caused the issue, it was the kernel serial driver
eating specific byte values until the port was set to raw mode.  So not
really a typical data synchronization issue (meaning something like a
buffer overrun) bu a state machine error in the printer due to a byte
never being transmitted by the computer.

Specifically I think it was the icanon byte values (erase, kill, werase,
and rprnt according to stty) that were being stripped from the printer's
data stream.

On 2014-12-08 06:28, Lightner, Jeff wrote:
> Back in the 90s when I did lots of printers we used software flow control (XON/XOFF) which only used ports 2,3 & 7 (TX,RX and ground) but some printers still fired on some extra pins even when configured for software flow control.   4 and 5 are CTS and RTS and we usually looped those back to each other.   Also we used to loop back 3 other pins to each other which I don't exactly recall but based on the link below I believe were 6, 8 & 20.
> http://www.digi.com/support/kbase/kbaseresultdetl?id=868
> 
> We did that by buying RJ45 to DB25 modular connectors and tieing the wires together within that.
> 
> 
> -----Original Message-----
> From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of Alex Carver
> Sent: Sunday, December 07, 2014 2:41 AM
> To: Atlanta Linux Enthusiasts
> Subject: Re: [ale] Configure serial port settings at boot
> 
> The printer doesn't have pins for the hardware flow control.  It just has TX, RX and ground.  I had tracked the problem I was originally having down to some control codes being consumed and dropped by the serial driver so they would never make it to the printer.  The printer, when printing raster graphics, is first put into raster mode with an ESC sequence then a second ESC sequence tells it the number of bytes per row in a bitmap.  Each bitmap row is then started with SYN and followed by the n-bytes of row data.  Problem was, for some patterns, the byte looked like a control code and was stripped.  So the whole thing would go out of sync because a row was transmitted with a missing byte (or more).
> 
> If data doesn't start with a SYN and no other mode is turned on it assumes literal data and prints the matching ASCII character.  So dropping one byte from the row data throws off all the SYN locations and the printer output is corrupted.  Once I flip the raw mode on the serial port, everything goes through unaltered and the printer is happy.
> 
> 
> On 2014-12-06 16:08, Chris Fowler wrote:
>> ----- Original Message -----
>>
>>> From: "Alex Carver" <agcarver+ale at acarver.net>
>>> To: "Atlanta Linux Enthusiasts" <ale at ale.org>
>>> Sent: Saturday, December 6, 2014 5:17:56 PM
>>> Subject: Re: [ale] Configure serial port settings at boot
>>
>>> Ok, thanks to Jim, JD and Chris, rc.local appears to be the way to go 
>>> and is relatively easy.
>>
>>> I'm not using a script. This is for lpd with a label printer attached 
>>> to the serial port so technically the port is always in use. The 
>>> problem is that a cooked mode serial port will eat some of the bitmap 
>>> data and cause much confusion for the printer when its bitmap 
>>> suddenly vanishes. Eight bit raw mode is all the printer needs to 
>>> make sure the labels print properly. I can't configure the port 
>>> within lpd other than the baud rate so I have to change the mode externally with stty.
>>
>> You may want hardware flow control. I've been down this road many times, but it was back in the 90s. 
>>
>>
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at 
>> http://mail.ale.org/mailman/listinfo
>>
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
> 
> 



More information about the Ale mailing list