I'm trying to use the KAREL programs TCP server tools to set up a remote connection with a robot. However, I can't connect to the TCP server, and I can't figure out what is causing the error codes I'm seeing right now. Here is my current code, which is mostly based on the example code in the Fanuc docs:
PROGRAM handshake
%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
-------------------------------------------------------------------------------
CONST
tcp_device = 'S3:'
-------------------------------------------------------------------------------
VAR
tcp_socket : FILE
bytes_recv : INTEGER
tmp_str : STRING[128]
status : INTEGER
i : INTEGER
entry: INTEGER
-------------------------------------------------------------------------------
BEGIN
WRITE(CR, CR)
status = 0
SET_FILE_ATR(tcp_socket, ATR_IA)
-- set the server port before doing a connect
SET_VAR(entry, '*SYSTEM*','$HOSTS_CFG[3].$SERVER_PORT',6666,status)
WRITE('SET_VAR status = ', status, entry, CR)
DISMOUNT_DEV(tcp_device, status)
WRITE('DISMOUNT_DEV status = ', status, CR)
MOUNT_DEV(tcp_device, status)
WRITE('MOUNT_DEV status = ', status, CR)
DELAY 250
MSG_PING('192.168.1.241', status)
WRITE('Ping Status = ', status, CR)
WRITE('Disconnecting..',CR)
MSG_DISCO(tcp_device,status)
WRITE('Disconnect status = ', status, CR)
WRITE('Connecting..',CR)
MSG_CONNECT(tcp_device,status)
WRITE(' Connect Status = ',status,CR)
WRITE('Disconnecting..',CR)
MSG_DISCO(tcp_device,status)
WRITE('Done.',CR)
END handshake
Display More
PROGRAM OUTPUT:
SET_VAR status = 0 17235967
DISMOUNT_DEV status = 2008
MOUNT_DEV status = 2008
Ping Status = 0
Disconnecting...
Disconnect status = 2008
Connecting..
After this is reaches the MSG_CONNECT line and just hangs without errors or warnings until I abort. By the way, it does seem to be successfully pinging a device on my network.
Error code 2008 is the File error for illegal characters in the device name. This suggests something is wrong with the 'S3:' device name that I'm using, but that's exactly the device name given in the docs (and I've seen multiple example scripts here using it). I've added all this DISMOUT_DEV and MOUNT_DEV stuff based on other threads just trying to figure out what could be going wrong, no luck yet. Any insights?