EasyManua.ls Logo

SystemBase Portbase-3010 - Page 106

SystemBase Portbase-3010
118 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Portbase User Guide
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();
}
}
//Transmits a data packet to the opened socket by creating the data packet.
//Calls it in the main function every 3 seconds.
void SendData(void)
{
int i;
char temp[30] = "This is LoopBack Data!”
// Outputs data to the ttys0.
write(porthandle, temp, sizeof(temp));
}
//Outputs received data on the screen.
void GetData(void)
{
int i;
106

Table of Contents