[squeak-dev] Scape code for printers

Jon Hylands jon at huv.com
Wed Mar 11 13:07:00 UTC 2009


On Wed, 11 Mar 2009 11:48:27 +0100, Giuseppe Luigi Punzi
<glpunzi at lordzealon.com> wrote:

> I'm trying to use Smalltalk for all on my company.
> 
> Well, I know the escape codes, I only need to know, how to send it to 
> LPT1, or COM2, or to a printer at USB.
> 
> It suppose, I need to sent to the printer port :
> ESC p 0 25 250
> 
> This, sends the signal to "electrify" the port at the printer, to open 
> the cash drawer. This printers doesn't has screens.

Talking through a serial port is pretty simple.

	serialPort := SerialPort new
		baudRate: 9600;
		dataBits: 8;
		stopBitsType: 1;
		parityType: 0;
		yourself.

	((serialPort openPort: self serialPortNumber) isNil)
		ifTrue: [ self error: 'COM port not available' ].

	serialPort nextPutAll: #(1 2 3) asByteArray.
	serialPort close.

That setup does standard 9600 baud, 8n1.

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      Jon at huv.com      http://www.huv.com/jon

  Project: Micro Raptor (Small Biped Velociraptor Robot)
           http://www.huv.com/blog



More information about the Squeak-dev mailing list