Hello,
I'm attempting to use ROBOGUIDE with a CRX-20iA/L controller to run a server that connects with an external Python client.
I'm unable to get an external client to connect with the server; the client times out. I suspect the issue is that the client is using the wrong host or network / subnet configuration.
- Create a new cell
- Setup basic teach pendant configuration
- Create / build KARAL socket script
- Setup server tag as specified by manually
- Run the KARAL program
- Attempt to connect with Python client
The following .gif outlines what I did from start to finish, I expect the ROBOGUIDE user menu to go beyond the connecting.. line
Code
# client.py
import socket
def main():
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('192.168.1.1', 12345))
message = "Hello World"
client_socket.sendall(message.encode('utf-8'))
client_socket.close()
print("Message sent.")
if __name__ == "__main__":
main()
Display More
Code
PROGRAM tcp_server
%STACKSIZE = 4000
%NOLOCKGROUP
%NOPAUSE=ERROR+COMMAND+TPENABLE
%ENVIRONMENT uif
%ENVIRONMENT sysdef
%ENVIRONMENT memo
%ENVIRONMENT kclop
%ENVIRONMENT bynam
%ENVIRONMENT fdev
%ENVIRONMENT flbt
%INCLUDE klevccdf
%INCLUDE klevkeys
%INCLUDE klevkmsk
VAR
file_var : FILE
tmp_int : INTEGER
tmp_int1 : INTEGER
tmp_str : STRING[128]
tmp_str1 : STRING[128]
status : INTEGER
entry : INTEGER
BEGIN
SET_FILE_ATR(file_var, ATR_IA)
SET_VAR(entry, '*SYSTEM*', '$HOSTS_CFG[3].$SERVER_PORT', 12345, status)
WRITE TPPROMPT('Connecting..', status, CR)
MSG_CONNECT('S3', status)
WRITE TPPROMPT('Connect Status = ', status, CR)
IF status = 0 THEN
WRITE TPPROMPT('Opening', CR)
FOR tmp_int1 = 1 TO 20 DO
OPEN FILE file_var ('rw', 'S3:')
status = IO_STATUS(file_var)
WRITE TPPROMPT(status, CR)
IF status = 0 THEN
FOR tmp_int = 1 TO 1000 DO
WRITE TPPROMPT('Reading', CR)
BYTES_AHEAD(file_var, entry, status)
WRITE TPPROMPT(entry, status, CR)
READ file_var (tmp_str::10)
status = IO_STATUS(file_var)
WRITE TPPROMPT(status, CR)
ENDFOR
CLOSE FILE file_var
ENDIF
ENDFOR
WRITE TPPROMPT('Disconnecting..', CR)
MSG_DISCO('S3:', status)
WRITE TPPROMPT('Done.', CR)
ENDIF
END tcp_server
Display More
Error code from client side
Code
C:\Users\shawn\OneDrive\Desktop\ur_client>python client.py
Traceback (most recent call last): File "C:\Users\shawn\OneDrive\Desktop\ur_client\client.py", line 14, in <module> main() File "C:\Users\shawn\OneDrive\Desktop\ur_client\client.py", line 5, in main client_socket.connect(('192.168.1.100', 12345))
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond