Connection to the server server failed err_t == -4. Wireshark didn't detect any request for connection to server (to pc ip: *, *, 6, 110).
Have you some experiences? Some lwipopt for tcp client ... anything?
Error output:
[018.434] [./src/ethcomm.c:ethCommThread] start client thread
[018.442] [./src/ethcomm.c:ethCommThread] binded: 0, state: 0
[018.447] [./src/ethcomm.c:ethCommThread] connected: -4, state: 0
Code: Select all
static void ethMacAddress(struct lwipthread_opts *ipSettings)
{
uint8_t mac[6];
mac[0] = 0x06;
mac[1] = 0x*;
mac[2] = 0x*;
mac[3] = 0x02;
mac[4] = 0x03;
mac[5] = 0x04;
dhexprint(mac, 6);
ipSettings->macaddress = mac;
}
static void ethIpSettings(struct lwipthread_opts *ipSettings)
{
ip_addr_t ip, netmask;
IP4_ADDR(&ip, *, *, 6, 102);
ipSettings->address = ip.addr;
IP4_ADDR(&netmask, 255, 255, 255, 0);
ipSettings->netmask = netmask.addr;
ipSettings->addrMode = NET_ADDRESS_STATIC;
}
static THD_WORKING_AREA(ethThread_wa, 2048);
static thread_t *ethThread = NULL;
static THD_FUNCTION(ethCommThread, arg)
{
(void) arg;
dprint("start client thread\n");
chRegSetThreadName("tcp_client");
struct netconn *conn;
err_t err;
/* Create a new TCP connection handle */
conn = netconn_new(NETCONN_TCP);
LWIP_ERROR("tcp client: invalid conn", (conn != NULL), chThdExit(MSG_RESET););
/* Bind to port 2000 with default IP address */
err = netconn_bind(conn, IP_ADDR_ANY, 2000);
dprint("binded: %d, state: %d\n", err, conn->state);
ip_addr_t serverIp;
IP4_ADDR(&serverIp, *, *, 6, 110);
err = netconn_connect(conn, &serverIp, 6000);
dprint("connected: %d, state: %d\n", err, conn->state);
}
uint8_t ethernetInit()
{
struct lwipthread_opts ipSettings;
ethIpSettings(&ipSettings);
ethMacAddress(&ipSettings);
lwipInit(&ipSettings);
ethThread = chThdCreateStatic(ethThread_wa, sizeof(ethThread_wa), NORMALPRIO, ethCommThread, NULL);
return 0;
}