W5500
SwordfishUser.W5500 History
Hide minor edits - Show changes to markup
This library is compatiblewith this hardware also
This library is compatible with this hardware also
This library is compatiblewith this hardware also
SetAddress(192,168,1,50,@PingAddr)
SetAddress(192,168,1,50,@PingAddr) ' <-- CHANGE YOUR REQ.PING ADDRESS
W5500-Library
W5500-Library
Edit W5500-Socket.bas module and add Connect() function to connect via TCP client. On the module top add :
Include "EEPROM.bas" #option TCP_PORT_ROM_ADDR = 0 Private Const iniTcpPort As Word = 1000, endTcpPort As Word = 2000, eePortAddr = TCP_PORT_ROM_ADDR
On the module bottom add:
{ **************************************************************************** * Name : ComputeLocalPort * * Purpose : * **************************************************************************** } Private Function ComputeLocalPort() As Word ComputeLocalPort = EE.ReadWord(eePortAddr) If (ComputeLocalPort < iniTcpPort) Or (ComputeLocalPort > endTcpPort) Then ComputeLocalPort = iniTcpPort Else Inc(ComputeLocalPort) End If EE.WriteWord(eePortAddr, ComputeLocalPort) End Function { **************************************************************************** * Name : Connect * * Purpose : * **************************************************************************** } Public Function Connect(sock As Byte, pArrIPAddr As Word, _port As Word, flag As Byte) As Boolean result = false If Socket(sock, cSn_MR_TCP, ComputeLocalPort(), $00) Then WriteSocketPtr(sock, rSn_DIPR0, pArrIPAddr, 4) WriteSocketReg(sock, rSn_DPORT0, Byte(_port>>8)) WriteSocketReg(sock, rSn_DPORT0 + 1, Byte(_port And $00FF)) WriteSocketReg(sock, rSn_CR, cSn_CR_CONNECT) While(ReadSocketReg(sock,rSn_CR) = 1 ) // 30/11/2014 End While While ReadSocketReg(sock, rSn_SR)<> cSOCK_ESTABLISHED If (ReadSocketReg(sock, rSn_IR) And cSn_IR_TIMEOUT ) <> 0 Then result = false Exit End If End While result = true End If End Function
These routines allow you to perform a client connection and increase the local port at the last use, avoiding the connection timeout on the server side socket eventually left open earlier.
Added routines to allow a TCP client connection and increase the local port at the last use, avoiding the connection timeout on the server side socket eventually left open earlier.
Updated with PING functionality - March 27, 2015
Here you will find PING functionality test program.
Updated with TCP socket connection - February 28, 2015 (see at bottom)
Updated with TCP socket connection - February 28, 2015
W5500-Ping.bas | IPRAW mode ping module (27/3/2015) |
- Notice : Copyright (c) 2014 *
- Notice : Copyright (c) 2015 *
- Date : 1/11/2014 *
- Date : 27/03/2015 *
Here you will find PING functionality test program.
Here you will find PING functionality test program.
=Code { ***************************************************************************** * Name : W5500-Test-Ping.BAS * * Author : Coccoliso * * Notice : Copyright (c) 2014 * * : All Rights Reserved * * Date : 1/11/2014 * * Version : 1.0 * * Notes : * * : * ***************************************************************************** } Device = 18f2682 Clock = 40 #option WIZ_DHCP_DEBUG = true #option WIZ_DNS_DEBUG = false #option WIZ_PING_DEBUG = false #option WIZ_PING_DISPLAY = true #option USE_DHCP = true #option USE_DNS = false #option USE_PING = true #option WIZ_SCS_PIN = PORTC.0 #option WIZ_RST_PIN = PORTC.1 Include "Config_NOWDT" Include "W5500-Consts" Include "W5500-Utils" Include "W5500" Include "usart" Include "convert" Include "string" #if USE_DNS Include "W5500-DNSConsts" Dim dnsRes As DNS_INFO #endif Private Sub ConfigDisplay() USART.Write(#13,#10) USART.Write("MAC Address ",SARtoString(),#13,#10) USART.Write("IP Address ",SIPRtoString(),#13,#10) USART.Write("Subnet Mask ",SUBRtoString(),#13,#10) USART.Write("Gateway ",GARtoString(),#13,#10) USART.Write("DNS Address ",AddrToString(@Dns_Addr),#13,#10) USART.Write(#13,#10) End Sub #if USE_DHCP Sub OnUpdate() ConfigDisplay() End Sub Sub OnConflict() End Sub #endif Private Function SetAddress(a,b,c,d As Byte, RAMAddr As Word) As Word result = RAMAddr Save(FSR2) FSR2 = RAMAddr POSTINC2 = a POSTINC2 = b POSTINC2 = c INDF2 = d Restore End Function // ################################################################################## // ################################################################################## Dim PingAddr(4) As Byte USART.SetBaudrate(br115200) #if USE_DHCP = true USART.Write("Now find the DHCP server.. ",13,10) DHCPSetEvents(@OnUpdate, @OnConflict) If DHCPTask(3) = false Then USART.Write("DHCP error, so must set static parms.. ",13,10) ConfigDisplay() End If #else USART.Write("Using static config.. ",13,10) ConfigDisplay() #endif DelayMS(1000) #if USE_DNS USART.Write("DNSResolving for www.google.com ... ") dnsRes = DNSResolve("www.google.com") If dnsRes.STATUS = cRC_NO_ERROR Then USART.Write(AddrToString(@dnsRes.IPAddr.Byt),13,10) Else USART.Write("unable to resolve (ERR=",DecToStr(dnsRes.STATUS),")",13,10) End If #endif USART.Write(13,10) USART.Write("My IP is ",SIPRtoString(),13,10) SetAddress(192,168,1,50,@PingAddr) USART.Write("Now call PingAuto()..",13,10) PingAuto(@PingAddr) USART.Write("Now call PingCount() with 10 pings on Socket 0 ..",13,10) PingCount(0,10,@PingAddr) USART.Write("That is all!",13,10) While true End While
Here Attach:file.ext Δ you will find PING functionality and test program.
Here you will find PING functionality test program.
W5500-Library
W5500-Library
In this this post you will find the latest W5500 library update with PING functionality and test program.
Here Attach:file.ext Δ you will find PING functionality and test program.
Updated with PING functionality - March 27, 2015 (see at bottom
Updated with PING functionality - March 27, 2015 (see at bottom)
Updated with PING functionality
UPDATED 27 March 2015
Updated with PING functionality - March 27, 2015
Updated with PING functionality - March 27, 2015 (see at bottom
Updated with PING functionality
UPDATED 27 March 2015
In this this post you will find the latest W5500 library update with PING functionality and test program.
Updated with multi socket SOAP - January 30, 2015
Updated with TCP socket connection - February 28, 2015
Updated with TCP socket connection - February 28, 2015
Updated with TCP socket connection - February 28, 2015 (see at bottom)
Updated with TCP socket connection - February 28, 2015 Edit W5500-Socket.bas module and add Connect() function to connect via TCP client. On the module top add :
Include "EEPROM.bas" #option TCP_PORT_ROM_ADDR = 0 Private Const iniTcpPort As Word = 1000, endTcpPort As Word = 2000, eePortAddr = TCP_PORT_ROM_ADDR
On the module bottom add:
{ **************************************************************************** * Name : ComputeLocalPort * * Purpose : * **************************************************************************** } Private Function ComputeLocalPort() As Word ComputeLocalPort = EE.ReadWord(eePortAddr) If (ComputeLocalPort < iniTcpPort) Or (ComputeLocalPort > endTcpPort) Then ComputeLocalPort = iniTcpPort Else Inc(ComputeLocalPort) End If EE.WriteWord(eePortAddr, ComputeLocalPort) End Function { **************************************************************************** * Name : Connect * * Purpose : * **************************************************************************** } Public Function Connect(sock As Byte, pArrIPAddr As Word, _port As Word, flag As Byte) As Boolean result = false If Socket(sock, cSn_MR_TCP, ComputeLocalPort(), $00) Then WriteSocketPtr(sock, rSn_DIPR0, pArrIPAddr, 4) WriteSocketReg(sock, rSn_DPORT0, Byte(_port>>8)) WriteSocketReg(sock, rSn_DPORT0 + 1, Byte(_port And $00FF)) WriteSocketReg(sock, rSn_CR, cSn_CR_CONNECT) While(ReadSocketReg(sock,rSn_CR) = 1 ) // 30/11/2014 End While While ReadSocketReg(sock, rSn_SR)<> cSOCK_ESTABLISHED If (ReadSocketReg(sock, rSn_IR) And cSn_IR_TIMEOUT ) <> 0 Then result = false Exit End If End While result = true End If End Function
These routines allow you to perform a client connection and increase the local port at the last use, avoiding the connection timeout on the server side socket eventually left open earlier.
- Date : 1/11/2014 *
- Version : 1.0 *
- Notes : *
- Date : 30/01/2015 *
- Version : 2.0 *
- Notes : All 8 sockets can be used for a multi socket server *
- Date : 14/10/2014 *
- Version : 1.0 *
- Notes : *
- Date : 30/01/2015 *
- Version : 2.0 *
- Notes : All 8 sockets can used for multi socket SOAP server *
Updated with multi socket SOAP - January 30, 2015
// ############################################################################
// ############################################################################
// ##################################################################################
// ##################################################################################
Dim SDSeq As Byte
SockTimeoutEnable()
SockTimeoutEnable(sockreg)
SockTimeoutDisable()
SockTimeoutDisable(sockreg)
If SockTimeout() Then
If SockTimeout(sockreg) Then
SockTimeoutDisable()
SockTimeoutDisable(sockreg)
sockstat=ReadSocketReg(sockreg, rSn_SR) Select sockstat Case cSOCK_CLOSED If Socket(sockreg, cSn_MR_TCP, TCP_PORT, 0) Then If Not Listen(sockreg) Then DelayMS(1)
For sockreg= 0 To 7 sockstat=ReadSocketReg(sockreg, rSn_SR) Select sockstat Case cSOCK_CLOSED If Socket(sockreg, cSn_MR_TCP, TCP_PORT, 0) Then If Not Listen(sockreg) Then DelayMS(1) End If
End If Case cSOCK_ESTABLISHED rsize = W5500.DataAvailable(sockreg) If rsize > 0 Then SockTimeoutEnable()
{
Remember that the SOAP module works directly on the receive buffer and can be used on only one socket at a time because it keeps the socket number in a static variable which is set through the CheckEnvelope() function.
}
If CheckEnvelope(sockreg) Then If CheckMethod("Command", iMethod) Then
{
Client send a Command method request so check cCommand as integer parameter
}
If GetValue(iMethod,"cCommand",cCommand) Then USART.Write("cCommand=",DecToStr(cCommand),#13,#10) Else USART.Write("cCommand=","INVALID",#13,#10) End If
{
now check cParm as integer parameter
}
If GetValue(iMethod, "cParm",cParm) Then USART.Write("cParm=",DecToStr(cParm),#13,#10) Else USART.Write("cParm=","INVALID",#13,#10)
Case cSOCK_ESTABLISHED rsize = W5500.DataAvailable(sockreg) If rsize > 0 Then SockTimeoutEnable(sockreg) { Remember that the SOAP module works directly on the receive buffer and can be used on only one socket at a time because it keeps the socket number in a static variable which is set through the CheckEnvelope() function. } If CheckEnvelope(sockreg) Then If CheckMethod(sockreg, "Command", iMethod) Then { Client send a Command method request so check cCommand as integer parameter } If GetValue(sockreg, iMethod,"cCommand",cCommand) Then USART.Write("cCommand=",DecToStr(cCommand),#13,#10) Else USART.Write("cCommand=","INVALID",#13,#10) End If { now check cParm as integer parameter } If GetValue(sockreg, iMethod, "cParm",cParm) Then USART.Write("cParm=",DecToStr(cParm),#13,#10) Else USART.Write("cParm=","INVALID",#13,#10) End If W5500.ReleaseRXBuffer(sockreg) { Command method wants as answer a single Boolean value so create the response with single boolean result } W5500_SOAP.Initialize(sockreg, "Command") W5500_SOAP.WriteResult(sockreg, true) W5500_SOAP.Finalize(sockreg) Disconnect(sockreg) SockTimeoutDisable(sockreg)
W5500.ReleaseRXBuffer(sockreg)
{
Command method wants as answer a single Boolean value so create the response with single boolean result
}
W5500_SOAP.Initialize("Command") W5500_SOAP.WriteResult(true) W5500_SOAP.Finalize() Disconnect(sockreg) SockTimeoutDisable()
If CheckMethod(sockreg, "Status", iMethod) Then W5500.ReleaseRXBuffer(sockreg) { Client send a Status method request without parameters but want a complex object as response } W5500_SOAP.Initialize(sockreg, "Status") { Prepare four integer values } W5500_SOAP.WriteElement(sockreg, "PointsNum",0) W5500_SOAP.WriteElement(sockreg, "Chiamate",0) W5500_SOAP.WriteElement(sockreg, "InAttesa",0) W5500_SOAP.WriteElement(sockreg, "Visore",0) { Prepare two boolean values } W5500_SOAP.WriteElement(sockreg, "Buzzer", false) W5500_SOAP.WriteElement(sockreg, "Flash", false) { Now prepare a ListOf(integer) named ListaChiamate } W5500_SOAP.WriteElementOpen(sockreg, "ListaChiamate") W5500_SOAP.WriteItem(sockreg,0) W5500_SOAP.WriteItem(sockreg,1) W5500_SOAP.WriteItem(sockreg,2) W5500_SOAP.WriteItem(sockreg,3) W5500_SOAP.WriteElementClose(sockreg, "ListaChiamate") { Now prepare a ListOf(integer) named ListaAttese } W5500_SOAP.WriteElementOpen(sockreg, "ListaAttese") W5500_SOAP.WriteItem(sockreg, 5) W5500_SOAP.WriteElementClose(sockreg, "ListaAttese") W5500_SOAP.Finalize(sockreg) Disconnect(sockreg) SockTimeoutDisable(sockreg) End If
If CheckMethod("Status", iMethod) Then W5500.ReleaseRXBuffer(sockreg)
{
Client send a Status method request without parameters but want a complex object as response
}
W5500_SOAP.Initialize("Status")
{
Prepare four integer values
}
W5500_SOAP.WriteElement("PointsNum",0) W5500_SOAP.WriteElement("Chiamate",0) W5500_SOAP.WriteElement("InAttesa",0) W5500_SOAP.WriteElement("Visore",0)
{
Prepare two boolean values
}
W5500_SOAP.WriteElement("Buzzer", false) W5500_SOAP.WriteElement("Flash", false)
{
Now prepare a ListOf(integer) named ListaChiamate
}
W5500_SOAP.WriteElementOpen("ListaChiamate") W5500_SOAP.Write(0,1,2,3) W5500_SOAP.WriteElementClose("ListaChiamate")
{
Now prepare a ListOf(integer) named ListaAttese
}
W5500_SOAP.WriteElementOpen("ListaAttese") W5500_SOAP.WriteItem(5) W5500_SOAP.WriteElementClose("ListaAttese") W5500_SOAP.Finalize() Disconnect(sockreg) SockTimeoutDisable() End If End If End If Case cSOCK_FIN_WAIT, cSOCK_CLOSING, cSOCK_TIME_WAIT, cSOCK_CLOSE_WAIT, cSOCK_LAST_ACK Close(sockreg) End Select If SockTimeout() Then Close(sockreg) SockTimeoutDisable() End If
End If Case cSOCK_FIN_WAIT, cSOCK_CLOSING, cSOCK_TIME_WAIT, cSOCK_CLOSE_WAIT, cSOCK_LAST_ACK Close(sockreg) End Select If SockTimeout(sockreg) Then Close(sockreg) SockTimeoutDisable(sockreg) End If Next
This library allow the use of the WIZnet / W550io in Swordfish that mount W5500 ethernet chip. The W5500 has within it all the logic related to the TCP client / server and responds to the ping without special drivers, can enable wake on lan feature and it is for this reason that lends itself to be used quickly and without a great deal of memory. Compared to his older brother W5100 (for which you will find the SF library here) has far fewer pins, a simple buffer management (no more fraction) allowing direct access to the memory in a sequential manner and more available sockets.
This library allow the use of the WIZnet / WIZ550io in Swordfish that mount W5500 ethernet chip. The W5500 has within it all the logic related to the TCP client / server and responds to the ping without special drivers, can enable wake on lan feature and it is for this reason that lends itself to be used quickly and without a great deal of memory. Compared to his older brother W5100 (for which you will find the SF library here) has far fewer pins, a simple buffer management (no more fraction) allowing direct access to the memory in a sequential manner and more available sockets.
In particular, I have used through a module sold by the same WIZnet called W550io that mounts over chip and ethernet connector with all necessary circuitry. The module has two connectors strips with 1x6 pin and 1x8 pins.
In particular, I have used through a module sold by the same WIZnet called WIZ550io that mounts over chip and ethernet connector with all necessary circuitry. The module has two connectors strips with 1x6 pin and 1x8 pins.
- Author : M.Cerutti *
- Author : Coccoliso *
Surely the use of W5500 with PIC18 is an advantage because compared to the W5100 version with this chip you can avoid allocating the receive buffer. In the main program with options you can disable DNS and/or DHCP freely for more memory.
Surely the use of W5500 with PIC18 is an advantage because compared to the W5100 version with this chip you can avoid allocating the receive buffer. In the main program with options you can also disable DNS and/or DHCP freely for more memory.
Surely the use of W5500 with PIC18 is an advantage because compared to the W5100 this chip you can avoid allocating the receive buffer. In the main program with options you can disable DNS and/or DHCP freely.
Surely the use of W5500 with PIC18 is an advantage because compared to the W5100 version with this chip you can avoid allocating the receive buffer. In the main program with options you can disable DNS and/or DHCP freely for more memory.