WIZ810 Component bug
Posted: Thu Mar 06, 2025 11:49 am
Good day,One of my programmers has pointed the following out to me.Hi Leo,
See below for the bug in the TCPClose function. The problem is the two highlighted instances where 0x401 is used instead of the local variable FCL_CR = 0x401 + (0x100 * FCL_CHANNEL). The result is that socket 0 is always closed, instead of the intended socket.
Regards,
Michael
/*=----------------------------------------------------------------------=*\
Use :When an established TCP connection has finished transmission of data, either the local application (i.e. your code) or the remote application (i.e. the application at the other end of the connection) can initiate closure of the socket.
:
:Parameters for macro TCPClose:
: Channel : Specifies the communications channel 0-3
\*=----------------------------------------------------------------------=*/
void FCD_01351_TCP_IP_WIZ810MJ1__TCPClose(MX_UINT8 FCL_CHANNEL)
{
//Local variable definitions
MX_UINT8 FCL_IS_EQUAL = (0x0);
MX_UINT8 FCL_TIMEOUT = (0x64);
MX_UINT16 FCL_IR;
MX_UINT16 FCL_CR;
MX_UINT8 FCL_TEMP;
FCL_CR = 0x401 + (0x100 * FCL_CHANNEL);
FCL_IR = FCL_CR + 1;
while (FCL_IS_EQUAL == 0)
{
FCL_TEMP = FCD_01351_TCP_IP_WIZ810MJ1__MAC_ReadByte(FCL_IR);
if (FCL_TEMP & 0x10)
{
FCL_IS_EQUAL = 1;
} else {
FCI_DELAYBYTE_MS(1);
FCL_TIMEOUT = FCL_TIMEOUT - 1;
if (FCL_TIMEOUT == 0)
{
FCL_IS_EQUAL = 1;
// } else {
}
}
}
if (FCL_TIMEOUT != 0)
{
FCD_01351_TCP_IP_WIZ810MJ1__MAC_WriteByte(0x401, 0x08);
FCL_IS_EQUAL = 1;
while (FCL_IS_EQUAL)
{
FCL_IS_EQUAL = FCD_01351_TCP_IP_WIZ810MJ1__MAC_ReadByte(FCL_CR);
}
FCD_01351_TCP_IP_WIZ810MJ1__MAC_WriteByte(0x401, 0x10);
FCL_IS_EQUAL = 1;
while (FCL_IS_EQUAL)
{
FCL_IS_EQUAL = FCD_01351_TCP_IP_WIZ810MJ1__MAC_ReadByte(FCL_CR);
}
// } else {
}
}Apologies, but I cannot get the CR to work.
See below for the bug in the TCPClose function. The problem is the two highlighted instances where 0x401 is used instead of the local variable FCL_CR = 0x401 + (0x100 * FCL_CHANNEL). The result is that socket 0 is always closed, instead of the intended socket.
Regards,
Michael
/*=----------------------------------------------------------------------=*\
Use :When an established TCP connection has finished transmission of data, either the local application (i.e. your code) or the remote application (i.e. the application at the other end of the connection) can initiate closure of the socket.
:
:Parameters for macro TCPClose:
: Channel : Specifies the communications channel 0-3
\*=----------------------------------------------------------------------=*/
void FCD_01351_TCP_IP_WIZ810MJ1__TCPClose(MX_UINT8 FCL_CHANNEL)
{
//Local variable definitions
MX_UINT8 FCL_IS_EQUAL = (0x0);
MX_UINT8 FCL_TIMEOUT = (0x64);
MX_UINT16 FCL_IR;
MX_UINT16 FCL_CR;
MX_UINT8 FCL_TEMP;
FCL_CR = 0x401 + (0x100 * FCL_CHANNEL);
FCL_IR = FCL_CR + 1;
while (FCL_IS_EQUAL == 0)
{
FCL_TEMP = FCD_01351_TCP_IP_WIZ810MJ1__MAC_ReadByte(FCL_IR);
if (FCL_TEMP & 0x10)
{
FCL_IS_EQUAL = 1;
} else {
FCI_DELAYBYTE_MS(1);
FCL_TIMEOUT = FCL_TIMEOUT - 1;
if (FCL_TIMEOUT == 0)
{
FCL_IS_EQUAL = 1;
// } else {
}
}
}
if (FCL_TIMEOUT != 0)
{
FCD_01351_TCP_IP_WIZ810MJ1__MAC_WriteByte(0x401, 0x08);
FCL_IS_EQUAL = 1;
while (FCL_IS_EQUAL)
{
FCL_IS_EQUAL = FCD_01351_TCP_IP_WIZ810MJ1__MAC_ReadByte(FCL_CR);
}
FCD_01351_TCP_IP_WIZ810MJ1__MAC_WriteByte(0x401, 0x10);
FCL_IS_EQUAL = 1;
while (FCL_IS_EQUAL)
{
FCL_IS_EQUAL = FCD_01351_TCP_IP_WIZ810MJ1__MAC_ReadByte(FCL_CR);
}
// } else {
}
}Apologies, but I cannot get the CR to work.