Python calls Moxa PCOMM Lite to send files through the serial Ymodem protocol,

Source: Internet
Author: User

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)



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.