y_socket: add help and kill cmd, update usage_cmdl

This commit is contained in:
2025-10-23 11:02:35 +02:00
parent f60538cd69
commit 151daf548d
4 changed files with 34 additions and 26 deletions
@@ -347,7 +347,7 @@ if(/*(qlStatus->nb_episodes %125 == 0) &&*/ pprint->printed){
printf("\n< %5.2f > ( %s ) \n", car->direction, action_name[qlStatus->action % COUNT_ACTION]); printf("\n< %5.2f > ( %s ) \n", car->direction, action_name[qlStatus->action % COUNT_ACTION]);
//print_weight_in_neurons_TYPE_FLOAT(net_main, "net_main_wei"); //print_weight_in_neurons_TYPE_FLOAT(net_main, "net_main_wei");
//PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_main, weight_in, "net_main_we_in"); //PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_main, weight_in, "net_main_we_in");
PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_main, output, "net_main_out"); ///PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_main, output, "net_main_out");
//PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_target, output, "net_target_out"); //PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_target, output, "net_target_out");
//PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_main, input, "net_main_input"); //PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, net_main, input, "net_main_input");
printf(" action : %d , factor : %f nb_episodes : %ld \n",qlStatus->action,rlAgent->qlearnParams->exploration_factor, rlAgent->status->nb_episodes); printf(" action : %d , factor : %f nb_episodes : %ld \n",qlStatus->action,rlAgent->qlearnParams->exploration_factor, rlAgent->status->nb_episodes);
+24 -22
View File
@@ -166,28 +166,30 @@ struct main_list_y_ptr_STRING * split_str_to_main_list_y_ptr_STRING(char *str_or
void usage_cmdl(){ void usage_cmdl(){
printf("usage:\n" printf("usage:\n"
"help: to print this menu.\n"
"kill: to gracefuly kill local socket server.\n"
"sendto [addr] { \"cmd\" : \"[command]\" }\n" "sendto [addr] { \"cmd\" : \"[command]\" }\n"
"addr: ipv4 address or ipv6 address \n" "\taddr: server cible address: ipv4 address or ipv6 address \n"
"\tor all to send cmd to all nodes already in the list.\n" "\t\tor all to send cmd to all nodes already in the list.\n"
"\tor other to send cmd to all nodes excluding local address in the list.\n" "\t\tor other to send cmd to all nodes excluding local address in the list.\n"
"command: \n" "\tcommand: \n"
"\tupdate kill: to gracefully shutdown socket server.\n" "\t\tupdate kill: to gracefully shutdown socket server.\n"
"\tupdate cleanup: to free m_headers lists.\n" "\t\tupdate cleanup: to free m_headers lists.\n"
"\tupdate standby: to suspend all workers, but can receive all task but in queu tasks.\n" "\t\tupdate standby: to suspend all workers, but can receive all task but in queu tasks.\n"
"\tupdate wakeup: to wakeup all workers, and then execute all tasks in queu.\n" "\t\tupdate wakeup: to wakeup all workers, and then execute all tasks in queu.\n"
"\tpipe: to pipe string after header to destination:\n" "\t\tpipe: to pipe string after header to destination:\n"
"\t\teg: sendto 192.168.1.142 { \"cmd\" : \"pipe\" }sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n" "\t\t\teg: sendto 192.168.1.142 { \"cmd\" : \"pipe\" }sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n"
"\t\tIt is equivalent to type: sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n\t\tin node 192.168.1.142.\n" "\t\t\tIt is equivalent to type: sendto 192.168.1.250 { \"cmd\" : \"get file SOME_FILE_LOCAL\" }\n\t\tin node 192.168.1.142.\n"
"\tupdate remove node [addr]: to remove [addr] in the list.\n" "\t\tupdate remove node [addr]: to remove [addr] in the list.\n"
"\tupdate add node [addr]: to add [addr] in the list.\n" "\t\tupdate add node [addr]: to add [addr] in the list.\n"
"\tget file [filename]: to ask server to send file named [filename].\n" "\t\tget file [filename]: to ask server to send file named [filename].\n"
"\t\tfilename can be absolute path or relative working directory path\n" "\t\t\tfilename can be absolute path or relative working directory path\n"
"\t\teg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" }\n" "\t\t\teg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" }\n"
"\t\twe can specify destination directory eg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" , \"dst_dir\" : \"DIRECTORY_NEW_OR_ALREADY_EXISTS\" }\n" "\t\t\twe can specify destination directory eg: sendto 192.168.1.142 { \"cmd\" : \"get file FILENAME\" , \"dst_dir\" : \"DIRECTORY_NEW_OR_ALREADY_EXISTS\" }\n"
"\tpost file [filename] : to send file [filename] after header.\n" "\t\tpost file [filename] : to send file [filename] after header.\n"
"\t\tNeed to add \"seq\" and \"tm\" keys to have good handling, the payload is after the header {}\n" "\t\t\tNeed to add \"seq\" and \"tm\" keys to have good handling, the payload is after the header {}\n"
"\t\tSee y_socket_send_file_for_node function.\n" "\t\t\tSee y_socket_send_file_for_node function.\n"
"\tpost ok [filenameid]: to acknowledge receipt [filename].\n" "\t\tpost ok [filenameid]: to acknowledge receipt [filename].\n"
"\t\t[filenameid] is to precise witch [filename] (file name from whom and when)\n" "\t\t\t[filenameid] is to precise witch [filename] (file name from whom and when)\n"
); );
} }
+6
View File
@@ -587,6 +587,12 @@ if(buf_len>6){
} }
} }
}else if(buf_len && strncmp(buf, "help", 4)==0){
usage_cmdl();
}else if(buf_len && strncmp(buf, "kill", 4)==0){
pthread_mutex_lock(argSock->mut_go_on);
argSock->go_on = 0;
pthread_mutex_unlock(argSock->mut_go_on);
} }
} }
+2 -2
View File
@@ -190,12 +190,12 @@ TEST(pollThread){
wait_var_set_up_value_not_equal(var, 0); wait_var_set_up_value_not_equal(var, 0);
EXPECT_EQ(var->set_up,1); EXPECT_EQ(var->set_up,1);
/*
char buf[] = "sendto 192.168.1.250 { \"cmd\" : \"get file __exode.txt\" }"; char buf[] = "sendto 192.168.1.250 { \"cmd\" : \"get file __exode.txt\" }";
size_t len_buf = strlen(buf); size_t len_buf = strlen(buf);
set_cmd_to_socket(buf, len_buf, var); set_cmd_to_socket(buf, len_buf, var);
*/
/* /*
struct argdst dstarg={ struct argdst dstarg={
.port="1600", .port="1600",