I want to configure client/server communication via IP with a KAREL program. Setting the system files as needed works fine, only I can't update the state. When I run the program below, it shows that the server settings I changes as state 'STARTED', but it's not actually started (after a restart it's back to 'UNDEFINED'). When manually updating these settings, you need to cycle the state from UNDEFINED>DEFINED>STARTED, which I tried to reproduce in the KAREL code, only it doesn't work.
EDIT: found the true root of the problem: after changing the ip configuration settings (lines 9-13), you should also set the $HOSTS_CFG.$OPER variable to 3 (line 14).
Code
-- configure_IP.kl
PROGRAM configure_IP
%NOLOCKGROUP
VAR
status : INTEGER
server_nr : INTEGER
BEGIN -- main, configure_IP
server_nr = 4
$HOSTS_CFG[server_nr].$STATE = 1 -- 1 UNDEFINED, 2 DEFINED, 3 STARTED
$HOSTS_CFG[server_nr].$PROTOCOL = 'SM'
$HOSTS_CFG[server_nr].$STRT_REMOTE = '10.10.160.21'
$HOSTS_CFG[server_nr].$STATE = 2 -- 1 UNDEFINED, 2 DEFINED, 3 STARTED
$HOSTS_CFG[server_nr].$STATE = 3 -- 1 UNDEFINED, 2 DEFINED, 3 STARTED
$HOSTS_CFG[server_nr].$OPER = 3
END configure_IP
Display More