
Operating Instructions | HERAcell® 150i / 240i
13
Annex: Data communication
13
Annex: Data communication
50115191 A / 08.2009
141
// calculate checksum: inverted XOR of all bytes
// without checksum and <CR>
for (i = 0; i < 11; i ++)
bcc = (bcc^string[i]);
// copy checksum
string[11] = hexa(bcc/16);
string[12] = hexa(bcc%16);
// send telegram
ComWrt (COM_NR, string, 14);
return;
}
Receiving a response telegram
get_telegramm
int get_telegramm(char *p)
{
int reading_count = 0;
// reading the telegram character by character
do
ComRd(COM_NR, &p[reading_count], 1);
// until reception of <CR>
while ((p[readin+] != '\r'));
// return = number of received characters
return (reading_count);
}
Creating a time format in ASCII
time_2_str
char time_2_str (int z, char * b)
{
char i;
// output two numerals
for (i = 1; i >= 0; i--){
// calculate value
b[i] = z%10+0x30;
// reduce default value
z = z/10;
}
return (2);
}
Hexadecimal values in ASCII
characters
num_2_string
char num_2_str (int z, char * b)
{
// number with one decimal place
char a[12];
char i, l;
int rest = 0;
l = 0;
// Negative number?
if (z < 0) {
// set algebraic sign
b[0] = '-';
l = 1;
// convert value
z = 0xffffffff-z+1;
}
// store decimal place
rest = z % 10;
Содержание Heracell 150i
Страница 156: ......