Operating Instructions | HERAcell® 150i / 240i
13
Annex: Data communication
13
Annex: Data communication
50115191 A / 08.2009
140
13.7 Examples of data logger codes
Data logger entry
An entry in the data logger is 16 bytes large and has the following structure:
1. byte: indicates the event (e.g. door open 0x31, measured value entry
0x01)
2. byte: day of entry
3. byte: month
4. byte: year
5. byte: hour
6. byte: minute
7. and 8. byte: device status
9. to 16. byte: various data on the event
13.7.1 Functions for data logger queries
Functions
The following code example for reading the data logger uses six functions:
•
ahex
// converts the received ASCII character into a hexadecimal number,
•
send_telegramm
// sends a query to the data logger,
•
get_telegramm
// receives a response data the data logger,
•
time_2_str
// uses a hexadecimal value to create ASCII characters in time format,
•
num_2_string
// uses hexadecimal values to create ASCII characters to be entered into
a file,
•
read_datalogger
// edits the received data and writes them into a file.
13.7.2 Example of a code for a a data logger query
Creating a hexadecimal number
char ahex (char a)
char ahex(char a)
{
char i;
char hexa[16]="0123456789abcdef";
for (i = 0; i < 16; i++)
if (a == hexa[i])
return (i);
return 0;
}
Sending a telegram
send_telegramm
void send_telegramm(char *p)
{
char string [15];
unsigned char bcc = 0xFF;
char i;
// copy telegram together
strncpy (&string[0], "?:xxxx:00::00\r", 14);
// insert 4-digit address
strncpy (&string[2], p, 4);
Содержание Heracell 150i
Страница 156: ......