0

I have written a small application in Java that writes two strings – 'dddd' and 'ffff' – to a com port. I used strace -s9999 -o serialtrace.log -eread,write,ioctl to inspect how it writes.

I found that com port descriptor is 5, but there is a strange line reading information that I don’t write to the com port:

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

This info is in a configuration file. What is that?

Strace’s filtered output is:

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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P/\0\0004\0\0\0x4\2\0\0\0\0\0004\0 \0\4\0(\0\34\0\31\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\250\0\0\310\250\0\0\5\0\0\0\0\20\0\0\1\0\0\0\310\250\0\0\310\270\0\0\310\270\0\0\34\3\0\0\330\4\0\0\6\0\0\0\0\20\0\0\2\0\0\0\334\250\0\0\334\270\0\0\334\270\0\0\320\0\0\0\320\0\0\0\6\0\0\0\4\0\0\0Q\345td\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7\0\0\0\4\0\0\0\305\0\0\0\306\0\0\0i\0\0\0\23\0\0\0{\0\0\0\220\0\0\0\0\0\0\0c\0\0\0l\0\0\0\243\0\0\0~\0\0\0\0\0\0\0\234\0\0\0Z\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\254\0\0\0\212\0\0\0\247\0\0\0\r\0\0\0\0\0\0\0X\0\0\0\0\0\0\0\241\0\0\0\206\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\217\0\0\0\0\0\0\0\263\0\0\0\20\0\0\0\200\0\0\0S\0\0\0009\0\0\0[\0\0\0\0\0\0\0\262\0\0\0U\0\0\0\231\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\270\0\0\0\0\0\0\0\304\0\0\0\235\0\0\0\0\0\0\0\0\0\0\0\305\0\0\0\0\0\0\0\0\0\0\0\257\0\0\0\0\0\0\0\223\0\0\0d\0\0\0t\0\0\0\0\0\0\0n\0\0\0\246\0\0\0\0\0\0\0V\0\0\0\0\0\0\0\267\0\0\0\271\0\0\0z\0\0\0\301\0\0\0\27...
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)
  • Next time when you want to find out what file descriptor 5 is for, have a look at /proc/PID/fd/5 – Thorsten Staerk Dec 27 '14 at 14:09
  • 1
    it is a read, so this is sent from the serial port. What device do you have attached there? – Thorsten Staerk Dec 27 '14 at 14:11
1

Check if you have a close syscall followed by another open that gets assigned fd 5 before any of the data sent/received from the serial port.

What I believe is happening is that it's reading the configuration file, closing it, then opening the serial port. Add both open and close to your list of syscalls to trace.

  • But how to recognize syscal that opens and closes fd – vico Feb 6 '14 at 7:52
  • 1
    They’re named open and close, @vico. :-) – Palec Apr 18 '15 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.