Dear all

I am trying to send request to client device in Hex format and receive data into decimal format. By seeing forum and tutorial class. I could able to send and receive data from client device.Now I wanted to check the data i received valid or not. In order to test it i wanted to convert the data from hex to dec. I am also confused How client data being received here.

My code:

import socket
TCP_IP = '192.168.1.3'
TCP_PORT = 8899
BUFFER_SIZE = 1000

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((TCP_IP, TCP_PORT))

s.send('01030000001d85c3'.decode('hex'))

Decode_hex='01030000001d85c3'.decode('hex')
print Decode_hex
print "decode hex:",Decode_hex

data = s.recv(1024)
s.close()

print "data recieved :", data
d=data.encode('hex').upper()
print 'Hexa decimal value deceived:',repr(d)

mod_hex=data.encode('hex').upper()
print 'Hexa decimal value Modified:',repr(mod_hex)

#print 'received',d
decimal=int(d,16)
print "decimal converted value:",decimal

Here is my out put file

decode hex:

data recieved : :
Hexa decimal value deceived: '01033A0000000D00120041003400410056004B000000000000000000DF000000E1000000E700F800E600EC0000000000000000001F00010001000100DC496E'
Hexa decimal value Modified: '01033A0000000D00120041003400410056004B000000000000000000DF000000E1000000E700F800E600EC0000000000000000001F00010001000100DC496E'
decimal converted value: 214364598880234057828928146607817359105482384449559342919180352622648369076567392756173653847449417881349290133492250705920000000000003670016655364096025643555734

Here is output with wired connection.I expected Outpu like above format
If i used encode ('Hex') i wont get any reply from client device
if i use decode('HEX') i am getting reply like above.

Please guide me to get out from cleint device

I don't understand the issue. You're sending and receiving data. You convert the received
data to hex, then to integer by calling int(d, 16) and you say it confuses you but this is cryptic data and we don't know if it is correct or not so where is the problem ? Do you have an example of valid data that should be expected ?

can you check the pict shared withn wired connection. Based on which i m telling i m not getting proper data.
I found i sending request and getting response. response i got improper

Please refer the image i shared in first thread to understand request and response format

Without a more precise definition of proper request and response, I cannot say which conversion steps you need.

Could you please just explain what your request and response format is all about, so we can understand it and maybe provide an answer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.