#define CMD_STOP_SIMU 4
int server_port = SERVER_PORT;
+char *server_address;
int sockfd;
struct sockaddr_in serv_addr;
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(server_port);
- serv_addr.sin_addr.s_addr = inet_addr(SERVER_ADDRESS);
+ if (!server_address)
+ server_address = strdup(SERVER_ADDRESS);
+
+ serv_addr.sin_addr.s_addr = inet_addr(server_address);
if (serv_addr.sin_addr.s_addr == INADDR_NONE) {
LOG_ERROR("inet_addr error occured");
if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
close(sockfd);
- LOG_ERROR("Can't connect to %s : %u", SERVER_ADDRESS, server_port);
+ LOG_ERROR("Can't connect to %s : %u", server_address, server_port);
return ERROR_COMMAND_CLOSE_CONNECTION;
}
- LOG_INFO("Connection to %s : %u succeed", SERVER_ADDRESS, server_port);
+ LOG_INFO("Connection to %s : %u succeed", server_address, server_port);
return ERROR_OK;
}
static int jtag_vpi_quit(void)
{
+ free(server_address);
return close(sockfd);
}
return ERROR_OK;
}
+COMMAND_HANDLER(jtag_vpi_set_address)
+{
+ free(server_address);
+
+ if (CMD_ARGC == 0) {
+ LOG_WARNING("You need to set an address");
+ server_address = strdup(SERVER_ADDRESS);
+ } else
+ server_address = strdup(CMD_ARGV[0]);
+
+ LOG_INFO("Set server address to %s", server_address);
+
+ return ERROR_OK;
+}
static const struct command_registration jtag_vpi_command_handlers[] = {
{
.help = "set the port of the VPI server",
.usage = "description_string",
},
+ {
+ .name = "jtag_vpi_set_address",
+ .handler = &jtag_vpi_set_address,
+ .mode = COMMAND_CONFIG,
+ .help = "set the address of the VPI server",
+ .usage = "description_string",
+ },
COMMAND_REGISTRATION_DONE
};
interface jtag_vpi
-# Set the VPI JTAG server address
+# Set the VPI JTAG server port
if { [info exists VPI_PORT] } {
set _VPI_PORT $VPI_PORT
} else {
- set _VPI_PORT 50020
+ set _VPI_PORT 5555
+}
+
+# Set the VPI JTAG server address
+if { [info exists VPI_ADDRESS] } {
+ set _VPI_ADDRESS $VPI_ADDRESS
+} else {
+ set _VPI_ADDRESS "127.0.0.1"
}
jtag_vpi_set_port $_VPI_PORT
+jtag_vpi_set_address $_VPI_ADDRESS