現在、pexpect を介してバイナリ データを送信しようとしています。何らかの理由で、スキップされた 0x04 を除いて、データは単に検索を通過します。私は pexpect 呼び出しを追跡して、起こっているのは pty.fork() コマンドから開かれたファイル記述子への os.write() 呼び出しだけであることを確認しました。
何か案は?
(問題を例示するコード例)
import os, pty, sys
pid, child_fd = pty.fork()
if pid: # Parent
os.write(child_fd, b"'\x04hmm\x04'\n")
buf = os.read(child_fd, 100)
print buf
else: # Child
text = sys.stdin.readline()
print ''.join(["%02X " % ord(x) for x in text])
結果:
$ python test.py
'hmm'
27 68 6D 6D 27 0A