In part three of serial to Ethernet, we will go over the data receiving process from the Ethernet. Because we are not using any interrupt for Ethernet data, we are basically checking if there are any Ethernet data stored in the RX buffer. If there are data in the RX buffer, we will print out the data from the Ethernet. The first step is to check for the number of data inside the RX buffer by using the getSn_RX_RSR function. This function returns the number of bytes in the RX buffer. If this value is greater than 0, this means that you can use the recv function to get the data.
void lan_to_rs232()
{
uint16 xdata chk_length; // length checker
uint16 xdata rcv_length; // length of data received
uint16 xdata idx; // for loop index
chk_length = getSn_RX_RSR(0); // get length of data in lan receive buffer
if(chk_length > 0) // check if there is data in lan receive buffer
{
if(chk_length > MAX_BUF_SIZE) chk_length = MAX_BUF_SIZE;
//check if length of lan received buffer is more than LAN_RX_BUF
rcv_length = recv(0,LAN_RX_BUF,chk_length); //receive data
for(idx = 0; idx <>
No comments:
Post a Comment