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 = ''
TCP_PORT = 8899

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

s.connect((TCP_IP, TCP_PORT))


print Decode_hex
print "decode hex:",Decode_hex

data = s.recv(1024)

print "data recieved :", data
print 'Hexa decimal value deceived:',repr(d)

print 'Hexa decimal value Modified:',repr(mod_hex)

#print 'received',d
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

Edited by ajit.nayak

Attachments MODBUS-REQ1.jpg 436.58 KB
7 Months
Discussion Span
Last Post by ddanbe

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


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

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.