Monitor com porta com strace

0

Eu escrevi uma pequena aplicação em Java que grava duas strings - 'dddd' e 'ffff' - em uma porta com. Eu usei strace -s9999 -o serialtrace.log -eread,write,ioctl para inspecionar como ele grava.

Descobri que o descritor com porta é 5 , mas há uma informação de leitura de linha estranha que não escrevo na porta de comunicação:

Line 112: read(5, "#\n#Tue Jan 14 12:28:06 GMT+01:00 2014\ncurrencyCode=440\nlogFileName=dbg.log\nport=4462\ncommunicationForward=true\nterminalLanguage=4\ntermInterfaces=\ndelLogDaysOld=0\nStopBits=1\nParity=0\nmessagesFileName=language.ini\nDataBits=8\ncomPort=/dev/ttyS0\nInfoInReceiptSlip=1\ntermDataEncoding=1\nBaudRate=9600\nDebugRX=true", 8192) = 311

Esta informação está em um arquivo de configuração. O que é isso?

A saída filtrada de

Strace é:

Line 112: read(5, "#\n#Tue Jan 14 12:28:06 GMT+01:00 2014\ncurrencyCode=440\nlogFileName=dbg.log\nport=4462\ncommunicationForward=true\nterminalLanguage=4\ntermInterfaces=\ndelLogDaysOld=0\nStopBits=1\nParity=0\nmessagesFileName=language.ini\nDataBits=8\ncomPort=/dev/ttyS0\nInfoInReceiptSlip=1\ntermDataEncoding=1\nBaudRate=9600\nDebugRX=true", 8192) = 311
Line 113: read(5, "", 8192)                       = 0
Line 114: read(5, "", 8192)                       = 0
Line 222: read(5, "7ELF
Line 112: read(5, "#\n#Tue Jan 14 12:28:06 GMT+01:00 2014\ncurrencyCode=440\nlogFileName=dbg.log\nport=4462\ncommunicationForward=true\nterminalLanguage=4\ntermInterfaces=\ndelLogDaysOld=0\nStopBits=1\nParity=0\nmessagesFileName=language.ini\nDataBits=8\ncomPort=/dev/ttyS0\nInfoInReceiptSlip=1\ntermDataEncoding=1\nBaudRate=9600\nDebugRX=true", 8192) = 311
Line 112: read(5, "#\n#Tue Jan 14 12:28:06 GMT+01:00 2014\ncurrencyCode=440\nlogFileName=dbg.log\nport=4462\ncommunicationForward=true\nterminalLanguage=4\ntermInterfaces=\ndelLogDaysOld=0\nStopBits=1\nParity=0\nmessagesFileName=language.ini\nDataBits=8\ncomPort=/dev/ttyS0\nInfoInReceiptSlip=1\ntermDataEncoding=1\nBaudRate=9600\nDebugRX=true", 8192) = 311
Line 113: read(5, "", 8192)                       = 0
Line 114: read(5, "", 8192)                       = 0
Line 222: read(5, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%P/%pre%%pre%04%pre%%pre%%pre%x4%pre%%pre%%pre%%pre%%pre%04%pre% %pre%%pre%(%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%00%pre%%pre%00%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%00%pre%%pre%00%pre%%pre%00%pre%%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%40%pre%%pre%40%pre%%pre%40%pre%%pre%0%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%Q5td%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%5%pre%%pre%%pre%6%pre%%pre%%pre%i%pre%%pre%%pre%%pre%%pre%%pre%{%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%c%pre%%pre%%pre%l%pre%%pre%%pre%3%pre%%pre%%pre%~%pre%%pre%%pre%%pre%%pre%%pre%%pre%4%pre%%pre%%pre%Z%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%4%pre%%pre%%pre%2%pre%%pre%%pre%7%pre%%pre%%pre%\r%pre%%pre%%pre%%pre%%pre%%pre%%pre%X%pre%%pre%%pre%%pre%%pre%%pre%%pre%1%pre%%pre%%pre%6%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%%pre%%pre%%pre%%pre%3%pre%%pre%%pre%%pre%%pre%%pre%0%pre%%pre%%pre%S%pre%%pre%%pre%09%pre%%pre%%pre%[%pre%%pre%%pre%%pre%%pre%%pre%%pre%2%pre%%pre%%pre%U%pre%%pre%%pre%1%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%4%pre%%pre%%pre%5%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%5%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%%pre%%pre%%pre%%pre%3%pre%%pre%%pre%d%pre%%pre%%pre%t%pre%%pre%%pre%%pre%%pre%%pre%%pre%n%pre%%pre%%pre%6%pre%%pre%%pre%%pre%%pre%%pre%%pre%V%pre%%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%1%pre%%pre%%pre%z%pre%%pre%%pre%1%pre%%pre%%pre%...
Line 232: write(5, "      8643\n", 11)            = 11
Line 233: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 234: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 235: ioctl(5, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 236: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 237: read(5, "", 1)                          = 0
Line 238: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 239: ioctl(5, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 240: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
Line 242: write(5, "      8643\n", 11)            = 11
Line 243: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 244: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 245: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 246: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 247: read(5, "", 1)                          = 0
Line 248: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 249: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 250: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 252: write(5, "      8643\n", 11)            = 11
Line 253: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 254: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 255: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 256: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 257: read(5, "", 1)                          = 0
Line 258: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 259: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 260: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 262: read(5, "      8612\n", 11)             = 11
Line 264: write(5, "      8643\n", 11)            = 11
Line 265: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 266: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 267: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 268: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 269: read(5, "", 1)                          = 0
Line 270: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 271: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 272: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 274: write(5, "      8643\n", 11)            = 11
Line 276: write(5, "      8643\n", 11)            = 11
Line 277: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 278: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 279: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 280: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 281: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 282: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 283: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 284: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
Line 297: write(5, "ddd", 3)                      = 3
Line 305: write(5, "fff", 3)
%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%P/%pre%%pre%04%pre%%pre%%pre%x4%pre%%pre%%pre%%pre%%pre%04%pre% %pre%%pre%(%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%00%pre%%pre%00%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%00%pre%%pre%00%pre%%pre%00%pre%%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%40%pre%%pre%40%pre%%pre%40%pre%%pre%0%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%Q5td%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%5%pre%%pre%%pre%6%pre%%pre%%pre%i%pre%%pre%%pre%%pre%%pre%%pre%{%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%c%pre%%pre%%pre%l%pre%%pre%%pre%3%pre%%pre%%pre%~%pre%%pre%%pre%%pre%%pre%%pre%%pre%4%pre%%pre%%pre%Z%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%4%pre%%pre%%pre%2%pre%%pre%%pre%7%pre%%pre%%pre%\r%pre%%pre%%pre%%pre%%pre%%pre%%pre%X%pre%%pre%%pre%%pre%%pre%%pre%%pre%1%pre%%pre%%pre%6%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%%pre%%pre%%pre%%pre%3%pre%%pre%%pre%%pre%%pre%%pre%0%pre%%pre%%pre%S%pre%%pre%%pre%09%pre%%pre%%pre%[%pre%%pre%%pre%%pre%%pre%%pre%%pre%2%pre%%pre%%pre%U%pre%%pre%%pre%1%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%0%pre%%pre%%pre%%pre%%pre%%pre%%pre%4%pre%%pre%%pre%5%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%5%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%%pre%%pre%%pre%%pre%3%pre%%pre%%pre%d%pre%%pre%%pre%t%pre%%pre%%pre%%pre%%pre%%pre%%pre%n%pre%%pre%%pre%6%pre%%pre%%pre%%pre%%pre%%pre%%pre%V%pre%%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%1%pre%%pre%%pre%z%pre%%pre%%pre%1%pre%%pre%%pre%... Line 232: write(5, " 8643\n", 11) = 11 Line 233: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 234: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 235: ioctl(5, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 236: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 237: read(5, "", 1) = 0 Line 238: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 239: ioctl(5, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 240: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0 Line 242: write(5, " 8643\n", 11) = 11 Line 243: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 244: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 245: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 246: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 247: read(5, "", 1) = 0 Line 248: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 249: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 250: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 252: write(5, " 8643\n", 11) = 11 Line 253: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 254: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 255: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 256: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 257: read(5, "", 1) = 0 Line 258: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 259: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 260: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 262: read(5, " 8612\n", 11) = 11 Line 264: write(5, " 8643\n", 11) = 11 Line 265: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 266: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 267: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 268: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 269: read(5, "", 1) = 0 Line 270: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 271: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 272: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 274: write(5, " 8643\n", 11) = 11 Line 276: write(5, " 8643\n", 11) = 11 Line 277: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 278: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 279: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 280: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 281: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 282: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 283: ioctl(5, SNDCTL_TMR_START or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 284: ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0 Line 297: write(5, "ddd", 3) = 3 Line 305: write(5, "fff", 3)
    
por vico 31.01.2014 / 19:54

1 resposta

1

Verifique se você tem um syscall próximo seguido por outro aberto que recebe o fd 5 antes de qualquer um dos dados enviados / recebidos da porta serial.

O que eu acredito que está acontecendo é que ele está lendo o arquivo de configuração, fechando-o e abrindo a porta serial. Adicione tanto abrir e fechar a sua lista de syscalls para rastrear.

    
por 31.01.2014 / 20:08