---
title: "W5300에서 udp통신으로 값읽어올때요"
url: "https://maker.wiznet.io/forum/11363"
markdown_url: "https://maker.wiznet.io/forum/11363/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "beachrain"
created: "2015-10-08T05:56:02+09:00"
last_activity: "2017-05-04T08:37:07+09:00"
language: "en"
views: 663
replies: 2
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5300에서 udp통신으로 값읽어올때요

## Question

Asked by beachrain on 2015-10-08 in Ethernet Chips.

[VB.net](http://VB.net) 에서 W5300에 UDP통신으로 값을 받아오는데 bytes(128)까지는 잘 읽어오는데

bytes(132)부터는 쓰레기값을 읽어들이네요 아래는 소스코드 입니다

Private Sub find()

```
    ListView2.Items.Clear()
    ListView2.SelectedIndices.Clear()
    boardList.Clear()

    Dim bytes() As Byte

    Dim myLocal As New IPEndPoint(IPAddress.Parse("255.255.255.255"), CONFIG_RPORT)
    Dim myRemote As New IPEndPoint(IPAddress.Parse("255.255.255.255"), CONFIG_LPORT)

    Using send1 As New UdpClient(CONFIG_LPORT)
        Try
            bytes = System.Text.Encoding.ASCII.GetBytes("FIND")
            send1.Send(bytes, bytes.Length(), myLocal)
            send1.Client.ReceiveTimeout = 1000
            bytes = send1.Receive(myRemote)
            Do While (bytes.Length > 0)
                If (bytes(0) = Asc("f")) And (bytes(1) = Asc("i")) And (bytes(2) = Asc("n")) And (bytes(3) = Asc("d")) Then
                    Dim boardInfos As New BoardInfo
                    Dim i As Integer

                    boardInfos.mac = ""
                    For i = 6 To 11
                        If Len(Hex(bytes(i))) = 1 Then
                            boardInfos.mac = boardInfos.mac & "0" & Hex(bytes(i)) & ":"
                        Else
                            boardInfos.mac = boardInfos.mac & Hex(bytes(i)) & ":"
                        End If
                    Next i
                    boardInfos.mac = boardInfos.mac.Substring(0, Len(boardInfos.mac) - 1)

                    boardInfos.ver = bytes(4) & "." & bytes(5)
                    boardInfos.ip = bytes(12) & "." & bytes(13) & "." & bytes(14) & "." & bytes(15)
                    boardInfos.subnet = bytes(16) & "." & bytes(17) & "." & bytes(18) & "." & bytes(19)
                    boardInfos.gw = bytes(20) & "." & bytes(21) & "." & bytes(22) & "." & bytes(23)
                    boardInfos.dns = bytes(36) & "." & bytes(37) & "." & bytes(38) & "." & bytes(39)
                    boardInfos.port = (bytes(31) - 48) * 10000 + (bytes(32) - 48) * 1000 + (bytes(33) - 48) * 100 + (bytes(34) - 48) * 10 + (bytes(35) - 48)

                    Dim temp(64) As Byte
                    For i = 0 To 63
                        temp(i) = bytes(40 + i)
                    Next i
                    boardInfos.location = Encoding.Default.GetString(temp)

                    boardInfos.dc1 = bytes(104)
                    boardInfos.dc2 = bytes(108)
                    boardInfos.ch1 = bytes(112)
                    boardInfos.ch2 = bytes(116)
                    boardInfos.ch3 = bytes(120)
                    boardInfos.ch4 = bytes(124)
                    boardInfos.ch5 = bytes(128)
                    boardInfos.ch6 = bytes(132)

                    boardList.Add(boardInfos)
                    ListView2.Items.Add(boardInfos.mac)
                End If
                bytes = send1.Receive(myRemote)
            Loop
        Catch ex As Exception

        End Try
        send1.Close()
    End Using
End Sub
```

선언한 bytes는 256비트까지는 읽어야 정상인데 통신을하면 132부터 짤리네요

손을 대보려해도 코드의 문제인지 W5300칩과 통신할때 용량의 문제인지 모르겠습니다

답신 부탁드립니다…

## Replies

### Reply 1 by beachrain, 2015-10-08

잠시 헷갈렸네요 256비트가 아니라

1바이트로 된 bytes(128) 배열이네요 128바이트가 넘어가면 문제가 되는지 알려 주세요 ~

### Reply 2 by justinkim, 2015-10-14

128KByte가 아니라 128Byte라면 메모리 문제는 아닌것 같네요…

주신 정보만으로는 해결이 어려울 것 같습니다. Wire shark로 UDP data packet을 캡쳐해 보시기 바랍니다.

감사합니다. ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)

---

Source: https://maker.wiznet.io/forum/11363
