3.2. Printer Connection - IrLPT, IrTTP, IrCOMM?

IrLPT seems to be replaced by IrCOMM. Sorry I don't have tested this yet. So this is only the remaining part from former IrLPT support. Please see mailing list archive for further information.

Takahide Higuchi reported: " I have been debugging IrCOMM with a printer ( Canon BJC-80v ) with IrDA port and IrCOMM protocol (not IrLPT). I can print a short e-mail text though, it easily causes dead lock when I try to print a postscript with gs."

From the page of Thomas Davis http://www.jps.net/tadavis/irda : To use the IrLPT server, you need to perform the following steps:

/sbin/modprobe irlpt_server
/sbin/mknod /dev/irlptd c 10 `grep irlptd /proc/misc|cut -f 1`
At this point, the IrLPT server is ready to recieve print jobs; now; all you need is this simple shell script
#/bin/sh
#
while (true)
do
cat /dev/irlptd | lpr
done
Dag Brattli: I hope that this will make it easier for all you that prefer to live in user-space, to make your own IrDA applications and try it out. Some printers actually use IrTTP (because of the limitations of IrLPT), so now you can write your own small user-space printer client so you can talk to it:
int discover_devices(int fd)
{
    struct irda_device_list *list;
    unsigned char buf[sizeof(struct irda_device_list) +
          sizeof(struct irda_device_info) * MAX_DEVICES];
    int len;
    int daddr;
    int i;

    len = sizeof(struct irda_device_list) +
      sizeof(struct irda_device_info) * MAX_DEVICES;
    list = (struct irda_device_list *) buf;

    if (getsockopt(sfd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) {
    perror("getsockopt");
    exit(-1);
    }
    if (len > 0) {
    /*

Just pick the first one, but we should really ask the user

     */
    daddr = list->dev[0].daddr;

    printf("Discovered: (list len=%d)\n", list->len);

    for (i=0;i<list->len;i++) {
        printf("  name:  %s\n", list->dev[i].info);
        printf("  daddr: %08x\n", list->dev[i].daddr);
        printf("  saddr: %08x\n", list->dev[i].saddr);
        printf("\n");
    }
    }
    return daddr;
}

void client()
{
    struct sockaddr_irda peer;
    int addrlen = sizeof(struct sockaddr_irda);
    int daddr, actual;
    char buf[1024];

    fd = socket(AF_IRDA, SOCK_STREAM, 0);

    daddr = discover_devices(fd);

    peer.sir_family = AF_IRDA;
    strcpy(peer.sir_name, "P1284");
    peer.sir_addr = daddr;

    connect(fd, (struct sockaddr *) &daddr, sizeof(struct sockaddr_irda));

    /* Try to send something */
    actual = send(fd, "Testing", 8, 0);

    /* Try to read reply */
    actual = recv(fd, buf, 1024, 0);
}