beautypg.com

Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual

Page 95

background image

94

CHAPTER 8 • SERIAL MESSAGE SUPPORT

“%2d[hour1]:%2d[minute1]:%2d[sec1]”\
“.%3d[ms1]|%1CSUM[0]\r>”);

ClickMsgAddChecksumTask(DateChecksum,0);

ClickMsgAddReceiveTaskToVPort(TimeRequestMsg,
SetTime,V1);
}

void BuildTimeResponseMsg(void)
{
ClickUtilTime now;
unsigned long u32tmp;

ClickUtilGetTime(&now);
u32tmp = (unsigned long)now.Year;
ClickMsgWriteVar(“year2”,&u32tmp);
u32tmp = (unsigned long)now.Month;
ClickMsgWriteVar(“month2”,&u32tmp);
u32tmp = (unsigned long)now.DayOfMonth;
ClickMsgWriteVar(“day2”,&u32tmp);
u32tmp = (unsigned long)now.Hour;
ClickMsgWriteVar(“hour2”,&u32tmp);
u32tmp = (unsigned long)now.Minute;
ClickMsgWriteVar(“minute2”,&u32tmp);
u32tmp = (unsigned long)now.Second;
ClickMsgWriteVar(“sec2”,&u32tmp);
u32tmp = (unsigned long)now.MSec;
ClickMsgWriteVar(“ms2”,&u32tmp);
}

void SetTime(int port)
{
ClickUtilTime newTime;
unsigned long u32tmp;

ClickMsgReadVar(“year1”,&u32tmp);
newTime.Year = (int)u32tmp;
ClickMsgReadVar(“month1”,&u32tmp);
newTime.Month = (unsigned char)u32tmp;
ClickMsgReadVar(“day1”,&u32tmp);