2
COPYRIGHT (C) 2006 Roberto Bucher (roberto.bucher@supsi.ch)
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20
#include <scicos_block4.h>
23
#include <rtai_netrpc.h>
29
#define MAX_RTAI_LEDS 1000
30
#define MBX_RTAI_LED_SIZE 5000
32
extern char *TargetLedMbxID;
34
void par_getstr(char * str, int par[], int init, int len);
36
static void init(scicos_block *block)
40
int nch = GetNin(block);
41
int * ipar = GetIparPtrs(block);
44
par_getstr(ledName,ipar,1,ipar[0]);
45
rtRegisterLed(ledName,nch);
46
get_a_name(TargetLedMbxID,name);
48
mbx = (MBX *) RT_typed_named_mbx_init(0,0,name,MBX_RTAI_LED_SIZE/sizeof(unsigned int)*sizeof(unsigned int),FIFO_Q);
50
fprintf(stderr, "Cannot init mailbox\n");
58
static void inout(scicos_block *block)
60
MBX * mbx = *(block->work);
62
unsigned int led_mask = 0;
63
int nleds = GetNin(block);
66
for (i = 0; i < nleds; i++) {
74
RT_mbx_send_if(0, 0, mbx, &led_mask, sizeof(led_mask));
78
static void end(scicos_block *block)
80
int * ipar = GetIparPtrs(block);
83
MBX * mbx = *(block->work);
84
RT_named_mbx_delete(0, 0, mbx);
85
par_getstr(ledName,ipar,1,ipar[0]);
86
printf("Led %s closed\n",ledName);
90
void rtled(scicos_block *block,int flag)
92
if (flag==1){ /* set output */
95
else if (flag==5){ /* termination */
98
else if (flag ==4){ /* initialisation */