Shop OBEX P1 Docs P2 Docs Learn Events
txUDP nightmare; lacking PORT understanding? — Parallax Forums

txUDP nightmare; lacking PORT understanding?

UltraLazerUltraLazer Posts: 30
edited 2011-07-27 21:01 in Accessories
Hi, yet another txUDP issue... I'm sorry if this issue has been addressed already

I have been able to recieve UDP packets on the spinneret but I'm not sure I understand how the wiznet chip formats the port. My understanding is that the 2 bytes following the ip in the packet represent the port (destination or source? encoded how?)

192 168 1 2 238 48 0 16 47 PWR/1/0 ,i0 0 0 0 0 1 0 - Message sent to port 5555 @ 192.168.1.255

192 168 1 2 222 11 0 16 47 PWR/1/0 ,i0 0 0 0 0 1 0 - Message sent to 5555 @ spinnerets ip 192.168.1.101

Im not sure why byte 5 and 6 are showing difrent pot numbers depending on what IP it is sent to.

I am looking to rx on 5555 and tx to 5554 but the following

ETHERNET.SocketOpen(0, ETHERNET#_UDPPROTO, 5555, 5554, @destIP[0]) does not seem to work either.

Even leaving the udp echo demo as is from the obex (with new ip's) I am not able to receive any packets on my pc. I can receive UDP packets on the PC from devices that aren't the spinneret. I have no problem receiving but sending... no go.

I'm as stuck as I can get and would truly appreciate any insight on this.
Thanks

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-07-27 21:01
    The port is byte 4 and 5, zero based. Therefore, bytes 0, 1, 2, and 3 are the IP.
    byte[4] = $13
    byte[5] = $88
    
    $1388 = 5000
    

    Byte 6 and 7 are the content length and work the same as the port.
    byte[4] = $00
    byte[5] = $04
    
    $0004 = 4
    

    Bytes 8+ are the content.
Sign In or Register to comment.