You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(105) |
Aug
(245) |
Sep
(165) |
Oct
(100) |
Nov
(92) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(179) |
Feb
(233) |
Mar
(175) |
Apr
(168) |
May
(146) |
Jun
(165) |
Jul
(18) |
Aug
(95) |
Sep
(134) |
Oct
(120) |
Nov
(51) |
Dec
(65) |
| 2005 |
Jan
(96) |
Feb
(100) |
Mar
(113) |
Apr
(82) |
May
(281) |
Jun
(168) |
Jul
(54) |
Aug
(72) |
Sep
(104) |
Oct
(182) |
Nov
(126) |
Dec
(133) |
| 2006 |
Jan
(211) |
Feb
(252) |
Mar
(291) |
Apr
(199) |
May
(345) |
Jun
(282) |
Jul
(272) |
Aug
(261) |
Sep
(287) |
Oct
(464) |
Nov
(233) |
Dec
(210) |
| 2007 |
Jan
(669) |
Feb
(304) |
Mar
(483) |
Apr
(150) |
May
(293) |
Jun
(215) |
Jul
(178) |
Aug
(138) |
Sep
(159) |
Oct
(301) |
Nov
(367) |
Dec
(165) |
| 2008 |
Jan
(171) |
Feb
(148) |
Mar
(150) |
Apr
(180) |
May
(112) |
Jun
(109) |
Jul
(196) |
Aug
(319) |
Sep
(294) |
Oct
(284) |
Nov
(399) |
Dec
(280) |
| 2009 |
Jan
(536) |
Feb
(454) |
Mar
(382) |
Apr
(255) |
May
(321) |
Jun
(318) |
Jul
(412) |
Aug
(226) |
Sep
(76) |
Oct
(251) |
Nov
(134) |
Dec
(101) |
| 2010 |
Jan
(262) |
Feb
(210) |
Mar
(219) |
Apr
(55) |
May
(180) |
Jun
(225) |
Jul
(151) |
Aug
(184) |
Sep
(54) |
Oct
(160) |
Nov
(237) |
Dec
(115) |
| 2011 |
Jan
(141) |
Feb
(68) |
Mar
(204) |
Apr
(329) |
May
(68) |
Jun
(34) |
Jul
(304) |
Aug
(206) |
Sep
(183) |
Oct
(121) |
Nov
(1125) |
Dec
(934) |
| 2012 |
Jan
(466) |
Feb
(161) |
Mar
(314) |
Apr
(63) |
May
(62) |
Jun
(53) |
Jul
(47) |
Aug
(41) |
Sep
(36) |
Oct
(108) |
Nov
(297) |
Dec
(73) |
| 2013 |
Jan
(236) |
Feb
(81) |
Mar
(422) |
Apr
(441) |
May
(86) |
Jun
(177) |
Jul
(146) |
Aug
(140) |
Sep
(93) |
Oct
(126) |
Nov
(133) |
Dec
(230) |
| 2014 |
Jan
(380) |
Feb
(233) |
Mar
(251) |
Apr
(214) |
May
(168) |
Jun
(670) |
Jul
(538) |
Aug
(459) |
Sep
(330) |
Oct
(327) |
Nov
(339) |
Dec
(456) |
| 2015 |
Jan
(188) |
Feb
(426) |
Mar
(186) |
Apr
(71) |
May
(151) |
Jun
(283) |
Jul
(208) |
Aug
(477) |
Sep
(148) |
Oct
(302) |
Nov
(297) |
Dec
(331) |
| 2016 |
Jan
(474) |
Feb
(55) |
Mar
(92) |
Apr
(118) |
May
(286) |
Jun
(751) |
Jul
(494) |
Aug
(166) |
Sep
(97) |
Oct
(216) |
Nov
(41) |
Dec
(78) |
| 2017 |
Jan
(148) |
Feb
(205) |
Mar
(112) |
Apr
(119) |
May
(125) |
Jun
(102) |
Jul
(242) |
Aug
(26) |
Sep
(53) |
Oct
(28) |
Nov
(38) |
Dec
(97) |
| 2018 |
Jan
(71) |
Feb
(49) |
Mar
(43) |
Apr
(13) |
May
(19) |
Jun
(44) |
Jul
(74) |
Aug
(30) |
Sep
(44) |
Oct
(57) |
Nov
(74) |
Dec
(34) |
| 2019 |
Jan
(41) |
Feb
(50) |
Mar
(30) |
Apr
(24) |
May
(44) |
Jun
(101) |
Jul
(94) |
Aug
(123) |
Sep
(101) |
Oct
(81) |
Nov
(48) |
Dec
(51) |
| 2020 |
Jan
(74) |
Feb
(81) |
Mar
(129) |
Apr
(310) |
May
(176) |
Jun
(97) |
Jul
(137) |
Aug
(205) |
Sep
(84) |
Oct
(71) |
Nov
(106) |
Dec
(138) |
| 2021 |
Jan
(117) |
Feb
(94) |
Mar
(89) |
Apr
(71) |
May
(98) |
Jun
(99) |
Jul
(67) |
Aug
(129) |
Sep
(108) |
Oct
(127) |
Nov
(115) |
Dec
(114) |
| 2022 |
Jan
(115) |
Feb
(85) |
Mar
(97) |
Apr
(92) |
May
(102) |
Jun
(109) |
Jul
(168) |
Aug
(230) |
Sep
(183) |
Oct
(106) |
Nov
(109) |
Dec
(146) |
| 2023 |
Jan
(186) |
Feb
(126) |
Mar
(99) |
Apr
(92) |
May
(158) |
Jun
(74) |
Jul
(113) |
Aug
(93) |
Sep
(84) |
Oct
(163) |
Nov
(72) |
Dec
(81) |
| 2024 |
Jan
(71) |
Feb
(85) |
Mar
(63) |
Apr
(50) |
May
(45) |
Jun
(28) |
Jul
(106) |
Aug
(45) |
Sep
(60) |
Oct
(44) |
Nov
(53) |
Dec
(28) |
| 2025 |
Jan
(87) |
Feb
(58) |
Mar
(71) |
Apr
(37) |
May
(37) |
Jun
(46) |
Jul
(74) |
Aug
(26) |
Sep
(55) |
Oct
(43) |
Nov
(5) |
Dec
|
|
From: <pa...@us...> - 2003-07-27 16:37:45
|
Update of /cvsroot/emc/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv26551 Removed Files: NOTES Log Message: Deleted redundant junk file --- NOTES DELETED --- |
|
From: <pa...@us...> - 2003-07-27 16:33:45
|
Update of /cvsroot/emc/rtapi/src/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv26019/src/rtapi Removed Files: localdefs.h Log Message: Deleted auto-generated files --- localdefs.h DELETED --- |
|
From: <pa...@us...> - 2003-07-27 16:33:45
|
Update of /cvsroot/emc/rtapi/examples/fifo
In directory sc8-pr-cvs1:/tmp/cvs-serv26019/examples/fifo
Modified Files:
fifotask.c fifousr.c
Log Message:
Deleted auto-generated files
Index: fifotask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/fifo/fifotask.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** fifotask.c 25 Jul 2003 04:11:55 -0000 1.3
--- fifotask.c 27 Jul 2003 16:33:42 -0000 1.4
***************
*** 17,21 ****
/* task code, executed each timer interrupt */
! void fifo_code( int arg )
{
int n;
--- 17,21 ----
/* task code, executed each timer interrupt */
! void fifo_code(int arg)
{
int n;
***************
*** 23,34 ****
while (1) {
! for ( n = 0 ; n < count ; n++ ) {
buffer[n] = '0' + count;
}
! rtapi_fifo_write ( fifo, buffer, count );
buffer[n] = '\0';
! rtapi_print ( "fifotask: wrote '%s'\n", buffer );
count++;
! if ( count > 9 )
count = 1;
rtapi_wait();
--- 23,34 ----
while (1) {
! for (n = 0; n < count; n++) {
buffer[n] = '0' + count;
}
! rtapi_fifo_write(fifo, buffer, count);
buffer[n] = '\0';
! rtapi_print("fifotask: wrote '%s'\n", buffer);
count++;
! if (count > 9)
count = 1;
rtapi_wait();
***************
*** 45,67 ****
/*
! if (0 != rtapi_init()) {
! return -1;
! }
! */
/* allocate and initialize the fifo */
! /* debug, remove when working */ rtapi_print ( "debug - Calling rtapi_fifo_new()\n" );
! retval = rtapi_fifo_new( FIFO_KEY, FIFO_SIZE, &fifo );
! /* debug, remove when working */ rtapi_print( "debug - fifotask init: rtapi_fifo_new returned %d\n", retval );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "fifotask init: rtapi_fifo_new returned %d\n", retval );
return -1;
}
! rtapi_print("fifotask init: created fifo\n" );
/* set the base timer period */
retval = rtapi_clock_set_period(FIFO_PERIOD_NSEC);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "fifotask init: rtapi_clock_set_period returned %d\n", retval );
return -1;
}
--- 45,71 ----
/*
! if (0 != rtapi_init()) {
! return -1;
! }
! */
/* allocate and initialize the fifo */
! /* debug, remove when working */
! rtapi_print("debug - Calling rtapi_fifo_new()\n");
! retval = rtapi_fifo_new(FIFO_KEY, FIFO_SIZE, &fifo);
! /* debug, remove when working */
! rtapi_print("debug - fifotask init: rtapi_fifo_new returned %d\n",
! retval);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask init: rtapi_fifo_new returned %d\n", retval);
return -1;
}
! rtapi_print("fifotask init: created fifo\n");
/* set the base timer period */
retval = rtapi_clock_set_period(FIFO_PERIOD_NSEC);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask init: rtapi_clock_set_period returned %d\n",
! retval);
return -1;
}
***************
*** 71,87 ****
/* launch the fifo task */
! retval = rtapi_task_new( &fifo_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "fifotask init: rtapi_task_new returned %d\n", retval );
return -1;
}
/* start the fifo task */
! retval = rtapi_task_start( fifo_task, fifo_code,
! 0, fifo_prio,
! FIFO_STACKSIZE,
! FIFO_PERIOD_NSEC, RTAPI_NO_FP );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask init: rtapi_task_start returned %d\n", retval );
return -1;
}
--- 75,90 ----
/* launch the fifo task */
! retval = rtapi_task_new(&fifo_task);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask init: rtapi_task_new returned %d\n", retval);
return -1;
}
/* start the fifo task */
! retval = rtapi_task_start(fifo_task, fifo_code,
! 0, fifo_prio,
! FIFO_STACKSIZE, FIFO_PERIOD_NSEC, RTAPI_NO_FP);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask init: rtapi_task_start returned %d\n", retval);
return -1;
}
***************
*** 97,118 ****
int retval;
! retval = rtapi_task_stop( fifo_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask exit: rtapi_task_stop returned %d\n", retval );
return;
}
! retval = rtapi_task_delete( fifo_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask exit: rtapi_task_delete returned %d\n", retval );
return;
}
! retval = rtapi_fifo_delete( fifo );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask exit: rtapi_fifo_delete returned %d\n", retval );
return;
}
! rtapi_print("fifotask exit: done\n" );
rtapi_app_return();
--- 100,121 ----
int retval;
! retval = rtapi_task_stop(fifo_task);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask exit: rtapi_task_stop returned %d\n", retval);
return;
}
! retval = rtapi_task_delete(fifo_task);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask exit: rtapi_task_delete returned %d\n", retval);
return;
}
! retval = rtapi_fifo_delete(fifo);
! if (retval != RTAPI_SUCCESS) {
! rtapi_print("fifotask exit: rtapi_fifo_delete returned %d\n", retval);
return;
}
! rtapi_print("fifotask exit: done\n");
rtapi_app_return();
Index: fifousr.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/fifo/fifousr.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** fifousr.c 25 Jul 2003 04:11:55 -0000 1.3
--- fifousr.c 27 Jul 2003 16:33:42 -0000 1.4
***************
*** 25,37 ****
retval = ulapi_init();
! if ( retval != ULAPI_SUCCESS ) {
! printf("fifousr main: ulapi_init returned %d\n", retval );
return -1;
}
/* open the fifo */
! retval = ulapi_fifo_new( FIFO_KEY, FIFO_SIZE, 'R', &fifo );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "fifousr main: ulapi_fifo_new returned %d\n", retval );
return -1;
}
--- 25,37 ----
retval = ulapi_init();
! if (retval != ULAPI_SUCCESS) {
! printf("fifousr main: ulapi_init returned %d\n", retval);
return -1;
}
/* open the fifo */
! retval = ulapi_fifo_new(FIFO_KEY, FIFO_SIZE, 'R', &fifo);
! if (retval != ULAPI_SUCCESS) {
! printf("fifousr main: ulapi_fifo_new returned %d\n", retval);
return -1;
}
***************
*** 41,54 ****
signal(SIGINT, quit);
! printf ( "waiting for fifo data, ctrl-C to quit\n" );
while (1) {
! nchars = ulapi_fifo_read( fifo, buffer, FIFO_SIZE );
! if ( retval < 0 ) {
! printf ( "fifousr main: ulapi_fifo_read returned %d\n", nchars );
! }
! else {
! buffer[nchars] = '\0';
! printf("fifousr main: read %d chars: '%s'\n", nchars, buffer);
}
}
--- 41,53 ----
signal(SIGINT, quit);
! printf("waiting for fifo data, ctrl-C to quit\n");
while (1) {
! nchars = ulapi_fifo_read(fifo, buffer, FIFO_SIZE);
! if (retval < 0) {
! printf("fifousr main: ulapi_fifo_read returned %d\n", nchars);
! } else {
! buffer[nchars] = '\0';
! printf("fifousr main: read %d chars: '%s'\n", nchars, buffer);
}
}
***************
*** 56,64 ****
END:
! printf( "shutting down\n" );
! retval = ulapi_fifo_delete( fifo );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "fifousr main: ulapi_fifo_delete returned %d\n", retval );
return -1;
}
--- 55,63 ----
END:
! printf("shutting down\n");
! retval = ulapi_fifo_delete(fifo);
! if (retval != ULAPI_SUCCESS) {
! printf("fifousr main: ulapi_fifo_delete returned %d\n", retval);
return -1;
}
|
|
From: <pa...@us...> - 2003-07-27 16:33:45
|
Update of /cvsroot/emc/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv26019 Removed Files: Makefile.inc Log Message: Deleted auto-generated files --- Makefile.inc DELETED --- |
|
From: <jmk...@us...> - 2003-07-27 15:56:46
|
Update of /cvsroot/emc/rtapi/src/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv19600/src/rtapi Modified Files: localdefs.h Log Message: modified install_realtime_base and remove_realtime_base to install/remove RTAPI Index: localdefs.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/localdefs.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** localdefs.h 25 Jul 2003 01:40:38 -0000 1.6 --- localdefs.h 27 Jul 2003 15:56:43 -0000 1.7 *************** *** 2,6 **** #define LOCALDEFS_H ! /* automatically generated by config script on Thu Jul 24 21:36:47 EDT 2003 */ #define LOCAL_MHZ 233.866 --- 2,6 ---- #define LOCALDEFS_H ! /* automatically generated by config script on Fri Jul 25 22:14:05 EDT 2003 */ #define LOCAL_MHZ 233.866 |
|
From: <jmk...@us...> - 2003-07-27 15:56:46
|
Update of /cvsroot/emc/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv19600
Modified Files:
install_realtime_base remove_realtime_base
Log Message:
modified install_realtime_base and remove_realtime_base to install/remove RTAPI
Index: install_realtime_base
===================================================================
RCS file: /cvsroot/emc/rtapi/install_realtime_base,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** install_realtime_base 22 Jul 2003 17:20:21 -0000 1.2
--- install_realtime_base 27 Jul 2003 15:56:43 -0000 1.3
***************
*** 102,105 ****
--- 102,109 ----
fi
fi
+ # start up the RTAPI if present
+ if [ -f rtlib/rtai_rtapi.o ] ; then
+ /sbin/insmod rtlib/rtai_rtapi.o
+ fi
exit 0
fi
***************
*** 176,179 ****
--- 180,188 ----
/sbin/insmod -f /lib/modules/$rev/misc/rtl_fifo.o
fi
+ fi
+
+ # start up the RTAPI if present
+ if [ -f rtlib/rtl_rtapi.o ] ; then
+ /sbin/insmod rtlib/rtl_rtapi.o
fi
Index: remove_realtime_base
===================================================================
RCS file: /cvsroot/emc/rtapi/remove_realtime_base,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** remove_realtime_base 8 Jul 2003 15:54:38 -0000 1.1.1.1
--- remove_realtime_base 27 Jul 2003 15:56:43 -0000 1.2
***************
*** 9,16 ****
fi
! if [ -e /dev/mbuff ] ; then
/sbin/fuser -v /dev/mbuff 2>/dev/null && echo "Can't remove realtime modules, kill the above processes first". && exit 0
fi
# Get a list of currently installed modules.
modules=`/sbin/lsmod | gawk '{print $1}'`
--- 9,40 ----
fi
! if [ -e /dev/mbuff ] ; then
/sbin/fuser -v /dev/mbuff 2>/dev/null && echo "Can't remove realtime modules, kill the above processes first". && exit 0
fi
+ # check for the presence of RTAPI
+ RTAPI_STR=$(/sbin/lsmod | grep -E '(^rtl_rtapi|^rtai_rtapi)')
+ if [ "$RTAPI_STR" ] ; then
+ # check for application(s) using RTAPI
+ RTAPI_BUSY=$(echo $RTAPI_STR | grep [[] | wc -l )
+ if [ $RTAPI_BUSY -gt 0 ] ; then
+ # can't remove anything, realtime tasks might be running
+ # get name(s) of running apps - between '[' and ']'
+ RTAPI_APP=$(echo $RTAPI_STR | sed s/^.*[[]/[/)
+ echo "Can't remove realtime base, shut down $RTAPI_APP first"
+ exit -1
+ fi
+ echo Removing RTAPI
+ RTAPI_RTL=$(echo $RTAPI_STR | grep rtl | wc -l)
+ if [ $RTAPI_RTL -gt 0 ] ; then
+ /sbin/rmmod rtl_rtapi
+ fi
+ RTAPI_RTAI=$(echo $RTAPI_STR | grep rtai | wc -l)
+ if [ $RTAPI_RTAI -gt 0 ] ; then
+ /sbin/rmmod rtai_rtapi
+ fi
+ fi
+
+
# Get a list of currently installed modules.
modules=`/sbin/lsmod | gawk '{print $1}'`
***************
*** 23,28 ****
fi
depends=`/sbin/lsmod | sed 'y/[/ /' | sed 'y/]/ /' | sed 's#(unused)##' | sed 's#unused##' | gawk '/^'$mod'/ {print $4 " " $5 " " $6 " " $7 " " $8}'`
! dependcount=`echo $depends | wc -w`
! if [ $dependcount -gt 0 ] ; then
echo Removing kernel module $mod and anything that depends on it.
echo Including $depends
--- 47,52 ----
fi
depends=`/sbin/lsmod | sed 'y/[/ /' | sed 'y/]/ /' | sed 's#(unused)##' | sed 's#unused##' | gawk '/^'$mod'/ {print $4 " " $5 " " $6 " " $7 " " $8}'`
! dependcount=`echo $depends | wc -w`
! if [ $dependcount -gt 0 ] ; then
echo Removing kernel module $mod and anything that depends on it.
echo Including $depends
***************
*** 31,35 ****
echo Removing kernel module $mod
/sbin/rmmod $mod
! fi
;;
*)
--- 55,59 ----
echo Removing kernel module $mod
/sbin/rmmod $mod
! fi
;;
*)
***************
*** 37,41 ****
esac
done
!
exit 0
--- 61,65 ----
esac
done
!
exit 0
|
|
From: <pa...@us...> - 2003-07-26 22:06:29
|
Update of /cvsroot/emc/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv21491
Added Files:
CodingStyle
Log Message:
Initial version
--- NEW FILE: CodingStyle ---
Version: $Id: CodingStyle,v 1.1 2003/07/26 22:06:26 paul_c Exp $
Introduction
Most of this style guide has been copied wholesale from the linux kernel
documents - See linux/Documentation/CodingStyle for the full text.
Indentation
Rationale: The whole idea behind indentation is to clearly define where
a block of control starts and ends. Especially when you've been looking
at your screen for 20 straight hours, you'll find it a lot easier to see
how the indentation works if you have large indentations.
Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.
Placing Braces
The other issue that always comes up in C styling is the placement of
braces. Unlike the indent size, there are few technical reasons to
choose one placement strategy over the other, but the preferred way, as
shown to us by the prophets Kernighan and Ritchie, is to put the opening
brace last on the line, and put the closing brace first, thusly:
if (x is true) {
we do y
}
However, there is one special case, namely functions: they have the
opening brace at the beginning of the next line, thus:
int function(int x)
{
body of function
}
Note that the closing brace is empty on a line of its own, _except_ in
the cases where it is followed by a continuation of the same statement,
ie a "while" in a do-statement or an "else" in an if-statement, like
this:
do {
body of do-loop
} while (condition);
and
if (x == y) {
..
} else if (x > y) {
...
} else {
....
}
Also, note that this brace-placement also minimizes the number of empty
(or almost empty) lines, without any loss of readability. Thus, as the
supply of new-lines on your screen is not a renewable resource (think
25-line terminal screens here), you have more empty lines to put
comments on.
Naming
C is a Spartan language, and so should your naming be. Unlike Modula-2
and Pascal programmers, C programmers do not use cute names like
ThisVariableIsATemporaryCounter. A C programmer would call that
variable "tmp", which is much easier to write, and not the least more
difficult to understand.
HOWEVER, while mixed-case names are frowned upon, descriptive names for
global variables are a must. To call a global function "foo" is a
shooting offense.
GLOBAL variables (to be used only if you _really_ need them) need to
have descriptive names, as do global functions. If you have a function
that counts the number of active users, you should call that
"count_active_users()" or similar, you should _not_ call it "cntusr()".
Encoding the type of a function into the name (so-called Hungarian
notation) is brain damaged - the compiler knows the types anyway and can
check those, and it only confuses the programmer. No wonder MicroSoft
makes buggy programs.
LOCAL variable names should be short, and to the point. If you have
some random integer loop counter, it should probably be called "i".
Calling it "loop_counter" is non-productive, if there is no chance of it
being mis-understood. Similarly, "tmp" can be just about any type of
variable that is used to hold a temporary value.
If you are afraid to mix up your local variable names, you have another
problem, which is called the function-growth-hormone-imbalance syndrome.
See next chapter.
Functions
Functions should be short and sweet, and do just one thing. They should
fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24,
as we all know), and do one thing and do that well.
The maximum length of a function is inversely proportional to the
complexity and indentation level of that function. So, if you have a
conceptually simple function that is just one long (but simple)
case-statement, where you have to do lots of small things for a lot of
different cases, it's OK to have a longer function.
However, if you have a complex function, and you suspect that a
less-than-gifted first-year high-school student might not even
understand what the function is all about, you should adhere to the
maximum limits all the more closely. Use helper functions with
descriptive names (you can ask the compiler to in-line them if you think
it's performance-critical, and it will probably do a better job of it
that you would have done).
Another measure of the function is the number of local variables. They
shouldn't exceed 5-10, or you're doing something wrong. Re-think the
function, and split it into smaller pieces. A human brain can
generally easily keep track of about 7 different things, anything more
and it gets confused. You know you're brilliant, but maybe you'd like
to understand what you did 2 weeks from now.
Commenting
Comments are good, but there is also a danger of over-commenting. NEVER
try to explain HOW your code works in a comment: it's much better to
write the code so that the _working_ is obvious, and it's a waste of
time to explain badly written code.
Generally, you want your comments to tell WHAT your code does, not HOW.
Also, try to avoid putting comments inside a function body: if the
function is so complex that you need to separately comment parts of it,
you should probably re-read the Functions section again. You can make
small comments to note or warn about something particularly clever (or
ugly), but try to avoid excess. Instead, put the comments at the head
of the function, telling people what it does, and possibly WHY it does
it.
If comments along the lines of /* Fix me */ are used, please, please, say
why something needs fixing. When a change has been made to the affected
portion of code, either remove the comment, or amend it indicate a change
has been made and needs testing.
Shell Scripts & Makefiles
Not everyone has the same tools and packages installed. Some people use
vi, others emacs - A few even avoid having either package installed,
prefering a lightweight text editor such as nano or the one built in to
Midnight Commander.
gawk versus mawk - Again, not everyone will have gawk installed, mawk is
nearly a tenth of the size and yet conforms to the Posix AWK standard. If
some obscure gawk specific command is needed that mawk does not provide,
than the script will break for some users. The same would apply to mawk.
In short, use the generic awk invocation in preference to gawk or mawk.
CVS Notes
cvs is a very powefull tool that many developers fail to use to it's full
potential. http://www.red-bean/cvsbook should be compulsory reading for
anyone wanting to use cvs. The chapters on tags, branching, and merging
can appear daunting at first. Chapters covering administration, however,
can be skipped.
CVS Tags
Tagging files within the cvs repository enables us to mark a set of files
with a specific marker. This provides a simple mechanism to retrive code
thus marked. The tags could indicate a stable version, or be a precursor to
branching. Apart from branch tags, the recommendation is to prefix all tags
with the developers initials.
Note: Tags prefixed with bdi or BDI are reserved for use in conjunction with
the Brain Dead Install project.
Do not put anything below this point. The revision log is automatically appended
################################################################################
Revision Log
################################################################################
$Log: CodingStyle,v $
Revision 1.1 2003/07/26 22:06:26 paul_c
Initial version
|
|
From: <pa...@us...> - 2003-07-26 01:47:19
|
Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv8211/rtapi
Modified Files:
rtai_rtapi.c rtai_ulapi.c
Log Message:
Added braces to some of the conditional routines
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rtai_rtapi.c 25 Jul 2003 04:11:55 -0000 1.7
--- rtai_rtapi.c 25 Jul 2003 22:04:20 -0000 1.8
***************
*** 9,13 ****
#include <linux/kernel.h>
/* FIXME - on my system malloc.h is deprecated, use slab.h instead */
! /* #include <linux/malloc.h> */ /* kmalloc(), kfree(), GFP_USER */
#include <linux/slab.h>
--- 9,13 ----
#include <linux/kernel.h>
/* FIXME - on my system malloc.h is deprecated, use slab.h instead */
! /* #include <linux/malloc.h> *//* kmalloc(), kfree(), GFP_USER */
#include <linux/slab.h>
[...1053 lines suppressed...]
! int rtapi_fifo_write(rtapi_fifo_handle fifo, char *buf,
! unsigned long int size)
{
! int retval;
/* validate fifo handle */
! if (fifo == NULL) {
return RTAPI_BADH;
! }
! if (fifo->magic != FIFO_MAGIC) {
return RTAPI_BADH;
! }
/* get whatever data is available */
! retval = rtf_put(fifo->fd, buf, size);
! if (retval < 0) {
return RTAPI_INVAL;
+ }
return retval;
}
Index: rtai_ulapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_ulapi.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rtai_ulapi.c 19 Jul 2003 07:17:22 -0000 1.2
--- rtai_ulapi.c 25 Jul 2003 22:04:20 -0000 1.3
***************
*** 19,38 ****
struct ulapi_shmem {
! int magic; /* to check for valid handle */
! int key; /* key to shared memory area */
! unsigned long int size; /* size of shared memory area */
! void *mem; /* pointer to the memory */
! };
struct ulapi_fifo {
! int magic; /* to check for valid handle */
! int key; /* key to fifo */
! int fd; /* file descripter for fifo */
! int mode; /* O_RDONLY or O_WRONLY */
! unsigned long int size; /* size of fifo area */
! };
! #define SHMEM_MAGIC 25453 /* random numbers used as signatures */
#define FIFO_MAGIC 10293
--- 19,38 ----
struct ulapi_shmem {
! int magic; /* to check for valid handle */
! int key; /* key to shared memory area */
! unsigned long int size; /* size of shared memory area */
! void *mem; /* pointer to the memory */
! };
struct ulapi_fifo {
! int magic; /* to check for valid handle */
! int key; /* key to fifo */
! int fd; /* file descripter for fifo */
! int mode; /* O_RDONLY or O_WRONLY */
! unsigned long int size; /* size of fifo area */
! };
! #define SHMEM_MAGIC 25453 /* random numbers used as signatures */
#define FIFO_MAGIC 10293
***************
*** 52,73 ****
! int ulapi_shmem_new( int key, unsigned int size,
! ulapi_shmem_handle *shmemptr )
{
! ulapi_shmem_handle shmem;
/* validate shmemptr */
! if ( shmemptr == NULL )
return ULAPI_INVAL;
!
/* alloc space for shmem structure */
! shmem = malloc( sizeof(struct ulapi_shmem) );
! if ( shmem == NULL )
return ULAPI_NOMEM;
!
/* now get shared memory block from OS */
shmem->mem = rtai_malloc(key, size);
! if ( shmem->mem == NULL ) {
! free ( shmem );
return ULAPI_NOMEM;
}
--- 52,72 ----
! int ulapi_shmem_new(int key, unsigned int size, ulapi_shmem_handle * shmemptr)
{
! ulapi_shmem_handle shmem;
/* validate shmemptr */
! if (shmemptr == NULL) {
return ULAPI_INVAL;
! }
/* alloc space for shmem structure */
! shmem = malloc(sizeof(struct ulapi_shmem));
! if (shmem == NULL) {
return ULAPI_NOMEM;
! }
/* now get shared memory block from OS */
shmem->mem = rtai_malloc(key, size);
! if (shmem->mem == NULL) {
! free(shmem);
return ULAPI_NOMEM;
}
***************
*** 85,96 ****
! int ulapi_shmem_getptr ( ulapi_shmem_handle shmem, void **ptr )
{
/* validate shmem handle */
! if ( shmem == NULL )
return ULAPI_BADH;
! if ( shmem->magic != SHMEM_MAGIC )
return ULAPI_BADH;
!
/* pass memory address back to caller */
*ptr = shmem->mem;
--- 84,96 ----
! int ulapi_shmem_getptr(ulapi_shmem_handle shmem, void **ptr)
{
/* validate shmem handle */
! if (shmem == NULL) {
return ULAPI_BADH;
! }
! if (shmem->magic != SHMEM_MAGIC) {
return ULAPI_BADH;
! }
/* pass memory address back to caller */
*ptr = shmem->mem;
***************
*** 100,153 ****
! int ulapi_shmem_delete( ulapi_shmem_handle shmem )
{
/* validate shmem handle */
! if ( shmem == NULL )
return ULAPI_BADH;
! if ( shmem->magic != SHMEM_MAGIC )
return ULAPI_BADH;
!
/* free the shared memory */
! rtai_free( shmem->key, shmem->mem );
/* free the shmem structure */
shmem->magic = 0;
! free ( shmem );
return ULAPI_SUCCESS;
}
! int ulapi_fifo_new( int key, unsigned long int size, char mode,
! ulapi_fifo_handle *fifoptr )
{
! ulapi_fifo_handle fifo;
! int retval, flags;
! enum { DEVSTR_LEN = 256 };
! char devstr[DEVSTR_LEN];
/* validate fifoptr */
! if ( fifoptr == NULL )
return ULAPI_INVAL;
!
/* alloc space for fifo structure */
! fifo = malloc( sizeof(struct ulapi_fifo) );
! if ( fifo == NULL )
return ULAPI_NOMEM;
!
/* determine system name for fifo */
sprintf(devstr, "/dev/rtf%d", key);
/* determine mode for fifo */
! if ( mode == 'R' )
flags = O_RDONLY;
! else if ( mode == 'W' )
! flags = O_WRONLY;
! else
! return ULAPI_INVAL;
/* open the fifo */
! retval = open( devstr, flags );
! if ( retval < 0 ) {
/* open failed */
! free ( fifo );
return ULAPI_NOTFND;
}
--- 100,158 ----
! int ulapi_shmem_delete(ulapi_shmem_handle shmem)
{
/* validate shmem handle */
! if (shmem == NULL) {
return ULAPI_BADH;
! }
! if (shmem->magic != SHMEM_MAGIC) {
return ULAPI_BADH;
! }
/* free the shared memory */
! rtai_free(shmem->key, shmem->mem);
/* free the shmem structure */
shmem->magic = 0;
! free(shmem);
return ULAPI_SUCCESS;
}
! int ulapi_fifo_new(int key, unsigned long int size, char mode,
! ulapi_fifo_handle * fifoptr)
{
! ulapi_fifo_handle fifo;
! int retval, flags;
! enum { DEVSTR_LEN = 256 };
! char devstr[DEVSTR_LEN];
/* validate fifoptr */
! if (fifoptr == NULL) {
return ULAPI_INVAL;
! }
/* alloc space for fifo structure */
! fifo = malloc(sizeof(struct ulapi_fifo));
! if (fifo == NULL) {
return ULAPI_NOMEM;
! }
/* determine system name for fifo */
sprintf(devstr, "/dev/rtf%d", key);
/* determine mode for fifo */
! if (mode == 'R') {
flags = O_RDONLY;
! } else {
! if (mode == 'W') {
! flags = O_WRONLY;
! }
+ else {
+ return ULAPI_INVAL;
+ }
+ }
/* open the fifo */
! retval = open(devstr, flags);
! if (retval < 0) {
/* open failed */
! free(fifo);
return ULAPI_NOTFND;
}
***************
*** 166,227 ****
! int ulapi_fifo_delete( ulapi_fifo_handle fifo )
{
/* validate fifo handle */
! if ( fifo == NULL )
return ULAPI_BADH;
! if ( fifo->magic != FIFO_MAGIC )
return ULAPI_BADH;
!
/* close the fifo */
! if ( close( fifo->fd ) < 0 )
return ULAPI_NOTFND;
!
/* free the fifo structure */
fifo->magic = 0;
! free ( fifo );
return ULAPI_SUCCESS;
}
! int ulapi_fifo_read( ulapi_fifo_handle fifo,
! char *buf, unsigned long int size)
{
! int retval;
/* validate fifo handle */
! if ( fifo == NULL )
return ULAPI_BADH;
! if ( fifo->magic != FIFO_MAGIC )
return ULAPI_BADH;
! if ( fifo->mode != O_RDONLY )
return ULAPI_UNSUP;
!
/* get whatever data is available */
! retval = read( fifo->fd, buf, size );
! if ( retval < 0 )
return ULAPI_FAIL;
return retval;
}
! int ulapi_fifo_write( ulapi_fifo_handle fifo,
! char *buf, unsigned long int size)
{
! int retval;
/* validate fifo handle */
! if ( fifo == NULL )
return ULAPI_BADH;
! if ( fifo->magic != FIFO_MAGIC )
return ULAPI_BADH;
! if ( fifo->mode != O_WRONLY )
return ULAPI_UNSUP;
/* get whatever data is available */
! retval = write( fifo->fd, buf, size );
! if ( retval < 0 )
return ULAPI_FAIL;
return retval;
}
-
--- 171,238 ----
! int ulapi_fifo_delete(ulapi_fifo_handle fifo)
{
/* validate fifo handle */
! if (fifo == NULL) {
return ULAPI_BADH;
! }
! if (fifo->magic != FIFO_MAGIC) {
return ULAPI_BADH;
! }
/* close the fifo */
! if (close(fifo->fd) < 0) {
return ULAPI_NOTFND;
! }
/* free the fifo structure */
fifo->magic = 0;
! free(fifo);
return ULAPI_SUCCESS;
}
! int ulapi_fifo_read(ulapi_fifo_handle fifo, char *buf, unsigned long int size)
{
! int retval;
/* validate fifo handle */
! if (fifo == NULL) {
return ULAPI_BADH;
! }
! if (fifo->magic != FIFO_MAGIC) {
return ULAPI_BADH;
! }
! if (fifo->mode != O_RDONLY) {
return ULAPI_UNSUP;
! }
/* get whatever data is available */
! retval = read(fifo->fd, buf, size);
! if (retval < 0) {
return ULAPI_FAIL;
+ }
return retval;
}
! int ulapi_fifo_write(ulapi_fifo_handle fifo,
! char *buf, unsigned long int size)
{
! int retval;
/* validate fifo handle */
! if (fifo == NULL) {
return ULAPI_BADH;
! }
! if (fifo->magic != FIFO_MAGIC) {
return ULAPI_BADH;
! }
! if (fifo->mode != O_WRONLY) {
return ULAPI_UNSUP;
+ }
/* get whatever data is available */
! retval = write(fifo->fd, buf, size);
! if (retval < 0) {
return ULAPI_FAIL;
+ }
return retval;
}
|
|
From: <pa...@us...> - 2003-07-26 01:47:19
|
Update of /cvsroot/emc/rtapi/examples/timertask
In directory sc8-pr-cvs1:/tmp/cvs-serv8246/timertask
Modified Files:
timertask.c
Log Message:
Added braces to some of the conditional routines
Index: timertask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/timertask/timertask.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** timertask.c 23 Jul 2003 01:22:49 -0000 1.3
--- timertask.c 25 Jul 2003 22:04:34 -0000 1.4
***************
*** 17,21 ****
--- 17,23 ----
{
while (1) {
+ /* a simple counter... */
timer_count++;
+ /* put the task to sleep untill the next interrupt */
rtapi_wait();
}
***************
*** 25,28 ****
--- 27,32 ----
/* part of the Linux kernel module that kicks off the timer task */
+ /* rtapi_app_main() is expanded to init_module() via a macro in
+ rtapi_app.h */
int rtapi_app_main(void)
{
***************
*** 47,56 ****
--- 51,64 ----
/* create the timer task */
+ /* the address of the pointer needs to be passed rather than it's value */
retval = rtapi_task_new( &timer_task );
if ( retval != RTAPI_SUCCESS ) {
+ /* See rtapi.h for the error codes returned */
rtapi_print( "timertask init: rtapi_task_new returned %d\n", retval );
return -1;
}
+ /* the third arg is an abitrary int that is passed to the timer task
+ on the first iterration */
retval = rtapi_task_start( timer_task, timer_code,
0, timer_prio,
***************
*** 68,75 ****
--- 76,86 ----
/* part of the Linux kernel module that stops the timer task */
+ /* rtapi_app_exit() is substituted for cleanup_module() by a
+ macro in rtapi_app.h */
void rtapi_app_exit(void)
{
int retval;
+ /* Stop the task */
retval = rtapi_task_stop(timer_task);
if ( retval != RTAPI_SUCCESS ) {
***************
*** 77,80 ****
--- 88,92 ----
return;
}
+ /* Remove the task from the list */
retval = rtapi_task_delete( timer_task );
if ( retval != RTAPI_SUCCESS ) {
***************
*** 83,88 ****
}
rtapi_print("timertask exit: timer count is %d\n", timer_count);
!
rtapi_app_return();
}
--- 95,102 ----
}
+ /* Print the final count just to show that the task did it's job */
rtapi_print("timertask exit: timer count is %d\n", timer_count);
! /* Clean up and exit */
rtapi_app_return();
+
}
|
|
From: <pa...@us...> - 2003-07-26 01:47:18
|
Update of /cvsroot/emc/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv8400
Modified Files:
configure
Log Message:
Another fix for the adeos V TNG conflict
Index: configure
===================================================================
RCS file: /cvsroot/emc/rtapi/configure,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** configure 25 Jul 2003 01:40:38 -0000 1.5
--- configure 25 Jul 2003 22:05:29 -0000 1.6
***************
*** 22,25 ****
--- 22,33 ----
echo MOD_DIR = /lib/modules/$version/misc >> Makefile.inc
+ if [ $(/sbin/ksyms -a | grep _adeos_ | wc -l) -ge 1 ] ; then
+ if [ -d /lib/modules/$version/build ] ; then
+ # We have a 2.4 or later kernel if this symlink exists,
+ # so add an include to the correct headers for the kernel running.
+ echo KERNEL_INC = -I/lib/modules/$version/build/include >> Makefile.inc
+ fi
+ fi
+
echo CC = gcc >> Makefile.inc
echo CFLAGS = -g -Wall -I\$\(INC_DIR\) >> Makefile.inc
***************
*** 88,104 ****
# ditto for an RTAI boot by looking through the kernel for telltale symbols:
# set_rtai_callback, remove_rtai_callback for 2.2, 2.4 kernels
! RTAIBOOT=$(/sbin/ksyms -a | grep _rtai_ | wc -l)
if [ $RTAIBOOT -gt 0 ] ; then
echo found RTAI installed in the kernel
fi
! # ditto for an ADEOS boot by looking through the kernel for telltale symbols:
! # ???_adeos_????, ????_adeos_????
! ADEOSBOOT=$(/sbin/ksyms -a | grep _adeos_ | wc -l)
! if [ $ADEOSBOOT -gt 0 ] ; then
! echo found ADEOS installed in the kernel
! fi
!
! # append stuff into Makefile.inc only if we have found the RTL dir
# and have booted it
if [ "$RTLDIR" != "" -a $RTLBOOT -gt 0 ] ; then
--- 96,105 ----
# ditto for an RTAI boot by looking through the kernel for telltale symbols:
# set_rtai_callback, remove_rtai_callback for 2.2, 2.4 kernels
! RTAIBOOT=$(/sbin/ksyms -a | grep -E '(_rtai_|_adeos_)' | wc -l)
if [ $RTAIBOOT -gt 0 ] ; then
echo found RTAI installed in the kernel
fi
! # append stuff into Makefile.inc only if we have found the RTL dir
# and have booted it
if [ "$RTLDIR" != "" -a $RTLBOOT -gt 0 ] ; then
***************
*** 150,162 ****
rm -f configure.tmp
# end of JK hack
-
- # Paul added this at the top to make adeos RTAI work, but it causes warnings
- # when compiling rtai_rtapi.c for "regular" rtai. (BDI-TNG)
- # So I moved it down here and only do it if adeos is present - jmkasunich
- if [ -d /lib/modules/$version/build -a $ADEOSBOOT -gt 0 ] ; then
- # We have a 2.4 or later kernel if this symlink exists,
- # so add an include to the correct headers for the kernel running.
- echo KERNEL_INC = -I/lib/modules/$version/build/include >> Makefile.inc
- fi
# leave when we configured one
--- 151,154 ----
|
|
From: <jmk...@us...> - 2003-07-25 04:11:58
|
Update of /cvsroot/emc/rtapi/examples/fifo
In directory sc8-pr-cvs1:/tmp/cvs-serv2846/examples/fifo
Modified Files:
fifotask.c fifousr.c
Log Message:
troubleshooting fifos
Index: fifotask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/fifo/fifotask.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fifotask.c 23 Jul 2003 01:22:49 -0000 1.2
--- fifotask.c 25 Jul 2003 04:11:55 -0000 1.3
***************
*** 11,15 ****
static rtapi_task_handle fifo_task = 0; /* the task structure */
static rtapi_fifo_handle fifo;
! enum { FIFO_PERIOD_NSEC = 10000000 }; /* timer period, in nanoseconds */
enum { FIFO_STACKSIZE = 1024 }; /* how big the stack is */
--- 11,15 ----
static rtapi_task_handle fifo_task = 0; /* the task structure */
static rtapi_fifo_handle fifo;
! enum { FIFO_PERIOD_NSEC = 1000000000 }; /* timer period, in nanoseconds */
enum { FIFO_STACKSIZE = 1024 }; /* how big the stack is */
***************
*** 27,30 ****
--- 27,32 ----
}
rtapi_fifo_write ( fifo, buffer, count );
+ buffer[n] = '\0';
+ rtapi_print ( "fifotask: wrote '%s'\n", buffer );
count++;
if ( count > 9 )
***************
*** 49,53 ****
--- 51,57 ----
/* allocate and initialize the fifo */
+ /* debug, remove when working */ rtapi_print ( "debug - Calling rtapi_fifo_new()\n" );
retval = rtapi_fifo_new( FIFO_KEY, FIFO_SIZE, &fifo );
+ /* debug, remove when working */ rtapi_print( "debug - fifotask init: rtapi_fifo_new returned %d\n", retval );
if ( retval != RTAPI_SUCCESS ) {
rtapi_print( "fifotask init: rtapi_fifo_new returned %d\n", retval );
***************
*** 110,114 ****
}
! rtapi_print("fifotask exit: %d writes\n", count);
rtapi_app_return();
--- 114,118 ----
}
! rtapi_print("fifotask exit: done\n" );
rtapi_app_return();
Index: fifousr.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/fifo/fifousr.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fifousr.c 23 Jul 2003 01:22:49 -0000 1.2
--- fifousr.c 25 Jul 2003 04:11:55 -0000 1.3
***************
*** 41,44 ****
--- 41,46 ----
signal(SIGINT, quit);
+ printf ( "waiting for fifo data, ctrl-C to quit\n" );
+
while (1) {
nchars = ulapi_fifo_read( fifo, buffer, FIFO_SIZE );
|
|
From: <jmk...@us...> - 2003-07-25 04:11:58
|
Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv2846/src/rtapi
Modified Files:
rtai_rtapi.c
Log Message:
troubleshooting fifos
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rtai_rtapi.c 23 Jul 2003 01:22:50 -0000 1.6
--- rtai_rtapi.c 25 Jul 2003 04:11:55 -0000 1.7
***************
*** 596,604 ****
/* create the fifo */
retval = rtf_create ( key, size );
if ( retval != size ) {
/* create failed */
kfree ( fifo );
- rtapi_print ( "rtapi_fifo_new: rtf_create ( %d, %d ) returned %d\n", key, size, retval );
if ( retval == ENOMEM )
/* couldn't allocate memory */
--- 596,608 ----
/* create the fifo */
+ /* debug, remove when working */ rtapi_print ( "rtapi_fifo_new: calling rtf_create( %d, %d)\n", key, size );
retval = rtf_create ( key, size );
+ /* debug, remove when working */ rtapi_print ( "rtapi_fifo_new: rtf_create ( %d, %d ) returned %d\n", key, size, retval );
+
+ #if ( 1 ) /* set to 1 to ignore bad return from rtf_create() */
+
if ( retval != size ) {
/* create failed */
kfree ( fifo );
if ( retval == ENOMEM )
/* couldn't allocate memory */
***************
*** 606,609 ****
--- 610,615 ----
return RTAPI_INVAL;
}
+
+ #endif
/* label as a valid fifo structure */
|
|
From: <jmk...@us...> - 2003-07-25 01:40:41
|
Update of /cvsroot/emc/rtapi/src/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv15521/src/rtapi Modified Files: localdefs.h rtapi.h Log Message: tweaked the adeos mods in configure script Index: localdefs.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/localdefs.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** localdefs.h 22 Jul 2003 17:20:22 -0000 1.5 --- localdefs.h 25 Jul 2003 01:40:38 -0000 1.6 *************** *** 2,8 **** #define LOCALDEFS_H ! /* automatically generated by config script on Tue Jul 22 13:03:40 UTC 2003 */ ! #define LOCAL_MHZ 807.966 #endif --- 2,8 ---- #define LOCALDEFS_H ! /* automatically generated by config script on Thu Jul 24 21:36:47 EDT 2003 */ ! #define LOCAL_MHZ 233.866 #endif Index: rtapi.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** rtapi.h 23 Jul 2003 01:22:50 -0000 1.7 --- rtapi.h 25 Jul 2003 01:40:38 -0000 1.8 *************** *** 20,23 **** --- 20,24 ---- /** Typedefs for object handles. The structs to which these handles * * refer are private, and may vary from one RTOS to another. * + * In fact, don't even count on handles always being pointers. */ |
|
From: <jmk...@us...> - 2003-07-25 01:40:41
|
Update of /cvsroot/emc/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv15521
Modified Files:
Makefile.inc configure
Log Message:
tweaked the adeos mods in configure script
Index: Makefile.inc
===================================================================
RCS file: /cvsroot/emc/rtapi/Makefile.inc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.inc 23 Jul 2003 01:22:49 -0000 1.5
--- Makefile.inc 25 Jul 2003 01:40:38 -0000 1.6
***************
*** 18,22 ****
# Makefile add-ons from rtai.mk
! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE
ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include
RTLINK = ld -r -static
--- 18,22 ----
# Makefile add-ons from rtai.mk
! RTFLAGS = -Wall $(KERNEL_INC) -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE
ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include
RTLINK = ld -r -static
Index: configure
===================================================================
RCS file: /cvsroot/emc/rtapi/configure,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** configure 23 Jul 2003 01:22:49 -0000 1.4
--- configure 25 Jul 2003 01:40:38 -0000 1.5
***************
*** 22,31 ****
echo MOD_DIR = /lib/modules/$version/misc >> Makefile.inc
- if [ -d /lib/modules/$version/build ] ; then
- # We have a 2.4 or later kernel if this symlink exists,
- # so add an include to the correct headers for the kernel running.
- echo KERNEL_INC = -I/lib/modules/$version/build/include >> Makefile.inc
- fi
-
echo CC = gcc >> Makefile.inc
echo CFLAGS = -g -Wall -I\$\(INC_DIR\) >> Makefile.inc
--- 22,25 ----
***************
*** 94,103 ****
# ditto for an RTAI boot by looking through the kernel for telltale symbols:
# set_rtai_callback, remove_rtai_callback for 2.2, 2.4 kernels
! RTAIBOOT=$(/sbin/ksyms -a | grep -E '(_rtai_|_adeos_)' | wc -l)
if [ $RTAIBOOT -gt 0 ] ; then
echo found RTAI installed in the kernel
fi
! # append stuff into Makefile.inc only if we have found the RTL dir
# and have booted it
if [ "$RTLDIR" != "" -a $RTLBOOT -gt 0 ] ; then
--- 88,104 ----
# ditto for an RTAI boot by looking through the kernel for telltale symbols:
# set_rtai_callback, remove_rtai_callback for 2.2, 2.4 kernels
! RTAIBOOT=$(/sbin/ksyms -a | grep _rtai_ | wc -l)
if [ $RTAIBOOT -gt 0 ] ; then
echo found RTAI installed in the kernel
fi
! # ditto for an ADEOS boot by looking through the kernel for telltale symbols:
! # ???_adeos_????, ????_adeos_????
! ADEOSBOOT=$(/sbin/ksyms -a | grep _adeos_ | wc -l)
! if [ $ADEOSBOOT -gt 0 ] ; then
! echo found ADEOS installed in the kernel
! fi
!
! # append stuff into Makefile.inc only if we have found the RTL dir
# and have booted it
if [ "$RTLDIR" != "" -a $RTLBOOT -gt 0 ] ; then
***************
*** 149,152 ****
--- 150,162 ----
rm -f configure.tmp
# end of JK hack
+
+ # Paul added this at the top to make adeos RTAI work, but it causes warnings
+ # when compiling rtai_rtapi.c for "regular" rtai. (BDI-TNG)
+ # So I moved it down here and only do it if adeos is present - jmkasunich
+ if [ -d /lib/modules/$version/build -a $ADEOSBOOT -gt 0 ] ; then
+ # We have a 2.4 or later kernel if this symlink exists,
+ # so add an include to the correct headers for the kernel running.
+ echo KERNEL_INC = -I/lib/modules/$version/build/include >> Makefile.inc
+ fi
# leave when we configured one
|
|
From: <jmk...@us...> - 2003-07-23 01:22:53
|
Update of /cvsroot/emc/rtapi/examples/shmem
In directory sc8-pr-cvs1:/tmp/cvs-serv23441/examples/shmem
Modified Files:
shmemtask.c shmemusr.c
Log Message:
changed examples to use new api - fifo not working yet
Index: shmemtask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/shmem/shmemtask.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** shmemtask.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- shmemtask.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 9,22 ****
#include "common.h" /* shmem structure, SHMEM_KEY */
! static void *shmem_task = 0; /* the task structure */
enum { SHMEM_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
enum { SHMEM_STACKSIZE = 1024 }; /* how big the stack is */
static int key = SHMEM_KEY;
- static int id = 0;
static SHMEM_STRUCT *shmem_struct = 0;
/* task code, executed each timer interrupt */
! void shmem_code(void)
{
while (1) {
--- 9,22 ----
#include "common.h" /* shmem structure, SHMEM_KEY */
! static rtapi_task_handle shmem_task; /* the task */
! static rtapi_shmem_handle shmem_mem; /* the shared memory area */
enum { SHMEM_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
enum { SHMEM_STACKSIZE = 1024 }; /* how big the stack is */
static int key = SHMEM_KEY;
static SHMEM_STRUCT *shmem_struct = 0;
/* task code, executed each timer interrupt */
! void shmem_code ( int arg )
{
while (1) {
***************
*** 33,70 ****
int rtapi_app_main(void)
{
int shmem_prio;
- int t;
if (0 != rtapi_init()) {
return -1;
}
/* allocate and initialize the shared memory structure */
! if (0 != rtapi_alloc_shmem(key, sizeof(SHMEM_STRUCT), &id,
! (void **) &shmem_struct)) {
! rtapi_print("shmemtask: can't allocate shared memory\n");
return -1;
}
shmem_struct->heartbeat = 0;
/* set the base timer period */
! rtapi_clock_set_period(SHMEM_PERIOD_NSEC);
/* set the task priority to lowest, since we only have one task */
shmem_prio = rtapi_prio_lowest();
! /* launch the shmem task */
! shmem_task = rtapi_task_new();
! if (0 == shmem_task) {
! rtapi_print("shmemtask: can't create shmem task\n");
return -1;
}
! if (0 != rtapi_task_start(shmem_task, shmem_code, shmem_prio, SHMEM_STACKSIZE, SHMEM_PERIOD_NSEC, 0)) { /* 0 = no floating point */
! rtapi_print("shmemtask: can't start shmem task\n");
return -1;
}
! rtapi_print("shmemtask: started shmem task\n");
return 0;
--- 33,87 ----
int rtapi_app_main(void)
{
+ int retval;
int shmem_prio;
+ /*
if (0 != rtapi_init()) {
return -1;
}
+ */
/* allocate and initialize the shared memory structure */
! retval = rtapi_shmem_new( key, sizeof(SHMEM_STRUCT), &shmem_mem );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "shmemtask init: rtapi_shmem_new returned %d\n", retval );
return -1;
}
+ retval = rtapi_shmem_getptr( shmem_mem, (void **)&shmem_struct );
+ if ( retval != RTAPI_SUCCESS ) {
+ rtapi_print( "shmemtask init: rtapi_shmem_getptr returned %d\n", retval );
+ return -1;
+ }
+
shmem_struct->heartbeat = 0;
/* set the base timer period */
! retval = rtapi_clock_set_period(SHMEM_PERIOD_NSEC);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "shmemtask init: rtapi_clock_set_period returned %d\n", retval );
! return -1;
! }
/* set the task priority to lowest, since we only have one task */
shmem_prio = rtapi_prio_lowest();
! /* create the shmem task */
! retval = rtapi_task_new( &shmem_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "shmemtask init: rtapi_task_new returned %d\n", retval );
return -1;
}
! /* start the shmem task */
! retval = rtapi_task_start( shmem_task, shmem_code,
! 0, shmem_prio,
! SHMEM_STACKSIZE,
! SHMEM_PERIOD_NSEC, RTAPI_NO_FP );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("shmemtask init: rtapi_task_start returned %d\n", retval );
return -1;
}
! rtapi_print("shmemtask init: started shmem task\n");
return 0;
***************
*** 74,97 ****
void rtapi_app_exit(void)
{
if (0 != shmem_struct) {
! rtapi_print("shmemtask: heartbeat is %u\n", shmem_struct->heartbeat);
}
! if (0 != shmem_task) {
! if (0 != rtapi_task_stop(shmem_task)) {
! rtapi_print("shmemtask: can't stop shmem task\n");
! }
! if (0 != rtapi_task_delete(shmem_task)) {
! rtapi_print("shmemtask: can't delete shmem task\n");
! }
! shmem_task = 0;
}
! if (0 != shmem_struct) {
! if (0 != rtapi_free_shmem(key, sizeof(SHMEM_STRUCT),
! id, (void *) shmem_struct)) {
! rtapi_print("shmemtask: can't free shared memory\n");
! }
! shmem_struct = 0;
}
--- 91,115 ----
void rtapi_app_exit(void)
{
+ int retval;
+
if (0 != shmem_struct) {
! rtapi_print("shmemtask exit: heartbeat is %u\n", shmem_struct->heartbeat);
}
! retval = rtapi_task_stop( shmem_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("shmemtask exit: rtapi_task_stop returned %d\n", retval );
! return;
! }
! retval = rtapi_task_delete( shmem_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("shmemtask exit: rtapi_task_delete returned %d\n", retval );
! return;
}
! retval = rtapi_shmem_delete( shmem_mem );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("shmemtask exit: rtapi_shmem_delete returned %d\n", retval );
! return;
}
Index: shmemusr.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/shmem/shmemusr.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** shmemusr.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- shmemusr.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 6,10 ****
static int key = SHMEM_KEY;
! static int id = 0;
static SHMEM_STRUCT *shmem_struct;
--- 6,10 ----
static int key = SHMEM_KEY;
! static ulapi_shmem_handle shmem_mem;
static SHMEM_STRUCT *shmem_struct;
***************
*** 17,29 ****
int main()
{
! if (0 != ulapi_init()) {
! fprintf(stderr, "can't initialize user-level interface\n");
return -1;
}
! if (0 != ulapi_alloc_shmem(key, sizeof(SHMEM_STRUCT), &id,
! (void **) &shmem_struct) || 0 == shmem_struct) {
! fprintf(stderr, "can't allocate shared memory\n");
return -1;
}
--- 17,37 ----
int main()
{
+ int retval;
! retval = ulapi_init();
! if ( retval != ULAPI_SUCCESS ) {
! printf("shmemusr main: ulapi_init returned %d\n", retval );
return -1;
}
! /* allocate the shared memory structure */
! retval = ulapi_shmem_new( key, sizeof(SHMEM_STRUCT), &shmem_mem );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "shmemusr main: ulapi_shmem_new returned %d\n", retval );
! return -1;
! }
! retval = ulapi_shmem_getptr( shmem_mem, (void **)&shmem_struct );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "shmemusr main: ulapi_shmem_getptr returned %d\n", retval );
return -1;
}
***************
*** 31,41 ****
signal(SIGINT, quit);
while (!done) {
! printf("%u\n", shmem_struct->heartbeat);
sleep(1);
}
! if (0 != shmem_struct) {
! ulapi_free_shmem(key, sizeof(shmem_struct), id, shmem_struct);
! shmem_struct = 0;
}
--- 39,50 ----
signal(SIGINT, quit);
while (!done) {
! printf("%lu\n", shmem_struct->heartbeat);
sleep(1);
}
! retval = ulapi_shmem_delete( shmem_mem );
! if ( retval != ULAPI_SUCCESS ) {
! printf("shmemusr main: ulapi_free_shmem returned %d\n", retval );
! return -1;
}
|
|
From: <jmk...@us...> - 2003-07-23 01:22:53
|
Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv23441/src/rtapi
Modified Files:
rtai_rtapi.c rtapi.h
Log Message:
changed examples to use new api - fifo not working yet
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rtai_rtapi.c 22 Jul 2003 17:20:22 -0000 1.5
--- rtai_rtapi.c 23 Jul 2003 01:22:50 -0000 1.6
***************
*** 108,113 ****
! int rtapi_init(void)
{
rt_linux_use_fpu(1);
return RTAPI_SUCCESS;
--- 108,115 ----
!
! static int rtapi_init(void)
{
+ rtapi_print( "Initing RTAPI\n" );
rt_linux_use_fpu(1);
return RTAPI_SUCCESS;
***************
*** 115,124 ****
! int rtapi_exit(void)
{
return RTAPI_SUCCESS;
}
int rtapi_clock_set_period(unsigned long int nsecs)
{
--- 117,138 ----
! static int rtapi_exit(void)
{
+ rtapi_print ( "Removing RTAPI\n" );
return RTAPI_SUCCESS;
}
+ int init_module ( void )
+ {
+ return ( rtapi_init() );
+ }
+
+ void cleanup_module ( void )
+ {
+ rtapi_exit();
+ }
+
+
int rtapi_clock_set_period(unsigned long int nsecs)
{
***************
*** 134,138 ****
/* validate taskptr */
! if ( &taskptr == NULL )
return RTAPI_INVAL;
--- 148,152 ----
/* validate taskptr */
! if ( taskptr == NULL )
return RTAPI_INVAL;
***************
*** 146,150 ****
/* and return handle to the caller */
! taskptr = task;
return RTAPI_SUCCESS;
--- 160,164 ----
/* and return handle to the caller */
! *taskptr = task;
return RTAPI_SUCCESS;
***************
*** 427,435 ****
retval = rt_request_global_irq(irq, handler);
! if ( retval != 0 )
if ( retval == EBUSY )
return RTAPI_BUSY;
else
! return RTAPI_INVAL;
return RTAPI_SUCCESS;
}
--- 441,450 ----
retval = rt_request_global_irq(irq, handler);
! if ( retval != 0 ) {
if ( retval == EBUSY )
return RTAPI_BUSY;
else
! return RTAPI_FAIL;
! }
return RTAPI_SUCCESS;
}
***************
*** 443,447 ****
retval = rt_free_global_irq(irq);
if ( retval != 0 )
! return RTAPI_INVAL;
return RTAPI_SUCCESS;
}
--- 458,462 ----
retval = rt_free_global_irq(irq);
if ( retval != 0 )
! return RTAPI_FAIL;
return RTAPI_SUCCESS;
}
***************
*** 585,588 ****
--- 600,604 ----
/* create failed */
kfree ( fifo );
+ rtapi_print ( "rtapi_fifo_new: rtf_create ( %d, %d ) returned %d\n", key, size, retval );
if ( retval == ENOMEM )
/* couldn't allocate memory */
Index: rtapi.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rtapi.h 22 Jul 2003 17:20:22 -0000 1.6
--- rtapi.h 23 Jul 2003 01:22:50 -0000 1.7
***************
*** 14,18 ****
#define RTAPI_FAIL -8 /* operation failed */
!
/** Typedefs for object handles. The structs to which these handles *
--- 14,20 ----
#define RTAPI_FAIL -8 /* operation failed */
! /* flags for the rtapi_task_start() call */
! #define RTAPI_NO_FP 0
! #define RTAPI_USES_FP 1
/** Typedefs for object handles. The structs to which these handles *
***************
*** 29,33 ****
* any rtapi functions. Returns a status code, as defined above. */
! extern int rtapi_init( void );
--- 31,35 ----
* any rtapi functions. Returns a status code, as defined above. */
! /* extern int rtapi_init( void ); */
***************
*** 36,40 ****
* status code. */
! extern int rtapi_exit( void );
--- 38,42 ----
* status code. */
! /* extern int rtapi_exit( void ); */
***************
*** 95,99 ****
* rtapi_task_new(). 'taskcode' is the name of a function taking one *
* int and returning void, which contains the task code. 'arg' will be *
! * passed to 'taskcode' as an abitrary int value when the task is *
* invoked. 'prio' is the priority, as determined by one of the *
* priority functions above. *
--- 97,101 ----
* rtapi_task_new(). 'taskcode' is the name of a function taking one *
* int and returning void, which contains the task code. 'arg' will be *
! * passed to 'taskcode' as an abitrary int value when the task is *
* invoked. 'prio' is the priority, as determined by one of the *
* priority functions above. *
|
|
From: <jmk...@us...> - 2003-07-23 01:22:52
|
Update of /cvsroot/emc/rtapi/examples/semaphore
In directory sc8-pr-cvs1:/tmp/cvs-serv23441/examples/semaphore
Modified Files:
common.h master.c slave.c
Log Message:
changed examples to use new api - fifo not working yet
Index: common.h
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/semaphore/common.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** common.h 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- common.h 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 2,6 ****
#define COMMON_H
! extern void * master_sem; /* the global semaphore */
#endif /* COMMON_H */
--- 2,6 ----
#define COMMON_H
! extern rtapi_sem_handle master_sem; /* the global semaphore */
#endif /* COMMON_H */
Index: master.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/semaphore/master.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** master.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- master.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 11,16 ****
#include "common.h" /* master_sem decl */
! void *master_sem = 0; /* the global semaphore */
! static void *master_task = 0; /* the task structure */
static unsigned int master_count = 0;
enum { MASTER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
--- 11,16 ----
#include "common.h" /* master_sem decl */
! rtapi_sem_handle master_sem; /* the global semaphore */
! rtapi_task_handle master_task; /* the task structure */
static unsigned int master_count = 0;
enum { MASTER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
***************
*** 18,22 ****
/* task code, executed each timer interrupt */
! void master_code(void)
{
while (1) {
--- 18,22 ----
/* task code, executed each timer interrupt */
! void master_code( int arg )
{
while (1) {
***************
*** 32,50 ****
int rtapi_app_main(void)
{
int master_prio;
if (0 != rtapi_app_init()) {
return -1;
}
/* create the semaphore */
! master_sem = rtapi_sem_new();
! if (0 == master_sem) {
! rtapi_print("mastertask: can't get semaphore\n");
return -1;
}
/* set the base timer period */
! rtapi_clock_set_period(MASTER_PERIOD_NSEC);
/* set the task priority to one above the lowest; the slave
--- 32,57 ----
int rtapi_app_main(void)
{
+ int retval;
int master_prio;
+ /*
if (0 != rtapi_app_init()) {
return -1;
}
+ */
/* create the semaphore */
! retval = rtapi_sem_new( &master_sem );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "sem master init: rtapi_sem_new returned %d\n", retval );
return -1;
}
/* set the base timer period */
! retval = rtapi_clock_set_period(MASTER_PERIOD_NSEC);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "sem master init: rtapi_clock_set_period returned %d\n", retval );
! return -1;
! }
/* set the task priority to one above the lowest; the slave
***************
*** 52,68 ****
master_prio = rtapi_prio_next_higher(rtapi_prio_lowest());
! /* launch the master task */
! master_task = rtapi_task_new();
! if (0 == master_task) {
! rtapi_print("mastertask: can't allocate master task\n");
return -1;
}
! if (0 != rtapi_task_start(master_task, master_code, master_prio, MASTER_STACKSIZE, MASTER_PERIOD_NSEC, 0)) { /* 0 = no floating point */
! rtapi_print("mastertask: can't start master task\n");
return -1;
}
! rtapi_print("mastertask: started master task\n");
return 0;
--- 59,80 ----
master_prio = rtapi_prio_next_higher(rtapi_prio_lowest());
! /* create the master task */
! retval = rtapi_task_new( &master_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "sem master init: rtapi_task_new returned %d\n", retval );
return -1;
}
! /* start the master task */
! retval = rtapi_task_start( master_task, master_code,
! 0, master_prio,
! MASTER_STACKSIZE,
! MASTER_PERIOD_NSEC, RTAPI_NO_FP );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem master init: rtapi_task_start returned %d\n", retval );
return -1;
}
! rtapi_print("sem master init: started master task\n");
return 0;
***************
*** 72,88 ****
void rtapi_app_exit(void)
{
! if (0 != master_task) {
! if (0 != rtapi_task_stop(master_task)) {
! rtapi_print("mastertask: can't stop master task\n");
! }
! if (0 != rtapi_task_delete(master_task)) {
! rtapi_print("mastertask: can't delete master task\n");
! }
! master_task = 0;
}
! rtapi_sem_delete(master_sem);
! rtapi_print("mastertask: master count is %d\n", master_count);
rtapi_app_return();
--- 84,107 ----
void rtapi_app_exit(void)
{
! int retval;
!
! retval = rtapi_task_stop( master_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem master exit: rtapi_task_stop returned %d\n", retval );
! return;
! }
! retval = rtapi_task_delete( master_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem master exit: rtapi_task_delete returned %d\n", retval );
! return;
}
! retval = rtapi_sem_delete( master_sem );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem master exit: rtapi_sem_delete returned %d\n", retval );
! return;
! }
! rtapi_print("sem master exit: master count is %d\n", master_count);
rtapi_app_return();
Index: slave.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/semaphore/slave.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** slave.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- slave.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 11,20 ****
#include "common.h" /* master_sem */
! static void *slave_task = 0; /* the task structure */
static unsigned int slave_count = 0;
enum { SLAVE_STACKSIZE = 1024 }; /* how big the stack is */
/* task code, executed when semaphore is released by master task */
! void slave_code(void)
{
while (1) {
--- 11,20 ----
#include "common.h" /* master_sem */
! static rtapi_task_handle slave_task; /* the task structure */
static unsigned int slave_count = 0;
enum { SLAVE_STACKSIZE = 1024 }; /* how big the stack is */
/* task code, executed when semaphore is released by master task */
! void slave_code( int arg )
{
while (1) {
***************
*** 29,32 ****
--- 29,33 ----
int rtapi_app_main(void)
{
+ int retval;
int slave_prio;
***************
*** 38,55 ****
slave_prio = rtapi_prio_lowest();
! /* launch the slave task */
! slave_task = rtapi_task_new();
! if (0 == slave_task) {
! rtapi_print("slavetask: can't allocate slave task\n");
return -1;
}
! if (0 != rtapi_task_start(slave_task, slave_code, slave_prio, SLAVE_STACKSIZE, 0, /* 0 = don't run task on timer */
! 0)) { /* 0 = no floating point */
! rtapi_print("slavetask: can't start slave task\n");
return -1;
}
! rtapi_print("slavetask: started slave task\n");
return 0;
--- 39,60 ----
slave_prio = rtapi_prio_lowest();
! /* create the slave task */
! retval = rtapi_task_new( &slave_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "sem slave init: rtapi_task_new returned %d\n", retval );
return -1;
}
! /* start the slave task */
! retval = rtapi_task_start( slave_task, slave_code,
! 0, slave_prio,
! SLAVE_STACKSIZE,
! 0 /* not periodic */, RTAPI_NO_FP );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem slave init: rtapi_task_start returned %d\n", retval );
return -1;
}
! rtapi_print("sem slave init: started slave task\n");
return 0;
***************
*** 59,73 ****
void rtapi_app_exit(void)
{
! if (0 != slave_task) {
! if (0 != rtapi_task_stop(slave_task)) {
! rtapi_print("slavetask: can't stop slave task\n");
! }
! if (0 != rtapi_task_delete(slave_task)) {
! rtapi_print("slavetask: can't delete slave task\n");
! }
! slave_task = 0;
}
! rtapi_print("slavetask: slave count is %d\n", slave_count);
rtapi_app_return();
--- 64,81 ----
void rtapi_app_exit(void)
{
! int retval;
!
! retval = rtapi_task_stop( slave_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem slave exit: rtapi_task_stop returned %d\n", retval );
! return;
! }
! retval = rtapi_task_delete( slave_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("sem slave exit: rtapi_task_delete returned %d\n", retval );
! return;
}
! rtapi_print("sem slave exit: slave count is %d\n", slave_count);
rtapi_app_return();
|
|
From: <jmk...@us...> - 2003-07-23 01:22:52
|
Update of /cvsroot/emc/rtapi/examples/timertask
In directory sc8-pr-cvs1:/tmp/cvs-serv23441/examples/timertask
Modified Files:
timertask.c
Log Message:
changed examples to use new api - fifo not working yet
Index: timertask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/timertask/timertask.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** timertask.c 22 Jul 2003 17:20:22 -0000 1.2
--- timertask.c 23 Jul 2003 01:22:49 -0000 1.3
***************
*** 9,19 ****
#include "rtapi_app.h" /* rtapi_app_main,exit() */
! static void *timer_task = 0; /* pointer to the task structure */
static int timer_count = 0; /* the output variable */
enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
enum { TIMER_STACKSIZE = 1024 }; /* how big the stack is */
! /* task code, executed each timer interrupt */
! static void timer_code(int t)
{
while (1) {
--- 9,18 ----
#include "rtapi_app.h" /* rtapi_app_main,exit() */
! static rtapi_task_handle timer_task; /* the task */
static int timer_count = 0; /* the output variable */
enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
enum { TIMER_STACKSIZE = 1024 }; /* how big the stack is */
! static void timer_code( int arg )
{
while (1) {
***************
*** 28,65 ****
int rtapi_app_main(void)
{
int timer_prio;
- int ret_val;
if (0 != rtapi_app_init()) {
return -1;
}
/* set the base timer period */
! rtapi_clock_set_period(TIMER_PERIOD_NSEC);
/* set the task priority to lowest, since we only have one task */
timer_prio = rtapi_prio_lowest();
! /* launch the timer task */
! // timer_task = rtapi_task_new();
! ret_val = rtapi_task_new(&timer_task);
! if (0 != ret_val) {
! rtapi_print("timertask: can't allocate timer task %d\n", ret_val);
! return -1;
! }
!
! if (timer_task == NULL) {
! rtapi_print("timertask: Pointer returned is NULL\n");
return -1;
}
! ret_val = rtapi_task_start(timer_task, timer_code, 0, timer_prio, TIMER_STACKSIZE, TIMER_PERIOD_NSEC, 0);
!
! if (0 != ret_val ) {
! rtapi_print("timertask: can't start timer task %d\n", ret_val);
return -1;
}
! rtapi_print("timertask: started timer task\n");
return 0;
--- 27,66 ----
int rtapi_app_main(void)
{
+ int retval;
int timer_prio;
+ /* init is still in a state of change - right now this isn't needed
if (0 != rtapi_app_init()) {
return -1;
}
+ */
/* set the base timer period */
! retval = rtapi_clock_set_period(TIMER_PERIOD_NSEC);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "timertask init: rtapi_clock_set_period returned %d\n", retval );
! return -1;
! }
/* set the task priority to lowest, since we only have one task */
timer_prio = rtapi_prio_lowest();
! /* create the timer task */
! retval = rtapi_task_new( &timer_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "timertask init: rtapi_task_new returned %d\n", retval );
return -1;
}
! retval = rtapi_task_start( timer_task, timer_code,
! 0, timer_prio,
! TIMER_STACKSIZE,
! TIMER_PERIOD_NSEC, RTAPI_NO_FP );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("timertask init: rtapi_task_start returned %d\n", retval );
return -1;
}
! rtapi_print( "timertask init: started timer task\n" );
return 0;
***************
*** 69,83 ****
void rtapi_app_exit(void)
{
! if (0 != timer_task) {
! if (0 != rtapi_task_stop(timer_task)) {
! rtapi_print("timertask: can't stop timer task\n");
! }
! if (0 != rtapi_task_delete(timer_task)) {
! rtapi_print("timertask: can't delete timer task\n");
! }
! timer_task = 0;
}
! rtapi_print("timertask: timer count is %d\n", timer_count);
rtapi_app_return();
--- 70,87 ----
void rtapi_app_exit(void)
{
! int retval;
!
! retval = rtapi_task_stop(timer_task);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("timertask exit: rtapi_task_stop returned %d\n", retval );
! return;
! }
! retval = rtapi_task_delete( timer_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("timertask exit: rtapi_task_delete returned %d\n", retval );
! return;
}
! rtapi_print("timertask exit: timer count is %d\n", timer_count);
rtapi_app_return();
|
Update of /cvsroot/emc/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv23441 Modified Files: Makefile.inc configure rtai-1.3.mk rtai-1.7.mk rtai.mk rtlinux-2.2.mk rtlinux-3.0.mk rtlinux.mk Log Message: changed examples to use new api - fifo not working yet Index: Makefile.inc =================================================================== RCS file: /cvsroot/emc/rtapi/Makefile.inc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.inc 19 Jul 2003 07:17:22 -0000 1.4 --- Makefile.inc 23 Jul 2003 01:22:49 -0000 1.5 *************** *** 10,14 **** MOD_DIR = /lib/modules/2.4.18-rtai/misc CC = gcc ! CFLAGS = -g -I$(INC_DIR) -Wall CLINK = RTDIR = /usr/src/rtai-24.1.10 --- 10,14 ---- MOD_DIR = /lib/modules/2.4.18-rtai/misc CC = gcc ! CFLAGS = -g -Wall -I$(INC_DIR) CLINK = RTDIR = /usr/src/rtai-24.1.10 *************** *** 18,23 **** # Makefile add-ons from rtai.mk ! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o --- 18,23 ---- # Makefile add-ons from rtai.mk ! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o Index: configure =================================================================== RCS file: /cvsroot/emc/rtapi/configure,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** configure 22 Jul 2003 17:20:21 -0000 1.3 --- configure 23 Jul 2003 01:22:49 -0000 1.4 *************** *** 29,33 **** echo CC = gcc >> Makefile.inc ! echo CFLAGS = -g -I\$\(INC_DIR\) >> Makefile.inc echo CLINK = >> Makefile.inc --- 29,33 ---- echo CC = gcc >> Makefile.inc ! echo CFLAGS = -g -Wall -I\$\(INC_DIR\) >> Makefile.inc echo CLINK = >> Makefile.inc Index: rtai-1.3.mk =================================================================== RCS file: /cvsroot/emc/rtapi/rtai-1.3.mk,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** rtai-1.3.mk 8 Jul 2003 15:54:38 -0000 1.1.1.1 --- rtai-1.3.mk 23 Jul 2003 01:22:49 -0000 1.2 *************** *** 2,7 **** # Makefile add-ons from rtai-1.3.mk ! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o --- 2,7 ---- # Makefile add-ons from rtai-1.3.mk ! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o Index: rtai-1.7.mk =================================================================== RCS file: /cvsroot/emc/rtapi/rtai-1.7.mk,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** rtai-1.7.mk 8 Jul 2003 15:54:38 -0000 1.1.1.1 --- rtai-1.7.mk 23 Jul 2003 01:22:49 -0000 1.2 *************** *** 2,7 **** # Makefile add-ons from rtai-1.7.mk ! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o --- 2,7 ---- # Makefile add-ons from rtai-1.7.mk ! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o Index: rtai.mk =================================================================== RCS file: /cvsroot/emc/rtapi/rtai.mk,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rtai.mk 22 Jul 2003 17:20:21 -0000 1.2 --- rtai.mk 23 Jul 2003 01:22:49 -0000 1.3 *************** *** 2,7 **** # Makefile add-ons from rtai.mk ! RTFLAGS = $(KERNEL_INC) -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o --- 2,7 ---- # Makefile add-ons from rtai.mk ! RTFLAGS = -Wall $(KERNEL_INC) -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtai_rtapi.o Index: rtlinux-2.2.mk =================================================================== RCS file: /cvsroot/emc/rtapi/rtlinux-2.2.mk,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** rtlinux-2.2.mk 8 Jul 2003 15:54:38 -0000 1.1.1.1 --- rtlinux-2.2.mk 23 Jul 2003 01:22:49 -0000 1.2 *************** *** 2,7 **** # Makefile add-ons from rtlinux-2.2.mk ! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -I$(RTDIR)/linux/include -I$(RTDIR)/include/posix -I$(RTDIR)/include/compat -O2 -ffast-math -D__RTL__ -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtl_rtapi.o --- 2,7 ---- # Makefile add-ons from rtlinux-2.2.mk ! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -I$(RTDIR)/linux/include -I$(RTDIR)/include/posix -I$(RTDIR)/include/compat -O2 -ffast-math -D__RTL__ -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtl_rtapi.o Index: rtlinux-3.0.mk =================================================================== RCS file: /cvsroot/emc/rtapi/rtlinux-3.0.mk,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** rtlinux-3.0.mk 8 Jul 2003 15:54:38 -0000 1.1.1.1 --- rtlinux-3.0.mk 23 Jul 2003 01:22:49 -0000 1.2 *************** *** 2,7 **** # Makefile add-ons from rtlinux-3.0.mk ! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -I$(RTDIR)/linux/include -I$(RTDIR)/include/posix -I$(RTDIR)/include/compat -O2 -ffast-math -D__RTL__ -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/linux/include -I$(RTDIR)/include -I$(RTDIR)/include/compat RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtl_rtapi.o --- 2,7 ---- # Makefile add-ons from rtlinux-3.0.mk ! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -I$(RTDIR)/linux/include -I$(RTDIR)/include/posix -I$(RTDIR)/include/compat -O2 -ffast-math -D__RTL__ -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/linux/include -I$(RTDIR)/include -I$(RTDIR)/include/compat RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtl_rtapi.o Index: rtlinux.mk =================================================================== RCS file: /cvsroot/emc/rtapi/rtlinux.mk,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** rtlinux.mk 8 Jul 2003 15:54:38 -0000 1.1.1.1 --- rtlinux.mk 23 Jul 2003 01:22:49 -0000 1.2 *************** *** 2,7 **** # Makefile add-ons from rtlinux.mk ! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -I$(RTDIR)/linux/include -I$(RTDIR)/include/posix -I$(RTDIR)/include/compat -O2 -ffast-math -D__RTL__ -D__KERNEL__ -DMODULE ! ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtl_rtapi.o --- 2,7 ---- # Makefile add-ons from rtlinux.mk ! RTFLAGS = -Wall -I$(INC_DIR) -I$(RTDIR)/include -I$(RTDIR)/linux/include -I$(RTDIR)/include/posix -I$(RTDIR)/include/compat -O2 -ffast-math -D__RTL__ -D__KERNEL__ -DMODULE ! ULFLAGS = -Wall -g -I$(INC_DIR) -I$(RTDIR)/include RTLINK = ld -r -static RTAPI = $(RTLIB_DIR)/rtl_rtapi.o |
|
From: <jmk...@us...> - 2003-07-23 01:22:52
|
Update of /cvsroot/emc/rtapi/examples/fifo
In directory sc8-pr-cvs1:/tmp/cvs-serv23441/examples/fifo
Modified Files:
fifotask.c fifousr.c
Log Message:
changed examples to use new api - fifo not working yet
Index: fifotask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/fifo/fifotask.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** fifotask.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- fifotask.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 9,27 ****
#include "common.h" /* FIFO_KEY */
! static void *fifo_task = 0; /* the task structure */
enum { FIFO_PERIOD_NSEC = 10000000 }; /* timer period, in nanoseconds */
enum { FIFO_STACKSIZE = 1024 }; /* how big the stack is */
! static int fifo_fd = -1;
! static int count = 0;
/* task code, executed each timer interrupt */
! void fifo_code(void)
{
char buffer[FIFO_SIZE + 1] = { '\n' };
while (1) {
! rtapi_fifo_write(fifo_fd, buffer, FIFO_SIZE);
count++;
rtapi_wait();
}
--- 9,33 ----
#include "common.h" /* FIFO_KEY */
! static rtapi_task_handle fifo_task = 0; /* the task structure */
! static rtapi_fifo_handle fifo;
enum { FIFO_PERIOD_NSEC = 10000000 }; /* timer period, in nanoseconds */
enum { FIFO_STACKSIZE = 1024 }; /* how big the stack is */
! static int count = 1;
/* task code, executed each timer interrupt */
! void fifo_code( int arg )
{
+ int n;
char buffer[FIFO_SIZE + 1] = { '\n' };
while (1) {
! for ( n = 0 ; n < count ; n++ ) {
! buffer[n] = '0' + count;
! }
! rtapi_fifo_write ( fifo, buffer, count );
count++;
+ if ( count > 9 )
+ count = 1;
rtapi_wait();
}
***************
*** 33,54 ****
int rtapi_app_main(void)
{
int fifo_prio;
- int t;
if (0 != rtapi_init()) {
return -1;
}
/* allocate and initialize the fifo */
! rtapi_fifo_new(FIFO_KEY, &fifo_fd, FIFO_SIZE);
! if (fifo_fd < 0) {
! rtapi_print("fifotask: can't create fifo\n");
return -1;
- } else {
- rtapi_print("fifotask: created fifo %d\n", fifo_fd);
}
/* set the base timer period */
! rtapi_clock_set_period(FIFO_PERIOD_NSEC);
/* set the task priority to lowest, since we only have one task */
--- 39,65 ----
int rtapi_app_main(void)
{
+ int retval;
int fifo_prio;
+ /*
if (0 != rtapi_init()) {
return -1;
}
+ */
/* allocate and initialize the fifo */
! retval = rtapi_fifo_new( FIFO_KEY, FIFO_SIZE, &fifo );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "fifotask init: rtapi_fifo_new returned %d\n", retval );
return -1;
}
+ rtapi_print("fifotask init: created fifo\n" );
/* set the base timer period */
! retval = rtapi_clock_set_period(FIFO_PERIOD_NSEC);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "fifotask init: rtapi_clock_set_period returned %d\n", retval );
! return -1;
! }
/* set the task priority to lowest, since we only have one task */
***************
*** 56,69 ****
/* launch the fifo task */
! fifo_task = rtapi_task_new();
! if (0 == fifo_task) {
! rtapi_print("fifotask: can't allocate fifo task\n");
return -1;
}
! if (0 !=
! rtapi_task_start(fifo_task, fifo_code, fifo_prio, FIFO_STACKSIZE,
! FIFO_PERIOD_NSEC, 0)) {
! rtapi_print("fifotask: can't start fifo task\n");
return -1;
}
--- 67,83 ----
/* launch the fifo task */
! retval = rtapi_task_new( &fifo_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print( "fifotask init: rtapi_task_new returned %d\n", retval );
return -1;
}
! /* start the fifo task */
! retval = rtapi_task_start( fifo_task, fifo_code,
! 0, fifo_prio,
! FIFO_STACKSIZE,
! FIFO_PERIOD_NSEC, RTAPI_NO_FP );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask init: rtapi_task_start returned %d\n", retval );
return -1;
}
***************
*** 77,98 ****
void rtapi_app_exit(void)
{
! if (0 != fifo_task) {
! if (0 != rtapi_task_stop(fifo_task)) {
! rtapi_print("fifotask: can't stop fifo task\n");
! }
! if (0 != rtapi_task_delete(fifo_task)) {
! rtapi_print("fifotask: can't delete fifo task\n");
! }
! fifo_task = 0;
}
! if (fifo_fd < 0) {
! if (0 != rtapi_fifo_delete(FIFO_KEY, fifo_fd, FIFO_SIZE)) {
! rtapi_print("fifotask: can't free fifo\n");
! }
! fifo_fd = -1;
}
! rtapi_print("fifotask: %d writes\n", count);
rtapi_app_return();
--- 91,114 ----
void rtapi_app_exit(void)
{
! int retval;
!
! retval = rtapi_task_stop( fifo_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask exit: rtapi_task_stop returned %d\n", retval );
! return;
! }
! retval = rtapi_task_delete( fifo_task );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask exit: rtapi_task_delete returned %d\n", retval );
! return;
}
! retval = rtapi_fifo_delete( fifo );
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("fifotask exit: rtapi_fifo_delete returned %d\n", retval );
! return;
}
! rtapi_print("fifotask exit: %d writes\n", count);
rtapi_app_return();
Index: fifousr.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/fifo/fifousr.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** fifousr.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- fifousr.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 19,38 ****
int main()
{
! fd_set rfds;
! struct timeval tv;
! int fifo_fd;
char buffer[FIFO_SIZE + 1];
int nchars;
! int count;
! if (0 != ulapi_init()) {
! fprintf(stderr, "can't initialize ulapi\n");
! return 1;
}
! ulapi_fifo_new(FIFO_KEY, &fifo_fd, FIFO_SIZE);
! if (fifo_fd < 0) {
! fprintf(stderr, "can't open fifo\n");
! return 1;
}
--- 19,38 ----
int main()
{
! ulapi_fifo_handle fifo;
char buffer[FIFO_SIZE + 1];
int nchars;
! int retval;
! retval = ulapi_init();
! if ( retval != ULAPI_SUCCESS ) {
! printf("fifousr main: ulapi_init returned %d\n", retval );
! return -1;
}
! /* open the fifo */
! retval = ulapi_fifo_new( FIFO_KEY, FIFO_SIZE, 'R', &fifo );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "fifousr main: ulapi_fifo_new returned %d\n", retval );
! return -1;
}
***************
*** 41,59 ****
signal(SIGINT, quit);
- count = 0;
- tv.tv_sec = 1;
- tv.tv_usec = 0;
while (1) {
! FD_ZERO(&rfds);
! FD_SET(fifo_fd, &rfds);
! if (select(FD_SETSIZE, &rfds, NULL, NULL, &tv) > 0) {
! if (FD_ISSET(fifo_fd, &rfds)) {
! nchars = ulapi_fifo_read(fifo_fd, buffer, FIFO_SIZE);
! count++;
! printf("got %d chars\n", nchars);
! }
! } else {
! printf("timed out\n");
! break;
}
}
--- 41,52 ----
signal(SIGINT, quit);
while (1) {
! nchars = ulapi_fifo_read( fifo, buffer, FIFO_SIZE );
! if ( retval < 0 ) {
! printf ( "fifousr main: ulapi_fifo_read returned %d\n", nchars );
! }
! else {
! buffer[nchars] = '\0';
! printf("fifousr main: read %d chars: '%s'\n", nchars, buffer);
}
}
***************
*** 61,67 ****
END:
! printf("%d total reads\n", count);
! ulapi_fifo_delete(FIFO_KEY, fifo_fd, FIFO_SIZE);
return ulapi_exit();
--- 54,64 ----
END:
! printf( "shutting down\n" );
! retval = ulapi_fifo_delete( fifo );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "fifousr main: ulapi_fifo_delete returned %d\n", retval );
! return -1;
! }
return ulapi_exit();
|
|
From: <jmk...@us...> - 2003-07-23 01:22:52
|
Update of /cvsroot/emc/rtapi/examples/extint
In directory sc8-pr-cvs1:/tmp/cvs-serv23441/examples/extint
Modified Files:
extint.c
Log Message:
changed examples to use new api - fifo not working yet
Index: extint.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/extint/extint.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** extint.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- extint.c 23 Jul 2003 01:22:49 -0000 1.2
***************
*** 25,36 ****
int rtapi_app_main(void)
{
if (0 != rtapi_app_init()) {
return -1;
! }
/* set up ISR */
! rtapi_free_interrupt_handler(PARPORT_IRQ);
! rtapi_assign_interrupt_handler(PARPORT_IRQ, parport_irq_handler);
! rtapi_enable_interrupt(PARPORT_IRQ);
/* enable parallel port hardware interrupts */
--- 25,51 ----
int rtapi_app_main(void)
{
+ int retval;
+
+ /*
if (0 != rtapi_app_init()) {
return -1;
! }*/
/* set up ISR */
! retval = rtapi_free_interrupt_handler(PARPORT_IRQ);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("extint init: rtapi_free_interrupt returned %d\n", retval );
! /*return -1;*/
! }
! retval = rtapi_assign_interrupt_handler(PARPORT_IRQ, parport_irq_handler);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("extint init: rtapi_assign_interrupt_handler returned %d\n", retval );
! return -1;
! }
! retval = rtapi_enable_interrupt(PARPORT_IRQ);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("extint init: rtapi_enable_interrupt returned %d\n", retval );
! return -1;
! }
/* enable parallel port hardware interrupts */
***************
*** 41,46 ****
--- 56,64 ----
}
+
void rtapi_app_exit(void)
{
+ int retval;
+
/* disable parallel port hardware interrupts */
rtapi_outb(rtapi_inb(PARPORT_BASE_ADDRESS + 2) & (~0x10),
***************
*** 48,56 ****
/* clear ISR */
! rtapi_disable_interrupt(PARPORT_IRQ);
! rtapi_free_interrupt_handler(PARPORT_IRQ);
! rtapi_print("extint: interrupt count is %d\n", timer_count);
! rtapi_app_return();
}
--- 66,82 ----
/* clear ISR */
! retval = rtapi_disable_interrupt(PARPORT_IRQ);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("extint exit: rtapi_disable_interrupt returned %d\n", retval );
! return;
! }
! retval = rtapi_free_interrupt_handler(PARPORT_IRQ);
! if ( retval != RTAPI_SUCCESS ) {
! rtapi_print("extint exit: rtapi_disable_interrupt returned %d\n", retval );
! return;
! }
! rtapi_print("extint exit: interrupt count is %d\n", timer_count);
! /* rtapi_app_return(); */
}
|
|
From: <pa...@us...> - 2003-07-22 17:20:35
|
Update of /cvsroot/emc/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv32109
Modified Files:
configure install_realtime_base rtai.mk
Log Message:
A few small changes to enable the timetask example to work with 2.4.21-adeos
Index: configure
===================================================================
RCS file: /cvsroot/emc/rtapi/configure,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** configure 19 Jul 2003 01:32:47 -0000 1.2
--- configure 22 Jul 2003 17:20:21 -0000 1.3
***************
*** 22,25 ****
--- 22,31 ----
echo MOD_DIR = /lib/modules/$version/misc >> Makefile.inc
+ if [ -d /lib/modules/$version/build ] ; then
+ # We have a 2.4 or later kernel if this symlink exists,
+ # so add an include to the correct headers for the kernel running.
+ echo KERNEL_INC = -I/lib/modules/$version/build/include >> Makefile.inc
+ fi
+
echo CC = gcc >> Makefile.inc
echo CFLAGS = -g -I\$\(INC_DIR\) >> Makefile.inc
***************
*** 88,92 ****
# ditto for an RTAI boot by looking through the kernel for telltale symbols:
# set_rtai_callback, remove_rtai_callback for 2.2, 2.4 kernels
! RTAIBOOT=$(/sbin/ksyms -a | grep _rtai_ | wc -l)
if [ $RTAIBOOT -gt 0 ] ; then
echo found RTAI installed in the kernel
--- 94,98 ----
# ditto for an RTAI boot by looking through the kernel for telltale symbols:
# set_rtai_callback, remove_rtai_callback for 2.2, 2.4 kernels
! RTAIBOOT=$(/sbin/ksyms -a | grep -E '(_rtai_|_adeos_)' | wc -l)
if [ $RTAIBOOT -gt 0 ] ; then
echo found RTAI installed in the kernel
Index: install_realtime_base
===================================================================
RCS file: /cvsroot/emc/rtapi/install_realtime_base,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** install_realtime_base 8 Jul 2003 15:54:38 -0000 1.1.1.1
--- install_realtime_base 22 Jul 2003 17:20:21 -0000 1.2
***************
*** 22,28 ****
! # If the symbol rthal is found in ksyms assume we are using
# rtai instead of rtlinux.
! if /sbin/ksyms -a | grep rthal >${nullfile} 2>${nullfile} ; then
# Check to see if the rtai module is already installed..
--- 22,28 ----
! # If the symbol rthal or adeos is found in ksyms assume we are using
# rtai instead of rtlinux.
! if /sbin/ksyms -a | grep -E '(rthal|adeos)' >${nullfile} 2>${nullfile} ; then
# Check to see if the rtai module is already installed..
Index: rtai.mk
===================================================================
RCS file: /cvsroot/emc/rtapi/rtai.mk,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rtai.mk 8 Jul 2003 15:54:38 -0000 1.1.1.1
--- rtai.mk 22 Jul 2003 17:20:21 -0000 1.2
***************
*** 2,6 ****
# Makefile add-ons from rtai.mk
! RTFLAGS = -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE
ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include
RTLINK = ld -r -static
--- 2,6 ----
# Makefile add-ons from rtai.mk
! RTFLAGS = $(KERNEL_INC) -I$(INC_DIR) -I$(RTDIR)/include -O2 -ffast-math -D__KERNEL__ -DMODULE
ULFLAGS = -g -I$(INC_DIR) -I$(RTDIR)/include
RTLINK = ld -r -static
|
|
From: <pa...@us...> - 2003-07-22 17:20:25
|
Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv32109/src/rtapi
Modified Files:
localdefs.h rtai_rtapi.c rtapi.h sim_rtapi.c
Log Message:
A few small changes to enable the timetask example to work with 2.4.21-adeos
Index: localdefs.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/localdefs.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** localdefs.h 19 Jul 2003 07:17:22 -0000 1.4
--- localdefs.h 22 Jul 2003 17:20:22 -0000 1.5
***************
*** 2,8 ****
#define LOCALDEFS_H
! /* automatically generated by config script on Fri Jul 18 22:40:51 EDT 2003 */
! #define LOCAL_MHZ 233.866
#endif
--- 2,8 ----
#define LOCALDEFS_H
! /* automatically generated by config script on Tue Jul 22 13:03:40 UTC 2003 */
! #define LOCAL_MHZ 807.966
#endif
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rtai_rtapi.c 19 Jul 2003 07:17:22 -0000 1.4
--- rtai_rtapi.c 22 Jul 2003 17:20:22 -0000 1.5
***************
*** 134,138 ****
/* validate taskptr */
! if ( taskptr == NULL )
return RTAPI_INVAL;
--- 134,138 ----
/* validate taskptr */
! if ( &taskptr == NULL )
return RTAPI_INVAL;
***************
*** 146,150 ****
/* and return handle to the caller */
! *taskptr = task;
return RTAPI_SUCCESS;
--- 146,150 ----
/* and return handle to the caller */
! taskptr = task;
return RTAPI_SUCCESS;
***************
*** 406,410 ****
vsprintf(buffer, fmt, args);
rt_printk(buffer);
! va_end(ap);
}
--- 406,410 ----
vsprintf(buffer, fmt, args);
rt_printk(buffer);
! va_end(args);
}
Index: rtapi.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rtapi.h 19 Jul 2003 07:17:22 -0000 1.5
--- rtapi.h 22 Jul 2003 17:20:22 -0000 1.6
***************
*** 95,100 ****
* rtapi_task_new(). 'taskcode' is the name of a function taking one *
* int and returning void, which contains the task code. 'arg' will be *
! * passed to 'taskcode' when the task is invoked. 'prio' is the *
! * priority, as determined by one of the priority functions above. *
* 'stacksize' is the amount of stack to be reserved for the task - be *
* generous, hardware interrupts may use the same stack. 'period_nsec' *
--- 95,101 ----
* rtapi_task_new(). 'taskcode' is the name of a function taking one *
* int and returning void, which contains the task code. 'arg' will be *
! * passed to 'taskcode' as an abitrary int value when the task is *
! * invoked. 'prio' is the priority, as determined by one of the *
! * priority functions above. *
* 'stacksize' is the amount of stack to be reserved for the task - be *
* generous, hardware interrupts may use the same stack. 'period_nsec' *
Index: sim_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/sim_rtapi.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** sim_rtapi.c 19 Jul 2003 07:17:22 -0000 1.3
--- sim_rtapi.c 22 Jul 2003 17:20:22 -0000 1.4
***************
*** 397,401 ****
va_start(args, fmt);
vprintf(fmt, args);
! va_end(ap);
}
--- 397,401 ----
va_start(args, fmt);
vprintf(fmt, args);
! va_end(args);
}
|
|
From: <pa...@us...> - 2003-07-22 17:20:25
|
Update of /cvsroot/emc/rtapi/examples/timertask
In directory sc8-pr-cvs1:/tmp/cvs-serv32109/examples/timertask
Modified Files:
timertask.c
Log Message:
A few small changes to enable the timetask example to work with 2.4.21-adeos
Index: timertask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/timertask/timertask.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** timertask.c 8 Jul 2003 15:54:39 -0000 1.1.1.1
--- timertask.c 22 Jul 2003 17:20:22 -0000 1.2
***************
*** 9,13 ****
#include "rtapi_app.h" /* rtapi_app_main,exit() */
! static void *timer_task = 0; /* the task structure */
static int timer_count = 0; /* the output variable */
enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
--- 9,13 ----
#include "rtapi_app.h" /* rtapi_app_main,exit() */
! static void *timer_task = 0; /* pointer to the task structure */
static int timer_count = 0; /* the output variable */
enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
***************
*** 15,19 ****
/* task code, executed each timer interrupt */
! void timer_code(void)
{
while (1) {
--- 15,19 ----
/* task code, executed each timer interrupt */
! static void timer_code(int t)
{
while (1) {
***************
*** 29,32 ****
--- 29,33 ----
{
int timer_prio;
+ int ret_val;
if (0 != rtapi_app_init()) {
***************
*** 41,52 ****
/* launch the timer task */
! timer_task = rtapi_task_new();
! if (0 == timer_task) {
! rtapi_print("timertask: can't allocate timer task\n");
return -1;
}
! if (0 != rtapi_task_start(timer_task, timer_code, timer_prio, TIMER_STACKSIZE, TIMER_PERIOD_NSEC, 0)) { /* 0 = no floating point */
! rtapi_print("timertask: can't start timer task\n");
return -1;
}
--- 42,61 ----
/* launch the timer task */
! // timer_task = rtapi_task_new();
! ret_val = rtapi_task_new(&timer_task);
! if (0 != ret_val) {
! rtapi_print("timertask: can't allocate timer task %d\n", ret_val);
return -1;
}
! if (timer_task == NULL) {
! rtapi_print("timertask: Pointer returned is NULL\n");
! return -1;
! }
!
! ret_val = rtapi_task_start(timer_task, timer_code, 0, timer_prio, TIMER_STACKSIZE, TIMER_PERIOD_NSEC, 0);
!
! if (0 != ret_val ) {
! rtapi_print("timertask: can't start timer task %d\n", ret_val);
return -1;
}
|
|
From: <pa...@us...> - 2003-07-21 20:25:22
|
Update of /cvsroot/emc/emc In directory sc8-pr-cvs1:/tmp/cvs-serv28668 Modified Files: sim.var Log Message: Set param 5220 to 1.000 Index: sim.var =================================================================== RCS file: /cvsroot/emc/emc/sim.var,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sim.var 29 Jun 2003 02:33:12 -0000 1.11 --- sim.var 21 Jul 2003 20:25:19 -0000 1.12 *************** *** 17,21 **** 5215 0.000000 5216 0.000000 ! 5220 0.000000 5221 0.000000 5222 0.000000 --- 17,21 ---- 5215 0.000000 5216 0.000000 ! 5220 1.000000 5221 0.000000 5222 0.000000 |