Created
November 4, 2018 16:06
-
-
Save basith374/dd5f432b0e75ea188d63cdb8e977e3d8 to your computer and use it in GitHub Desktop.
socket connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
if len(sys.argv) < 2: | |
print('usage: %s <deviceid> <cmd> [<params>]' % (sys.argv[0])) | |
exit() | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(('13.250.41.251', 8008)) | |
deviceid = int(sys.argv[1]) | |
cmd = int(sys.argv[2]) | |
data = bytearray([200]) | |
data = data + deviceid.to_bytes(4, 'big') | |
data.append(cmd) | |
if cmd == 4 or cmd == 5: | |
data.append(int(sys.argv[3])) | |
else: | |
for i in sys.argv[3:]: | |
data = data + int(i).to_bytes(4, 'big') | |
print(data) | |
s.send(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment