SetSocketOption Multicast Panda II

I am attempting to send multicast packets using the Panda II and get an exception when trying to configure SetSocketOption. Does the Panda support multicasting? Is there another way to configure the socket? Any suggestions? Thank you.



            byte[] data = new byte[512];

            byte[] ip = { 192, 168, 1, 200 };
            byte[] subnet = { 255, 255, 255, 0 };
            byte[] gateway = { 192, 168, 1, 1 };
            byte[] mac = { 0x00, 0x26, 0x1C, 0x7B, 0x29, 0xE8 };


            // create an ipaddress object based on multicast  
            IPAddress multicastIPAddress = new IPAddress(new byte[] { 239, 255, 0, 1 });

            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di7, true); // WIZnet interface with FEZ Connect
            NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
            NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });
                  
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

           socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, multicastIPAddress.GetAddressBytes());
           socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 1);

            IPAddress DestinationIP = new IPAddress(new byte[] { 239, 255, 0, 1 });
            IPEndPoint DestinationEndPoint = new IPEndPoint(DestinationIP, 5568);


Exception System.Exception - 0x00000000 (4)

#### Message: Not Supported Methord
#### GHIElectronics.NETMF.Net.SocketNative::setsockopt [IP: 0006] ####
#### GHIElectronics.NETMF.Net.Sockets.Socket::SetSocketOption [IP: 0012] ####
#### Program::MyThread [IP: 00ba] ####

A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.W5100.dll
An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.W5100.dll

Additional information: Not Supported Methord

The Ethernet support on panda is minimal http://www.ghielectronics.com/catalog/compare/

You can still do multicast but you need to add the needed support. See Wiznet datasheet for w5100.

Welcome to the community.

So, with the Hydra or Cobra I would be able to use System.Net.Sockets and the SetSocketOption? Thank you.

Haven’t testers multicast myself by it should work.

I-Phone strikes again Gus :slight_smile:

Lemme translate: “Haven’t tested multicast myself, but it should work”

That is what happens when you use an iphone at 7AM Saturday morning :slight_smile:

Thanks for the translation

Thanks. Is there any way you could test to see if those SetOptions methods work? I want to order a Hyrda but want to ensure multicasting will work. Thanks.

Hi Mickpat,

I ran the these four lines of code without any exception on my Hydra:


IPAddress multicastIPAddress = new IPAddress(new byte[] { 239, 255, 0, 1 });
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, multicastIPAddress.GetAddressBytes());
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 1);

If there is a small test program for Multicasting that you would like us to test please provide the code and we will test it for you to ensure that what you are requiring will absolutely work.

Thank you Aaron for running that test. Very helpful.

I have been reading though the Wiznet data sheet and it looks like you can specify the Mutlicast option and TTL.

From the data sheet

Sn_TTL (Socket n IP Time To Live Register) [R/W] [0x0416,0x0516,0x0616,0x0716] [0x80]
This register sets up at the TTL(Time To Live) Field of IP Header.

Sn1_MR (Socket n Mode Register) [R/W] [0x0400, 0x0500, 0x0600, 0x0700] [0x00]2
This register sets up socket option or protocol type for each socket.

Bit 7 is used to enable multicast.

Can I set these using registers?


Register PCONP = new Register(0x?);

Hi Mick,

no fundamentally the register access that code is talking about is the CPU registers. The only way to interface with the Wiz chip is over it’s SPI connection, and in this case I suspect you would have to extend the GHI provided functions that handle this. Joe might need to comment here, he is the guru of the Wiz stack…

Thanks Bret.

Reading though some other posts, I see that internally the following is called to set registers, but this method doesn’t appear to be exposed.


W5100.RegisterWrite(s, W5100.SocketRegisters.CR, (byte)CR_val.Sn_CR_RECV);

I would like to set the following register, but not sure how to send this command to WizNet.


// S0_MR values
const ushort S0_MR = 0x0400;    // Socket 0: Mode Register Address

Looking at some other sample code, they use the following to set registers.


 _cmdConfig = new SPI.Configuration((Cpu.Pin)7, false, 0, 0, false, true, 2000, 0);    
                        
cmdBuffer[0] = CMD_WRITE;
cmdBuffer[1] = register;
cmdBuffer[2] = (byte)(data >> 8);
cmdBuffer[3] = (byte)data;

_cmdConfig.Write(cmdBuffer);

Any suggestions?

Yep, my suggestion is to wait for Joe. J…O…E… ! :stuck_out_tongue:

Joe is drowning in moving our libraries to NETMF 4.2. Multicast is surly an option of Wiznet chips but it is not supported directly by what we offer currently but that doesn’t mean you can’t add it.