[PATCH 0/2] Multidrop support for serial ports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Multidrop Mode differentiates the data characters and the address
characters. Data is transmitted with the parity bit to 0 and addresses
are transmitted with the parity bit to 1.

Usually multidrop is implemented by forcing MARK and SPARE parity as follow:
        /* Write data */

        /* Address byte */
        term.c_cflag |= PARENB | CMSPAR | PARODD;       /* MARK(1) */
        ret = tcsetattr(fd, TCSADRAIN, &term);
        if (ret < 0) {
                perror("unable to set MARK");
                exit(-1);
        }
        buf[0] = 0x00;
        ret = writen(fd, buf, 1);
        if (ret < 0) {
                perror("unable to write address (%m)");
                exit(-1);
        }

        /* Data bytes */
        term.c_cflag |= PARENB | CMSPAR;                /* SPACE(0) */
        term.c_cflag &= ~PARODD;
        ret = tcsetattr(fd, TCSADRAIN, &term);
        if (ret < 0) {
                perror("unable to set SPACE");
                exit(-1);
        }
        buf[0] = 0x1c;
        buf[1] = 0x01;
        buf[2] = 0x01;
        buf[3] = 0x00;
        buf[4] = 0x01;
        buf[5] = 0xde;
        buf[6] = 0xd4;
        ret = writen(fd, buf, 7);
        if (ret < 0) {
                perror("unable to write data (%m)");
                exit(-1);
        }

However this usually slow down communication by adding a delay between
the first byte and the others.

The first attached patch defines two non-stadard bits PARMD (that
enables multidrop) and SENDA (that marks the next transmitted byte as
address) that can be used to completely remove the delay by managing
the correct parity bit generation in hardware (the second patch is for
SAMA5D3 CPU). Then the userland code becomes:

        /* Transmission: enable parity multidrop and mark 1st byte as address */
        term.c_cflag |= PARENB | CMSPAR | PARMD | SENDA;
        ret = tcsetattr(fd, TCSADRAIN, &term);
        if (ret < 0) {
                perror("unable to set MARK");
                exit(-1);
        }

        /* Write data */
        n = 0;
        buf[n++] = 0x00;
        buf[n++] = 0x1c;
        buf[n++] = 0x01;
        buf[n++] = 0x01;
        buf[n++] = 0x00;
        buf[n++] = 0x01;
        buf[n++] = 0xde;
        buf[n++] = 0xd4;
        ret = writen(fd, buf, n);
        if (ret < 0) {
                perror("unable to write data (%m)");
                exit(-1);
        }

Rodolfo

Rodolfo Giometti (2):
  tty: add bits to manage multidrop mode
  tty serial: add multidrop support for atmel serial controllers

 drivers/tty/serial/atmel_serial.c   | 14 ++++++++++----
 include/linux/tty.h                 |  2 ++
 include/uapi/asm-generic/termbits.h |  2 ++
 3 files changed, 14 insertions(+), 4 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux