1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_GroupBox():#object):
def UDP_COMM():
print 'cest parti'
IP = "192.168.1.17"
PORT = 31313
Message = "55032002"
Data = Message.decode('hex')
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
## print "j'envoi : ",Message
s.sendto(Data,(IP,PORT))
flag = 1
while flag == 1:
data,addr = s.recvfrom(1024)
## print "addresse :",addr
datahex = ':'.join(x.encode('hex') for x in data)
## print "message recu (1): ",datahex
if datahex != '':
flag = 0
tampon = datahex.replace(':00:',':0a:')
tampon2 = tampon[12:len(tampon)-3].replace(':','')
messagedecode = (bytearray.fromhex(tampon2).decode())
## print "Message recu (2): \n",messagedecode
return messagedecode,Message
def acquisition():
global ToSend
global ToReceive
messagedecode, messageenvoye = UDP_COMM()
date = time.strftime("%d/%m/%Y %H:%M:%S")
try:
ToSend = ToSend + "\n" + date + " >>> " + messageenvoye
ToReceive = ToReceive + "\n" + date + " >>> " + messagedecode
except:
ToSend = date + " >>> " + messageenvoye
ToReceive = date + " >>> " + messagedecode
def wrapper():
test()
def test():
print "salut"
def setupUi(self,GroupBox):
GroupBox.setObjectName("GroupBox")
GroupBox.resize(400, 320)
self.pushButton = QtWidgets.QPushButton(GroupBox)
self.pushButton.setGeometry(QtCore.QRect(280, 210, 113, 32))
self.pushButton.setObjectName("pushButton")
self.MaZoneText1 = QtWidgets.QTextEdit(GroupBox)
self.MaZoneText1.setGeometry(QtCore.QRect(10, 30, 241, 141))
self.MaZoneText1.setReadOnly(True)
self.MaZoneText1.setObjectName("MaZoneText1")
self.MaZoneText1.append('salut')
self.retranslateUi(GroupBox)
QtCore.QMetaObject.connectSlotsByName(GroupBox)
## self.pushButton.clicked(connect(wrapper)) ## <<<< probleme à ce niveau voir dans Quote
def retranslateUi(self,GroupBox):
_translate = QtCore.QCoreApplication.translate
GroupBox.setWindowTitle(_translate("GroupBox", "GroupBox"))
GroupBox.setTitle(_translate("GroupBox", "GroupBox"))
self.pushButton.setText(_translate("GroupBox", "Envoyer")) |
Partager