Advanced graphics (experimental)¶
IBM Personal Communications (PCOMM) has two host graphics protocols. The session setting is Host Graphics: Vector Graphics, with Native or Advanced.
- Native is plain 3270 Write Structured Field. The
tn3270package sends it withImagePictures()andWriteStructuredFields(). Refer to graphics.md. - Advanced puts the same graphics fields in an envelope. The
tn3270.Advancedtype sends it.
Caution: The Advanced protocol comes from a study of the PCOMM 5.9 DLLs.
Nobody has tried it on a live session yet. A server cannot yet tell if a
client is set to Advanced mode. Thus the library does not try to find out.
The server uses Advanced mode only when its operator tells it to (for
example, gfxtest -advanced).
1. The layers of a message¶
The host sends a message to the client like this:
F3 Write Structured Field
00 08 0F 02 00 00 DD DD Destination/Origin field, DOID = DD DD
00 0F 10 13 ... the 10 13 header (15 bytes)
LL LL 0F 10 ... the payload fields (Object Picture and others)
FF EF IAC EOR (each FF of data is sent as FF FF)
The client replies with AID 88, the same Destination/Origin field, its
own 10 13 header, and its reply fields.
The 10 13 header, from the host:
| Byte | Value |
|---|---|
| 0-1 | 00 0F |
| 2-3 | 10 13 |
| 4-5 | 00 00 |
| 6 | 02 (0A in extended mode) |
| 7-8 | 08 01 |
| 9 | flags: 40 end of picture, 08 repaint, 04 no acknowledgement, 00 acknowledge |
| 10 | 00 |
| 11 | correlator |
| 12 | sequence number: one more than the last message |
| 13-14 | 00 00 |
In the reply of the client, byte 9 is 18. It is 98 if no fields follow.
Bytes 13-14 are a status word, little-endian. Status 0100 tells that the
client found a bad sequence number, and continues from the number that the
host sent.
2. The library¶
dev, err := tn3270.NegotiateTelnet(conn)
...
adv := tn3270.NewAdvanced(conn) // DOID 0003, correlator 21
err = adv.Query() // the Advanced query replies
fmt.Println(adv.Ports()) // the port IDs from the Port replies (B3)
sfs, _, err := tn3270.ImagePictures(x, y,
tn3270.PictureOptions{MaxSegment: tn3270.AdvancedMaxSegment}, planes...)
err = adv.SendPicture(append([][]byte{tn3270.ClearField()}, sfs...)...)
Query()sends Read Partition, Query (01 FF 02) in the envelope. It keeps the replies:QueryReply(),QueryReplies(),Ports()andGraphicColors(). If no reply comes, it returnsErrAdvancedTimeout. This can tell that the client is not in Advanced mode, but this is not sure.SendPicture()sends the fields in as few messages as possible. Each message is 0xE00 bytes or less (AdvancedMaxMessage). An Object Picture that is too long for one message is cut into pieces. The flags of the pieces are80(first),00(middle) and40(last). The last message has the repaint flag (08). Before the last message, the library waits for an acknowledgement of each message. SetNoAckto send them without acknowledgements (flag04).- A segment in Advanced mode is 0xFC00 bytes or less. Give
PictureOptions.MaxSegment: tn3270.AdvancedMaxSegmenttoImagePictures().SendPicture()refuses a segment that is longer. ClearField()is an Object Control field that clears the graphics. Put it before a picture.Reset()sends Erase/Reset (03). Each graphics instance of the session starts again.Transfer(name, data)sends data with DDM Open, Insert and Close.DDMSavePIF(PCXFD001) tells the client to save the picture as a GDDM PIF file.DDMPrint(PCXFD002) tells the client to print it. A refusal is a*DDMErrorwith the code of the client.SplitPictureFields()cuts the fields without sending them. It is for a server that sends the messages itself.
A key that the user pushes while the server waits for a reply gives
ErrAdvancedInterrupted. An Exception/Status reply (0F22) gives
ErrAdvancedRejected.
Use the Advanced type between screens, or in ScreenOpts.PostSendCallback.
Do not use it while ShowScreenOpts() waits for a response. The two read
from the same connection.
3. What is not known¶
- The DOID. PCOMM gets the DOID from an internal registration, not from
a constant. The display port in the Port reply (B3) is
0003, and the library uses this value. ChangeAdvanced.DOIDto use a different value. - How to find Advanced mode. The query replies of a Native session and an Advanced session can be the same. No bit that tells the mode is known.
- Long replies. PCOMM can cut a long reply into many records. The library reads one record for each reply. The Advanced query replies are 0x300 bytes or less, thus one record is usually sufficient.
- The DDM data. The data that
PCXFD001andPCXFD002expect is probably a GDDM picture file. This is not confirmed. - Graphics input. The study did not find a graphic cursor or locator report from the client.
- TN3270E. The library does not negotiate TN3270E. The protocol also operates on plain TN3270.
4. Try it¶
Set the PCOMM session to Host Graphics: Vector Graphics, Advanced. Then
connect. Choice A asks for the Advanced query replies. The tests 1 to 6
send their graphics in Advanced messages. Use -doid to change the
Destination/Origin ID, and -noack to send without acknowledgements. Each
record goes to the log, with the Destination/Origin field and the 10 13
header named.