Hello,
I am currently trying to send binary data out through pexpect. For some reason, the data gets through just find except for a 0x04, which is just skipped over. I tracked down the pexpect call to determine that all thats happening is an os.write() call to a file descriptor opened from a pty.fork() command.
Any ideas?
(example code that exemplifies the problem)
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])
Result:
$ python test.py
'hmm'
27 68 6D 6D 27 0A