Solvline PB2xxxUG User Manual
Page 95
4) Source Code
//Inserts the necessary header files.
#include
#include
#include
#include
#include
int porthandle; // Handle for the socket of RTCP
int readval; // Variable for saving the returned value of read
void OpenSerial(void);
void SendData(void);
void GetData(void);
//Creates the main function and calls the function.
main (int argc, char *argv[])
{
time_t tti;
struct tm *ttm;
int
gettime;
int
gettime2;
OpenSerial();
time(&tti);
ttm = localtime(&tti);
gettime = ttm->tm_sec;
gettime2 = ttm->tm_sec;
while(1){
time(&tti);
ttm = localtime(&tti);
gettime = ttm->tm_sec;// Obtains the present time.
if (gettime2 > gettime) gettime = gettime + 60;
if ( gettime - gettime2 > 2) {// Calls the SendData() function every 3
second.
SendData();
gettime2
=
ttm->tm_sec;
}
GetData();
}
}
95