Herunterladen Inhalt Inhalt Diese Seite drucken

Pepperl+Fuchs VAM-CTR-PC2 Handbuch Seite 41

Inhaltsverzeichnis

Werbung

printf("config OK... ");
/* print "active wheel" to screen */
switch(which_bar_to_print)
{
}
}
} while(1);
} /* main */
/* ================================================================ */
/* FUNCTION:
/* DESCRIPTION: send a command to AS-i PC board
/*
/* USAGE:
/*
/* PARAMETERS:
/*
command: value for 'command'
/*
/* RETURNS:
/*
0x0000: o.k. (ACK)
/*
0x0001: o.k. (NAK)
/*
0x0003: invalid response
/*
0x0004: timeout
/* ================================================================ */
static int send_cmd(unsigned char command)
{
time_t timer;
register unsigned char c;
Page(D_COMMAND);
Index(D_COMMAND);
Write(command);
c = command;
time(&timer);
do
{
Index(D_COMMAND);
Read(c);
if (c != command)
break;
}while(difftime(time(NULL),timer) < 0.2);
/* ...or end loop after 200 ms (timeout)! */
/* return codes depending on the command byte */
if
(c == command)
else if (c == 0x00)
Zumutbare Änderungen aufgrund technischer Verbesserungen vorbehalten.
Pepperl+Fuchs GmbH · 68301 Mannheim · Telefon (06 21) 7 76-11 11 · Telefax (06 21) 7 76-10 00 · Internet http://www.pepperl-fuchs.com
case 1: printf("-\r");
which_bar_to_print = 2;
break;
case 2: printf("/\r");
which_bar_to_print = 3;
break;
case 3: printf("\\\r");
which_bar_to_print = 1;
break;
send_cmd
error = send_cmd(command);
/* write the command code */
/* to DPRAM */
/* store actual time */
/* read command byte */
/* from DPRAM! */
/* break loop, if command byte */
/* is changing... */
return (0x0004);
return (0x0000);
AS-i PC2 Karte
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
/*
timeout */
/*
ACK
*/
Copyright Pepperl+Fuchs, Printed in Germany
Anhang
41

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis