beautypg.com

H-4271, Installation and maintenance 2-9 – Xylem H-4271 User Manual

Page 19

background image

if(port == 2)
if(COM2_LastChar == 0x0A) // CR LF terminates the response
Timeout = 0;

if(port == 3)
if(COM3_LastChar == 0x0A) // CR LF terminates the response
Timeout = 0;

if(Timeout)
Timeout--;
}
while(Timeout);

for(i = 0 ; i < 50 ; i++) // move response to SDI In Buffer
{
getcharX(port, 0, &Data);

Data = Data & 0x7F; // strip off parity bit
SDI_In_buffer[i] = Data; // save in SDI buffer
if(Data == 0)
break;
}

// make sure in buffer is empty before leaving
// do it quick so we do not get the service request

while(getcharX(port, 0, &c));

// look for proper SDI-12 address and return it or return a NULL

if(SDI_In_buffer[0] >= ' ')
Data = SDI_In_buffer[0];
else
Data = 0;

if((retry == 4) && (!Data) || // Only send the radio beacon
(retry == 2) && (!Data)) // on selected retries
{
msdelay(2000);

if(radio)

// if a radio connection is selected

{
putcharX(port,'+'); // +++
putcharX(port,'+');
putcharX(port,'+');
msdelay(2000); // wait for 'OK'

putcharX(port,'A'); // This command forces the
putcharX(port,'T'); // radio to resend the beacon
putcharX(port,'F'); // to the remote radio.
putcharX(port,'H'); // now making this part of
putcharX(port,','); // the retry process
putcharX(port,'C');
putcharX(port,'N');
putcharX(port,0x0A);
putcharX(port,0x0D);

msdelay(2000); // wait for 'OK'
}

while(getcharX(port, 0, &c)); // start with a clear buffer
}
}
while((--retry) && (!Data));

return(Data);
}

H-4271

Installation And Maintenance 2-9