Hello,
I need to send a UDP package with this function( netUDP_Send )
https://www.keil.com/pack/doc/mw/Network/html/group__udp__user__api.html#ga7a82db98b82300e5fd03ce1b7afb6cba
But I don't have remote IP and Port number. I have added a new variable to get remote IP and Port number but it shows me an error.
NET_ADDR4 addrUDP;uint32_t udp_cb_func (int32_t socket, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { addrUDP=addr; return 0;}
How can I send a UDP package?
Thank you all for your cooperation.
After compiling the project:
NET_ADDR4 addrUDP={ NET_ADDR_IP4, 2050, 192, 168, 1, 10 }; uint32_t udp_cb_func (int32_t socket, const NET_ADDR *addr, const uint8_t *buf, uint32_t len) { addrUDP=addr; return 0; }
Here is the error:
Configuration.c(158): error: #513: a value of type "const NET_ADDR *" cannot be assigned to an entity of type "NET_ADDR4"
In addition for ping command it lost some of my packages which is annoying.
Parisa Mohamadi said:for ping command it lost some of my packages
So you're going to have to find if that's due to your system, or issues in your network - or both ...
Thank you so much, I have changed my code to:
NET_ADDR addrUDP; uint32_t udp_cb_func (int32_t socket, NET_ADDR *addr, const uint8_t *buf, uint32_t len) { addrUDP.addr_type=*addr->addr_type; addrUDP.port=*addr->port; addrUDP.addr=*addr->addr; return 0; }
But I got this error:
error: #75: operand of "*" must be a pointer addrUDP.addr_type=*addr->addr_type;
In addition I have changed to:
addrUDP.addr_type=addr->addr_type; addrUDP.port=addr->port; addrUDP.addr=addr->addr;
But I got:
error: #137: expression must be a modifiable lvalue
I removed addrUDP.addr=addr->addr; but still it doesn't work. I just broadcast my UDP package to receive it in all network.
Whenever you get a message telling you that you must do something - do it!
That message tells you:
operand of "*" must be a pointer
So do that!
View all questions in Keil forum