Fixing w5500.

This commit is contained in:
TXuian 2022-12-10 12:02:04 +08:00
parent 8c45ff21f7
commit e6eca0a36a
1 changed files with 10 additions and 7 deletions

View File

@ -306,23 +306,26 @@ uint32_t wiz_client_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
}
}
void wiz_client_op_test(char *addr, uint16_t port, char *msg) {
void wiz_client_op_test(int argc, char *argv[]) {
/* argv[1]: ip
* argv[2]: port
* argv[3]: msg
*/
if (argc != 4) {
KPrintf("wiz_client_op <ip> <port> <msg>");
}
uint8_t client_sock = 2;
uint8_t ip[4] = {192, 168, 31, 127};
uint32_t port = atoi(argv[2]);
uint32_t tmp_ip[4];
KPrintf("wiz client to %s", addr);
sscanf(addr, "%d.%d.%d.%d", &tmp_ip[0], &tmp_ip[1], &tmp_ip[2], &tmp_ip[3]);
sscanf(argv[1], "%d.%d.%d.%d", &tmp_ip[0], &tmp_ip[1], &tmp_ip[2],
&tmp_ip[3]);
for (int i = 0; i < 4; ++i) {
ip[i] = (uint8_t)tmp_ip[i];
}
KPrintf("wiz client to %s:%d", argv[1], port);
uint8_t buf[g_wiznet_buf_size];
KPrintf("wiz_server, send to %d.%d.%d.%d %d\n", // tip info
ip[0], ip[1], ip[2], ip[3], port);
sscanf(msg, "%s", buf);
sscanf(argv[3], "%s", buf);
wiz_client_op(client_sock, buf, g_wiznet_buf_size, ip, port, SEND_DATA);
MdelayKTask(10);
memset(buf, 0, g_wiznet_buf_size);
@ -331,7 +334,7 @@ void wiz_client_op_test(char *addr, uint16_t port, char *msg) {
KPrintf("received msg: %s\n", buf);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) |
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
SHELL_CMD_PARAM_NUM(3),
wiz_client_op, wiz_client_op_test,
wiz_sock_recv or wiz_sock_send data as tcp client);