Code: Select all
for i in range(200):
s.send( b'PKT #' + bytes([i]))
#time.sleep( 4 )
rx = s.recv( 256 ) # The bufsize argument of 256 used is the maximum amount of data to be received at once.
if rx: # if you receive any thing from the Gateway printed than go to sleep again
print(rx) # If there's something received , Print it...if rx is empty, the socket will terminate
time.sleep( 6 )
and organize those data like stream of bytes my real packet will look like :
Data = [A,213,3255,27,10,0x2342]
when i try to use the same socket method to send those data it fails , i realized that the problem is that the bytes can only contains
from 0 ->255 so i used the following lines :
Code: Select all
i1 = 3255
i2 = 0x2342
for i in range(200):
to_send = bytes([ord('A'),213]) + i1.to_bytes(2,'big') + bytes([27, 10]) + i2.to_bytes(2,'big')
s.send(to_send )
NotImplementedError: for the line : s.send(to_send ) .......The wearied thing is that the same data construction will work fine
if it was tested on a python IDE which is very confusing !!....when i tested the method .to_bytes() inside a print statement i get an error.
Kindly help me to solve this issue ?