beautypg.com

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

Page 96

background image

CHAPTER 8 • SERIAL MESSAGE SUPPORT 95

newTime.DayOfMonth = (unsigned char)u32tmp;
ClickMsgReadVar(“hour1”,&u32tmp);
newTime.Hour = (unsigned char)u32tmp;
ClickMsgReadVar(“minute1”,&u32tmp);
newTime.Minute = (unsigned char)u32tmp;
ClickMsgReadVar(“sec1”,&u32tmp);
newTime.Second = (unsigned char)u32tmp;
ClickMsgReadVar(“ms1”,&u32tmp);
newTime.MSec = (int)u32tmp;

ClickUtilSetTime(&newTime);

BuildTimeResponseMsg();
ClickMsgTransmit(TimeResponseMsg,V1);
}

int DateChecksum(char *dataPtr, unsigned int dataSize,
char *expectedCRC, int myCSumIdx)
{
int i;
long sum;

sum = 0;
for (i=0; i {
if ((dataPtr[i] >= ‘0’) && (dataPtr[i] <= ‘9’))
{
sum += (dataPtr[i]-0x30);
}
}

if (expectedCRC != NULL)
{
if (sum == *expectedCRC)
{
return 0;
}
else
{
return 1;
}
}