Understanding the sending of commands in adb shell
the 2nd line sends a request to serial. the 1st line is waiting for result. in order to make this work one must listening before sending request, that way the answer can not missed. one can accomplish that by running the listening process in background while sending request in same time. it is usual like for handling of named pipes