M
Hi everybody! It was fun for a while, but now I'm strating to go crazy!
I wrote a code to send an ASCII command to an ADAM-6017 module through the ethernet using Python. I considered the module a server and my computer the client. The client would like to ask for the value of the 8 analogue inputs in the module, and get back that response. If I do this actions with the software that comes with the ADAM module, it gives me the answer that I would expect. However, when doing it with python, it doesn't. The code goes as follows....:
-------------------------------------------------
import socket
host='141.xxx.xxx.xx'
##(I am not sure which IP address to put here. If I put the Internet IP address of the computer I'm working with, it doesn't give me an error. If I put the module's IP address, which is the same as the computers changing the last digit, it sais 'errno 10049 the requested address is not valid in its context')
buf=1024
port=5002
addr=(host,port)
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(addr)
s.sendto('#01\r', addr)
indata, inaddr = s.recvfrom(buf)
------------------------------------------------
NOTE= the \ on the command is an inverted bar, for some reason it appears like than on the forum!
also there's no space between soc and ket.
--------------------------------------------------
indata and iaddr give me '#01\r' and the IP address. But what I want is the response of the module when we give it the command '#01'! I don't know what I'm doing wrong.
Is it ok to put the computer's IP addres?
Does this server/client structure make sense?
Do I have to write a code for the server (ADAM), and in that case, where do I run it?
Thank you very much for sharing your knowledge, I seriously appreciate it. Best,
Maria E.
memorell [at] umich.edu
I wrote a code to send an ASCII command to an ADAM-6017 module through the ethernet using Python. I considered the module a server and my computer the client. The client would like to ask for the value of the 8 analogue inputs in the module, and get back that response. If I do this actions with the software that comes with the ADAM module, it gives me the answer that I would expect. However, when doing it with python, it doesn't. The code goes as follows....:
-------------------------------------------------
import socket
host='141.xxx.xxx.xx'
##(I am not sure which IP address to put here. If I put the Internet IP address of the computer I'm working with, it doesn't give me an error. If I put the module's IP address, which is the same as the computers changing the last digit, it sais 'errno 10049 the requested address is not valid in its context')
buf=1024
port=5002
addr=(host,port)
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(addr)
s.sendto('#01\r', addr)
indata, inaddr = s.recvfrom(buf)
------------------------------------------------
NOTE= the \ on the command is an inverted bar, for some reason it appears like than on the forum!
also there's no space between soc and ket.
--------------------------------------------------
indata and iaddr give me '#01\r' and the IP address. But what I want is the response of the module when we give it the command '#01'! I don't know what I'm doing wrong.
Is it ok to put the computer's IP addres?
Does this server/client structure make sense?
Do I have to write a code for the server (ADAM), and in that case, where do I run it?
Thank you very much for sharing your knowledge, I seriously appreciate it. Best,
Maria E.
memorell [at] umich.edu