= SendAndWaitFor(caOutGoing, cpInputRd, "OK\r\n", 3000);

AN93

return;

}

void Delay(long iMs)

{

clock_t wait;

//covert ms's to clock_t by mutiplying by CLOCKS_PER_SEC/1000 wait = (clock_t)(iMs*CLOCKS_PER_SEC)/1000;

clock_t goal;

goal = wait + clock(); while( goal > clock() )

;

}

void LoadAndSendPatch(void)

{

char caOutGoing[256];

cpInputRd_temp = SendAndWaitFor("AT&T7\r", cpInputRd, "OK\r\n", 300); // Reset the modem printf ("Current %s \n", cpInputRd); cpInputRd=cpInputRd_temp;

printf ("Loading patch:%s...\n", fnamePatch);

if ((hpPatchFile = fopen(fnamePatch, "rb")) == NULL)

{

fprintf(stderr, "The Patch File is missing.\n"); exit(1);

}

AssertRTS(true );

cpInputRd=SendAndWaitFor("ATE1\r", cpInputRd, "OK\r\n", 300); bool bValidLine = true;

while(bValidLine)

{

bValidLine = GetFileTextLine(caOutGoing); if(bValidLine)

cpInputRd

}

cpInputRd = SendAndWaitFor("ATE1\r", cpInputRd, "OK\r\n", 300); cpInputRd_temp = SendAndWaitFor("AT&T6\r", cpInputRd, "OK\r\n", 300); printf ("Finish Loading, %s \n", cpInputRd); cpInputRd=cpInputRd_temp; fclose(hpPatchFile);

}

//Returns FALSE when at end of file

//Stops after first LF.

bool GetFileTextLine(char *cpIn)

{

*cpIn = 0; char cpInChar[8]; cpInChar[1] = 0; while(!feof(hpPatchFile))

Rev. 1.3

269

Page 269
Image 269
Silicon Laboratories SI2494/39, SI2493/57/34/15/04 manual Rev 269