Eu tento fazer com que uma placa PCI RS485 funcione em um computador com o Debian Jessie instalado (usando o systemd). Eu adaptei o kernel usando um patch fornecido pelo fabricante da placa. Isso parece funcionar quando a placa é detectada e todas as oito portas seriais são inicializadas.
O kernel deve definir as seguintes propriedades:
.flags = FL_BASE0,
.base_baud = 921600,
.uart_offset = 0x200,
Quando tentei trabalhar com essas portas, sempre via a taxa de transmissão de 921600. Desde então, mudei o seguinte:
Eu desinstalei o ModemManager (porque ele não parou de sondar as portas seriais e neste computador nunca haverá modem).
Adicionei regras ao /etc/udev/rules.d/ criando links simbólicos e alterando o usuário e o grupo dessas portas RS485.
Eu adaptei os grupos para poder ler e gravar nesses ports não apenas como root.
Desde então, percebo um comportamento estranho. A taxa de baud é inicializada com 921600 (eu vejo isso usando "dmsg"), mas sempre que eu a leio ela é configurada para 9600 (usando "stty -F / dev / stty11 -a").
Por fim, tenho as seguintes saídas:
me@my-system:$ sudo udevadm info -a -p $(udevadm info -q path -n /dev/ttyS11)
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:1b.2/0000:06:00.0/0000:07:0f.0/tty/ttyS11':
KERNEL=="ttyS11"
SUBSYSTEM=="tty"
DRIVER==""
ATTR{irq}=="17"
ATTR{line}=="11"
ATTR{port}=="0x0"
ATTR{type}=="21"
ATTR{flags}=="0x13000040"
ATTR{iomem_base}=="0xDF100000"
ATTR{custom_divisor}=="0"
ATTR{iomem_reg_shift}=="0"
ATTR{uartclk}=="14745600"
ATTR{xmit_fifo_size}=="64"
ATTR{close_delay}=="50"
ATTR{closing_wait}=="3000"
ATTR{io_type}=="2"
looking at parent device '/devices/pci0000:00/0000:00:1b.2/0000:06:00.0/0000:07:0f.0':
KERNELS=="0000:07:0f.0"
SUBSYSTEMS=="pci"
DRIVERS=="serial"
ATTRS{irq}=="17"
ATTRS{subsystem_vendor}=="0x0702"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x070002"
ATTRS{driver_override}=="(null)"
ATTRS{enabled}=="1"
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{dma_mask_bits}=="32"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0x90f0"
ATTRS{msi_bus}==""
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x1402"
ATTRS{subsystem_device}=="0x0010"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="0"
looking at parent device '/devices/pci0000:00/0000:00:1b.2/0000:06:00.0':
KERNELS=="0000:06:00.0"
SUBSYSTEMS=="pci"
DRIVERS==""
ATTRS{irq}=="18"
ATTRS{subsystem_vendor}=="0x0000"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x060401"
ATTRS{driver_override}=="(null)"
ATTRS{enabled}=="1"
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{dma_mask_bits}=="32"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0x8892"
ATTRS{msi_bus}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x1283"
ATTRS{subsystem_device}=="0x0000"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="1"
looking at parent device '/devices/pci0000:00/0000:00:1b.2':
KERNELS=="0000:00:1b.2"
SUBSYSTEMS=="pci"
DRIVERS=="pcieport"
ATTRS{irq}=="18"
ATTRS{subsystem_vendor}=="0x8086"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x060400"
ATTRS{driver_override}=="(null)"
ATTRS{enabled}=="1"
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{dma_mask_bits}=="32"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0xa169"
ATTRS{msi_bus}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x8086"
ATTRS{subsystem_device}=="0x7270"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="0"
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
Usando o setserial:
me@my-system:$ sudo setserial -a /dev/ttyS11
/dev/ttyS11, Line 11, UART: undefined, Port: 0x0000, IRQ: 17
Baud_base: 921600, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test
E lendo a configuração atual:
me@my-system:$ sudo stty -F /dev/ttyS11 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc
-ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
Dentro de / proc / tty / driver / é um arquivo "serial":
serinfo:1.0 driver revision:
...
11: uart:XR17D15X mmio:0xDF100000 irq:17 tx:0 rx:0
12: uart:XR17D15X mmio:0xDF100200 irq:17 tx:0 rx:0
13: uart:XR17D15X mmio:0xDF100400 irq:17 tx:0 rx:0
14: uart:XR17D15X mmio:0xDF100600 irq:17 tx:0 rx:0
15: uart:XR17D15X mmio:0xDF100800 irq:17 tx:0 rx:0
16: uart:XR17D15X mmio:0xDF100A00 irq:17 tx:0 rx:0
17: uart:XR17D15X mmio:0xDF100C00 irq:17 tx:0 rx:0
18: uart:XR17D15X mmio:0xDF100E00 irq:17 tx:0 rx:0
O que está errado aqui? Por que a taxa de transmissão está mudando? Como posso evitar isso? É "UART: indefinido" OK?