SFE_PalmoLPT 1.6
March 13, 2004

Maurizio Moretti
Palmosoft S.r.l.
http://www.palmosoft.com

Note by author: as introductory price, would be fine for me to know 
how the extension is used and in what market context (plus the eventual
try on hw and OS).
My try:
	* CUSTOM (OS 3.5, 4.0+, Handspring, Palm)
	* CUSTOM BT (OS 3.5, 4.0+, Palm)
	* SEIKO DPU3445 (OS 3.5, 4.0+, Handspring, Palm)
	* HP 350 (OS 3.5, 4.0+, Handspring, Palm)

Other people try:
	* CANON BJ85 (OS 3.5, 4.0+, Handspring, Palm)
	* ZEBRA CAMEO PLUS

m.moretti@palmosoft.com. Thank you.

What's new in ver 1.6?
General improvement. We've made a general improvement on all library.
The Seiko DPU3445 is now correctly handled by sw.
Speed on IrDa should be faster.
Inserted Bluetooth capacity (with RFCOM, you need to open the port 1).
Inserted IrComm capacity (using internal Palm stack instead of PalmoSoft
stack to IrDa, you need to open port 2).


What's new in ver 1.5?
-----------------------------
---------- SendRaw ----------
-----------------------------

Added two parameter to send raw (if you need to receive something from
printer after sending the command, or if you need to test status but
ONLY FOR CUSTOM PRINTER).

Errore=SendRaw(""1B5B4B0200001F424AFC53544152540A"",1,0).

The first parameter is the characters you want to write, in the example 
was the ESCape function to init Canon BubbleJet command.
As you see, data sent on the printer are the binary value 
(two characters at once). The second parameter is the boolean value 
if you need to receive something after sending the command (1 for 
enabling reception, 0 for disabling). The third parameter is the 
boolean value if you need to get status before send command (ONLY FOR 
CUSTOM PRINTER).

-----------------------------
---- GetLastReceiveData -----
-----------------------------

This new function enables you to retrieve last information received from
printer. Useful if you need to receive information or error from printer.

DataString=GetLastReceiveData

In DataString you have the string with information passed by printer.


What's new in ver 1.4?
-------------------------------
---------- PrintLine ----------
-------------------------------

Added a parameter to PrintLine (if you need to translate international
character). You can translate from Palm code page to "IBM" code page,
or to Multilingual codes chart (known as 850).

Errore=PrintLine("Ciao from Italy",0,1,1).

The first parameter is the line you want to write.

The second parameter is if you want to get status before print line (so 
you can recover from an end of paper situation), setting 1 you request 
the status, setting 0 if you don't need it.

The third parameter is if you want to append an LF to line provided in first
parameter (set to 1), append a CRLF (set to 2) or append nothing (0).

The fourth parameter is the type of translation you need:
0 for NO translation
1 for translation from Palm codes to IBM codes
2 for translation from Palm codes to Multilingual code page (850). Obviously
you need to select code page for printer with printer command, otherwise
you can't properly international characters.

The return value, as usual, is the return code.The return value, as usual, 
is the Palm OS error or 0 for no error.



-------
- BUG -
-------
Corrected a mistake with Palm M1xx series.

-----------------------------
---------- SendRaw ----------
-----------------------------
This new function is able to send hexadecimal codes to printer. You should
be able to send control caracter with chr(xx) but there is a problem with
NULL char (because printline wants an ASCIIZ string).
Is more simple to send character not by CHR but by Hexadecimal string 
(if you have a Canon you can copy directly command codes into the string
passed with SendRaw.

Errore=SendRaw("1B5B4B0200001F424A4C53544152540A")

The number of character sent to printer is half of char passed (in this case
is 16 hexadecimal characters).


What's new in ver 1.3?
-------------------------------
---------- PrintLine ----------
-------------------------------
Added a capability for adding to line:
LF
CRLF
None

Errore=PrintLine("Ciao from Italy",0,1).

The first parameter is the line you want to write.

The second parameter is if you want to get status before print line (so 
you can recover from an end of paper situation), setting 1 you request 
the status, setting 0 if you don't need it.

The third parameter is if you want to append an LF to line provided in first
parameter (set to 1), append a CRLF (set to 2) or append nothing (0).

The return value, as usual, is the return code.The return value, as usual, 
is the Palm OS error or 0 for no error.


ver 1.2 ------> Intermediate Version...


What's new in ver 1.1?
-------------------------------
---------- PrintLine ----------
-------------------------------

Added a parameter to PrintLine (if you DON'T need to append an LF to line).
Internally the PrintLine add only an LF (before send a CR/LF).

Errore=PrintLine("Ciao from Italy",0,0)

The first parameter is the line you want to write.

The second parameter is if you want to get status before print line.

The third parameter is if you want to append an LF to every printed line ...
1 = Yes, 0 = No.

The return value, as usual, is the Palm OS error or 0 for no error.

----------------------------------
---------- SetupPrinter ----------
----------------------------------
Added a parameter to SetupPrinter, you're able to specify communication port.
Would be 0 for an IrDa, otherwise a port supported by new serial manager
(hexadecimal 8000 for the COM).

Errore=SetupPrinter(0,2,3).
The first parameter is the port you want to use for communicating with the printer.
If you set 0 you choose to communicate via IrDa.

The second parameter is the timeout in seconds, 
the last parameter is the tick to wait to complete printing 
(try to experiment your need). If you set 0 you choose default 
(10 for seconds, 1 for ticks).

The return value, as usual, is the Palm OS error or 0 for no error.
0x802D	Added Setup Communication error.

--- NEW -------------------------
---------- SetupSerial ----------
---------------------------------

With this new function you're able to setup serial port (in case you need
to use it).
Sample:
Errore=SetupSerial(9600,"N",8,1,1).

Default values are used if you don't call SetupSerial, but still open the 
communication printer to serial port (calling SetupPrinter with a value <> 0).

Serial speed. Default: 38400.

Parity. "N" for none, "O" for parity on, "E" for even. Default: "N".

Bit per Char: you can use 5,6,7 and 8. Default: 8.

Stop bits: you can use 1 or 2. Default: 1.

Hardware flow control (RTS/CTS): 1 (YES), 0 (NO). Default: YES. Actually the 
XON/XOFF protocol is not natively supported on Palm OS.

Remember: don't use SetupPrinter AFTER calling SetupSerial or ALL the serial
parameters will be reset to default.

What is SFE_PalmoLPT?
---------------------

SFE_PalmoLPT is a Satellite Forms extension that provide a way 
to IrDa printing without paying runtime no more.
The library is very plain but for basic should make
his work.
If you have in mind a printer for your application, please give a 
try to a custom site (http://www.custom.it/ing/pos/palm.asp) who have a 
lot of portable and IrDa printer. If you use it, you can download directly 
the extension from my site or his site without paying any more (even
if the extension is locked on that printer).
---------------------
The function (basically) are only one (all you need to print):
Errore=PrintLine("Ciao from Italy",0)
The first parameter is the line you want to write,
the second parameter is if you want to get status before print line 
(so you can recover from an end of paper situation), 
setting 1 you request the status, setting 0 if you don't need it.\
Remember to set the second parameter to 0 because 1 is made ONLY
FOR CUSTOM PRINTER.

The return value, as usual, is the return code.
The possible return code is the Palm OS Code + some application code here
descripted:

Code Nr.	#Define	Explanation
0x8001	---	IrDa Status Failed
0x8002	---	IrDa Status Pending
0x8003	---	IrDa Disconnect
0x8004	---	IrDa No IrLap
0x8005	---	IrDa Busy
0x8006	---	IrDa Not Busy
0x8007	---	IrDa No Progress
0x8008	---	IrDa Link OK
0x8009	---	Not used
0x800A	---	Not used
0x800B	ErrPalmoIRBusy	IR Busy found before discovering (maybe during ConnectDevice).
0x800C	ErrPalmoIRNInit	IR PalmoSoft Library not inited
0x800D	ErrDiscovery	Application error during discovery function
0x800E	ErrConnectLap	Application error trying to ConnectIrLap
0x800F	ErrTimeout	Timeout while waiting to get a response from Ir Library. NB: Timeout hardcode into libraries: 10 seconds.
0x8010	ErrOutOfSequence	Get a response from IrDa library out of sequence (Examples: connect event while waiting for a sent packet event).
0x8011	ErrNoLSAP	Unable to connect with printer.
0x8012	ErrDebug	Is not an error but a debug messages. If you get some of these message, please send an email to supportcustom@palmosoft.com
0x8013	ErrUnexpectedIASResult	Unexpected result from IAS library.
0x8014	ErrLMPConnection	Error trying to connect to LMP
0x8015	ErrTinyTPConnection	Error trying to connect to TinyTP
0x8016	ErrNoDeviceInRange	No device in range during Discovery
0x8017	ErrAlreadyConnected	Already connected to device. If you need to connect to another device, try disconnect first.
0x8018	ErrBind	Error while trying binding stack.
0x8019	ErrSetDeviceInfo	Application error while setting device information (will be exposed on the remote side).
0x801A	ErrDroppingLap	Error while trying to disconnect IrLap.
0x801B	ErrUnbind	Error while trying unbinding stack.
0x801C	ErrNotConnected	Error: remote device not connected.
0x801D	ErrDataSendNotReady	Data send indicator not ready: wait while indicator is ready.
0x801E	ErrCannotSendData	Application error while trying to send data.
0x801F	ErrRawDataNotEven	Raw data passed to library is not even. Example: you want to send 0xFFF0 to printer, you need to pass a buffer with FFF0, so len of string must be even.
0x8020	ErrRawDataTooLong	Raw data too long (no more than 160 chars).
0x8021	ErrRawDataInvalid	Raw data invalid (all bytes must be from 0 to 9 or from A to F or from a to f
0x8022	ErrFunctionNotAvailable	Function not available in context. (Example: trying to make a discovery in serial mode).
0x8023	ErrDebugEvent	Not used
0x8024	ErrTimeoutInRx	Timeout while waiting data (from send to receive is hardcoded to 20 seconds).
0x8025	ErrUnableToHandleBitmap	Bitmap height or bitmap width too long. Maximum is 384 x 384. Try to give a lower percentage or pass a 0 to get the library calculate maximum percentage.
0x8026	ErrBitmapNotFound	The bitmap you pass to library was not found.
0x8027	ErrNotEnoughMemory	There are not enough memory to work with this bitmap (maybe the bitmap you provide is compressed).
0x8028	ErrCoverOpen	The printer cover is open.
0x8029	ErrNoPaper	There are no paper in printer.
0x802A	ErrHeadTemp	The head temperature is not in correct range.
0x802B	ErrBatteryVoltage	Battery voltage is not in correct range.
0x802C	ErrNotACustomPrinter	The Printer is not manufactured by Custom. Cannot continue.
0x802D	ErrSerialParameter	Error giving serial parameter.

When the result is a timeout there is a prompt for giving the user the ability to 
change paper or retry operation.
Remember that a LF is appended every PrintLine you made.

The other important function is:

ClosePrinter()

Close the connection with the printer.
Remember to issue this command before you close the program
The return value, as usual, is the Palm OS error or 0 for no error.

As an option you can setting OS parameter to printing, like timeout and 
reactivity time (but you don't need to call it):

Errore=SetupPrinter(30,0) 
Setup printer with timeout and ticks
The first parameter is the timeout in seconds, the second parameter is the reactivity
of the system expressed in tick (try to experiment your need). 
If you set 0 you choose default.
The return value, as usual, is the Palm OS error code of the function.


FOR CUSTOM SPRINT ONLY:
Print a barcode:
Error=PrintBarcode(tipobarcode,altezza,posizione,CheckDigit,StampaNumero,Size,barcode,rowbefore,rowafter)

Where:
	tipobarcode is a type of barcode:
		"I" = Interleaved 2/5
		"C" = Code39
		"B" = CodaBar
		"e" = EAN8
		"E" = EAN13
	altezza is the height of barcode in 1/8 mm units
	posizione is the position from left margin in 1/8 mm units
	CheckDigit is a parameter for printing (if = 1) or not (=0) the checkdigit in number
	StampaNumero is for printing number under/over barcode:
		0 = Don't print
		1 = over
		2 = under
		3 = under and over
	size of barcode:
		0 = normal
		1 = double
		2 = triple
		3 = quadruple
	barcode is the ASCII string containing the barcode.
	rowbefore is the row before the printed barcode
	rowafter is the row after the printed barcode.
	The return value, as usual, is the Palm OS error or 0 for no error.

Print a bitmap:

Errore=PrintImage("Date Book",1000,400,1,0,0).
where:
1) Program name (PRC) where you have the bitmap
2) the number of the bitmap
3) the percentile factor for width (0 for maximum enlarging)
4) factorizing height the same as width 
5-6) coordinate from margins where to print.

The return value, as usual, is the Palm OS error or 0 for no error."


Please, give me all your suggestions, and your thought:
m.moretti@palmosoft.com
