简体   繁体   中英

Python TCP/IP - sending commands

I have telescope a it is managed with PLC siemens. This telescope is remote. I have group of the commands which i can send by TCP/IP to execute. This commands are in ASCII format. Here is simple example of script:

import socket


TCP_IP = ''
TCP_PORT = 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send('GLLG 0\r\n')
s.send('DOSO 0\r\n')
data = s.recv(1024)
print data
s.close()

I send two commands. First is for login a second is for opening dome. But I have two half dome. When I send this command for opening dome it is opened only one half of dome.

But takes some time before half-dome opens and I must wait for send next command to open whole dome. My question is?

Is it possible to follow instructions?

When make one command send another automatically?

Wait until execute one command and after this send next command?

If the PLC will send a response back of some sort that confirms that the open of the dome is complete please read that and then send the next command.

Also make sure you send all your strings as binary unless your PLC can handle unicode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM