Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

lpr protocol with as400 issue

45 views
Skip to first unread message

David Haas

unread,
Jul 20, 2004, 4:34:01 PM7/20/04
to
I am implementing lpr protocol in a printer (embedded system) which we
are going to use with an AS400. I have taken some traces of lpr with
another print server and I notice some anomolies which I don't
understand.

The AS400 opens the TCP connection and here is the conversation:

AS400: 0x02 PASS LF
PRINTER: 00
AS400: 0x04 80 cfA003stuff.stuff.stuff.comLF
PRINTER: 00
AS400: 0x48stuff.stuff.stuff.comLF
AS400: 0x50stuffLF
AS400: ldfA003stuff.stuff.stuff.comLF
AS400: 0x4EstuffLF
AS400: 00
PRINTER: 00
AS400: 0x05dfA003stuff.stuff.stuff.comLF
PRINTER: 00
AS400: stuff to print
PRINTER: 00

So my question is why did the AS400 send a 0x04 line which would seem
to be asking for a queue status. It seems that it is actually sending
a control file here (which according to RFC1179 should be a 0x02
code).

Also the 0x05 code seems to be used to pass the data file and yet
there should be an indication of the number of bytes in the data file
and I don't see that. How does the print server know it is done? Is
this some other implementation to LPR protocol that everyone knows
about, but not me?

Any help would be greatly appreciated.

David Haas
NBS Card Technology
http://www.nbstech.com

Charles Wilt

unread,
Jul 21, 2004, 8:53:01 AM7/21/04
to
David,

Sorry I can't be of any help with your original problem. However, I
thought I'd mention that lpr/lpd directly to a printer from the AS/400
is the least preferred method.

You may instead want to take advantage of Internet Print Protocol (IPP).
http://www.ietf.org/html.charters/ipp-charter.html
http://www.pwg.org/ipp/


HTH,
Charles


Overallman

unread,
Jul 21, 2004, 10:50:22 AM7/21/04
to
David Haas wrote:

Some time ago i wrote a LPR client for W95 in VB5.0 and i was supprised
that the AS/400 followed the RFC1179 completely.

First i waited till i got a x02 that indicated that a print job would be
received, i ignored all other parameters, after that i processed:
0x01 = job cancel
0x02 = control file reception with the host and user
0x03 = data to print
At the end of the data i send a 0x00 to the AS/400 and started printing.


David Haas

unread,
Jul 21, 2004, 3:02:15 PM7/21/04
to
You mean you wrote a server????

I took traces at a customer site, so I know that the system was doing
what I saw it doing. Perhaps their AS400 was not configured properly?
Maybe there was a bug in whatever rev of the OS they have? It was
certainly strange. Unfortunately I know almost nothing about AS400 and
the IT person at the customer site was not very knowledgable either.

By the way, I am sure that IPP is a much better protocol than LPR, but
unfortunately the market seems to want LPR. I am implementing what our
customers are asking for. I might do an IPP implementation later.

David.


Overallman <overa...@overall.man> wrote in message news:<40fe8304$0$62393$5fc...@dreader2.news.tiscali.nl>...

Overallman

unread,
Jul 21, 2004, 4:14:01 PM7/21/04
to
David Haas wrote:
> You mean you wrote a server????

Indeed.

>
> I took traces at a customer site, so I know that the system was doing
> what I saw it doing. Perhaps their AS400 was not configured properly?
> Maybe there was a bug in whatever rev of the OS they have? It was
> certainly strange. Unfortunately I know almost nothing about AS400 and
> the IT person at the customer site was not very knowledgable either.
>

I used the OUTQ configuration way, i installed my software worldwide
(Belgium, Brasil, Iceland, Germany, ...) without any problem.

> By the way, I am sure that IPP is a much better protocol than LPR, but
> unfortunately the market seems to want LPR. I am implementing what our
> customers are asking for. I might do an IPP implementation later.
>

LPR is the standard but it has it problems.

> David.
>

If you can read VB, i'm willing to send you my sources so you can test
and write a simalar function for your embedded system.

David Haas

unread,
Jul 22, 2004, 8:25:15 AM7/22/04
to
Overallman <overa...@overall.man> wrote in message news:<40fecee1$0$62376$5fc...@dreader2.news.tiscali.nl>...

> If you can read VB, i'm willing to send you my sources so you can test
> and write a simalar function for your embedded system.

Thank's for the offer, but Windows XP already supports lpr natively
and I am also going to test my implementation against linux.

I'm going to bring it to some other AS400 customers so in the end I
will figure it out.

Overallman

unread,
Jul 22, 2004, 12:34:17 PM7/22/04
to
David Haas wrote:
> Overallman <overa...@overall.man> wrote in message news:<40fecee1$0$62376$5fc...@dreader2.news.tiscali.nl>...
>
>
>>If you can read VB, i'm willing to send you my sources so you can test
>>and write a simalar function for your embedded system.
>
>
> Thank's for the offer, but Windows XP already supports lpr natively
> and I am also going to test my implementation against linux.
>

That wasn't the question, was it ?

> I'm going to bring it to some other AS400 customers so in the end I
> will figure it out.

Losing time can't be a problem when the customer pays for it, that's why
we threw out all external customized sotware and advisors.

Anyway i'll attach the dataarival procedure, so you have an idea.

Good luck.

-------------------------------------------------------------------------------------------------

Private Sub LPR_socket_DataArrival(ByVal bytesTotal As Long)

On Error GoTo Fout

Light_Show = Light_Red
Light_Show.Visible = True

LPR_socket.GetData StrData, vbString

Debug.Print StrData + vbCrLf

ReceivedCmd = Asc(Mid$(StrData, 1, 1))
If bytesTotal > 2 Then ReceivedData = Mid$(StrData, 2, Len(StrData) - 2)

Select Case CmdStep
Case 0
' Deamon mode
Select Case ReceivedCmd
Case 1
' Print any waiting jobs
MsgBox "Deamon cmd 1"
Case 2
' Receive a printer job
CmdStep = 1
varQueued = ReceivedData
Screen_Out.Text = Screen_Out.Text + ">Queue : " +
ReceivedData + vbCrLf
Case Else
Forced_Close
End Select
Case 1
' Receive mode
Select Case ReceivedCmd
Case 1
' Abort job
CmdStep = 0
Case 2
' Receive control file
b = InStr(1, ReceivedData, " ") + 1
MaxLength = Val(Mid$(ReceivedData, 1, InStr(2,
ReceivedData, " ")))
CtrlFile = Mid$(ReceivedData, b, Len(ReceivedData) - b + 1)
Screen_Out.Text = Screen_Out.Text + ">Control : " +
CtrlFile + vbCrLf
Length = 0
CtrlLine = ""
CmdStep = 2
Case 3
' Receive data file
posb = InStr(1, ReceivedData, " ") + 1
MaxLength = Val(Mid$(ReceivedData, 1, InStr(2,
ReceivedData, " ")))
DataFile = Mid$(ReceivedData, posb, Len(ReceivedData) -
posb + 1)
Screen_Out.Text = Screen_Out.Text + ">File : " +
DataFile + vbCrLf
CmdStep = 3
Length = 0
Case Else
Forced_Close
End Select
Case 2
' Control file mode
Open CtrlFile For Append As #1
Print #1, StrData
Close #1
CtrlLine = CtrlLine + StrData
Length = Length + bytesTotal
If Length > MaxLength Then
Control_Token
CmdStep = 1
End If
Case 3
' Data receive
If Length = 0 Then Open DataFile For Binary As #1
For x = 1 To Len(StrData)
Put #1, , Mid$(StrData, x, 1)
Next x
Length = Length + bytesTotal
If Length > MaxLength Then
Close #1
CmdStep = 1
End If
Case Else
End Select

If CmdStep < 2 Or Length = 0 Then Send_Answer

GoTo Einde
Fout:
MsgBox Str$(Err.Number) & " - " & Err.Description
Resume Next
Einde:
End Sub


---------------------------------------------------------------------------------------------

David Fowle

unread,
Aug 4, 2004, 10:26:46 AM8/4/04
to
Dear David,

From my own experience of implementing an LPD server (please see
http://www.pdfing.com ) I know that when the OS400 DSTTYPE() parameter
is set to *AS400 (SNDTCPSPLF) or *OS400 (CRTOUTQ) OS400 LPR uses an
extension to the base LPD/LPR protocol, known as "Receive Control File
First" (04) and "Receive Data File of Unspecified Length" (05)

These extensions are described in an IETF draft by Glen Trewit. I can
send you a copy if you cannot find it for yourself.

Regards

David Fowle

0 new messages