三菱FX5U 支持SMTP 协议,可利用Python 的Socket 通信按照三菱的协议格式进行通信,上位机作为客户端,PLC作为服务器
"""
author: alai
date:2018/05/01
"""
import socket
import time
import xlwt,xlrd,struct
from xlutils.copy import copy
import sys
import re,os,sys
data="ok"
class TcpThread(QThread):
trigger = pyqtSignal(str)
trigger1=pyqtSignal(str)
def __int__(self):
super(TcpThread, self).__init__()
# 分离出一个函数用于循环tcp 重连
def doConnect(self):
with open('IP_Address.txt', 'r')as fn:
s1 = fn.read()
host = ''.join(re.findall(r'IP:(.*)', s1)) # 服务器IP地址取出来,并转成字符串
port = int(''.join(re.findall(r'PORT:(.*)', s1))) # 从文本中提取端口号转成整数
BUFFSIZE = int(''.join(re.findall(