Example code 8.1 – Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual
Page 93
92
CHAPTER 8 • SERIAL MESSAGE SUPPORT
74
Get Non-Volatile Lanes &
Approaches Variable Size by
Timestamp
R
Please consult the Z1 protocol documentation for more information on the specifics of each
command. When you call the corresponding read data function, the Z1 support library will
automatically parse the received message and store its payload data in a convenient data
structure. For example, ClickZ1_0EReadData will store the time into a local ClickUtilTime
structure.
The HDZ1Example.C code in the Examples > Chapter 8 directory demonstrates how to
receive event data and interval data in either a pushed or polled paradigm.
Example Code 8.1
Example Code 8.1 can be found in the Examples > Chapter 8 directory. This example dem-
onstrates the convenience of the Click 500 message library functions in supporting protocol
messages. The Click message strings TimeResponseMsg and TimeRequest Message are cre-
ated to provide a simple way to get and set the time of the Click 500’s real time clock. The
validity of the date and time information in the messages is verified using a custom check-
sum. Press the push-button to send a message that displays the current time. To set the time,
send a message such as “SETTIME 07/21/2009 16:01:02.999|:” followed by a carriage return
using a serial terminal program.
///////////////////////////////////////////////////////////////
// ExampleCode8.1.C
///////////////////////////////////////////////////////////////
#use click500menu.lib
#use click500serial.lib
#use click500message.lib
void Mode1(void);
void Setup1(void);
void BuildTimeResponseMsg(void);
void SetTime(int port);
int DateChecksum(char *dataPtr, unsigned int dataSize,
char *expectedCRC, int myCSumIdx);
ClickMsgString TimeResponseMsg;