Python calls Moxa PCOMM Lite to send files through the serial Ymodem protocol,
This article is written in python 2.7.
After a long search, we finally found Moxa PCOMM Lite. PCOMM. DLL can be called to conveniently transmit files through serial Xmodem, Ymodem, Zmodem, and other protocols without the need to duplicate the wheel.
PCOMM Lite 1.6 is applicable to win7 and other systems. As dll files, you can use any programming languages that support calling dll, such as VC ++, VB, and Qt, to compile applications.
Http://www.moxa.com/drivers/pcommlite/win2k/setup_pcommlite_1.6_12041917.zip
The following is the python code of the sender.
1 # encoding = UTF-8 2 3 from ctypes import * 4 5 dll = windll. loadLibrary ("PCOMM. DLL ") 6 7 port = 2 # specify the serial port COM2 8 9 dll. sio_open (port) 10 11 dll. sio_ioctl (port, 15, 0x00 | 0x03 | 0x00) #57600, no verification, 8-Bit Data bit, 1-bit stop bit 12 13 def cb (xmitlen, buflen, pbuf, flen): 14 print xmitlen, flen, 15 print 16 return xmitlen17 18 CALLBACK = WINFUNCTYPE (c_int, c_long, c_int, POINTER (c_char), c_long) 19 20 ccb = CALLBACK (cb) 21 22 dll. sio_ftymodectx (port, "e: \ test.jpg", ccb, 0) 23 24 dll. sio_close (port)