I want to retrieve/get file from serial port on Windows 7 machine via python2.7. I'm trying to do it with xmodem, but unsuccessfully. In the other words, I have connected the Linux router to my PC with a Serial cable and I want to retrieve a file by serial port. And I like to do it in script if possible.
import serial
from xmodem import XMODEM
def getc(size, timeout=1):
return port.read(size)
def putc(data, timeout=1):
port.write(data)
sleep(0.001)
modem = XMODEM(getc, putc)
port = "COM5"
ser = serial.Serial(port, 38400)
x = ser.write('echo "d" >> /tmp/d')
stream = open('/tmp/d', 'wb')
modem.recv(stream)
ser.close()
Where have I made a mistake?
I´m new in Python..
Exception is:
Traceback (most recent call last):
File "C:/Users/tester/Desktop/ITSP/conn_com.py", line 18, in <module>
stream = open('/tmp/d', 'wb')
IOError: [Errno 2] No such file or directory: '/tmp/d'