PC의 IP는 192.168.35.1 이며, W5300의 IP는 192.168.35.100 입니다.
W5300 에서는 loopback 를 사용하며
tcps 와 udps 가 동작하고 있습니다.
socket 0 = UDP
socket 1 = TCP
아래 메세지는 UDP 에서 recvfrom & sendto 를 수행한 다음
DPORTR 을 읽기 위한 출력 입니다.
아무리 해도 제대로된 값이 나오지 않아 아예 Sn_DHAR부터 6 word를 읽어 출력하였습니다.
getSn_DPORT2 가 6 word 읽는 매크로 입니다.
하지만, DHAR, DPORTR, DIPR 셋 중에서
DPORTR 만 값이 잘못 나옵니다.
실제 사용한 PC포트는 10000 인데 0x2710 입니다.
하지만 W5300의 DPORT 레지스터에는 0x2727 로 잘못된 값이이 들어 있습니다.
For TCP server mode you must set up socket’s source port for W5300 to listen on. When client successfully connects to W5300, socket’s destination port number is set automatically, you do NOT need to set it manually. This DPORTR port number is used by the W5300 socket to send packets to the client matching client’s socket properties so that client can understand its exact socket it received packet for.
This is really not covered by the datasheet. Datasheet only says that you must set source port, but nothing about what to do with destination port. The answer is: you do not need to do anything on destination port, it is already set properly when connection from the client is established.