Update of /cvsroot/pure-data/externals/iem/pdoctave In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9797
Modified Files: pdoctave_command.c pdoctave_dataframe.c pdoctave_dataframe.h pdoctave_get.c write_shared_mem.cc Log Message: pdoctave weekend, yeah! So obviously, total nerdness has struck me already. IAOUOIASSFAIUOOOOOOAA!!!
But it works!!! - Octave error handling for errors of write_shared_mem.cc (i.e. undefined variables). - Return value for non existent data packages corrected in write_shared_mem.cc (it has to be removeSharedData instead of freeSharedData in exceptional cases) - opening octave on library startup - removed annoying post messages yesyesyes, perhaps it's time for Georgies threadlib "detach" for pdoctave_get now!
Index: pdoctave_dataframe.h =================================================================== RCS file: /cvsroot/pure-data/externals/iem/pdoctave/pdoctave_dataframe.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdoctave_dataframe.h 25 Mar 2006 13:14:59 -0000 1.2 --- pdoctave_dataframe.h 26 Mar 2006 21:34:29 -0000 1.3 *************** *** 16,20 ****
#define STD_USLEEP_TIME 100 ! #define MAX_SLEEP_TIME 2
typedef struct _SharedDataFrame_ SharedDataFrame; --- 16,20 ----
#define STD_USLEEP_TIME 100 ! #define MAX_USLEEP_TIME 5000000
typedef struct _SharedDataFrame_ SharedDataFrame;
Index: pdoctave_command.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/pdoctave/pdoctave_command.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdoctave_command.c 25 Mar 2006 10:53:12 -0000 1.2 --- pdoctave_command.c 26 Mar 2006 21:34:29 -0000 1.3 *************** *** 59,63 **** static void pDOctaveCommandBang (PDOctaveCommand *pdoctcmd_obj) { ! post("command: %s sent", pdoctcmd_obj->oct_command); writeToOctaveStdIN (pdoctcmd_obj->oct_command); } --- 59,63 ---- static void pDOctaveCommandBang (PDOctaveCommand *pdoctcmd_obj) { ! //post("command: %s sent", pdoctcmd_obj->oct_command); writeToOctaveStdIN (pdoctcmd_obj->oct_command); } *************** *** 83,87 **** pd_new (pdoctave_command_class);
! post("getpdoctaveinstances returned %d", getPDOctaveInstances()); if (getPDOctaveInstances()<1) { error("Octave not running, insert a 'pdoctave' object!!"); --- 83,87 ---- pd_new (pdoctave_command_class);
! // post("getpdoctaveinstances returned %d", getPDOctaveInstances()); if (getPDOctaveInstances()<1) { error("Octave not running, insert a 'pdoctave' object!!");
Index: pdoctave_get.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/pdoctave/pdoctave_get.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pdoctave_get.c 26 Mar 2006 12:47:03 -0000 1.4 --- pdoctave_get.c 26 Mar 2006 21:34:29 -0000 1.5 *************** *** 27,31 **** t_symbol *name;
! post("getpdoctaveinstances returned %d", getPDOctaveInstances()); if (getPDOctaveInstances()<1) { error("Octave not running, insert a 'pdoctave' object!!"); --- 27,31 ---- t_symbol *name;
! // post("getpdoctaveinstances returned %d", getPDOctaveInstances()); if (getPDOctaveInstances()<1) { error("Octave not running, insert a 'pdoctave' object!!"); *************** *** 65,69 **** cmd +=strlen(cmd); strcpy (cmd,");\n end\n\0"); ! post("pdoctave_get: %s",pdoctget_obj->oct_command);
writeToOctaveStdIN (pdoctget_obj->oct_command); --- 65,69 ---- cmd +=strlen(cmd); strcpy (cmd,");\n end\n\0"); ! //post("pdoctave_get: %s",pdoctget_obj->oct_command);
writeToOctaveStdIN (pdoctget_obj->oct_command); *************** *** 141,144 **** --- 141,145 ---- case UNKNOWN: post("pdoctave_get: unknown return value"); + s = gensym(""); return; } *************** *** 162,172 **** blockForWriting (sdf); pDOctaveGetCommand (pdoctget_obj); if((sleepUntilWriteUnBlocked (sdf))==0) { error("pdoctave_get: pd and octave scheduling error, restart pd!"); return; }
! // waiting for results ! pdoctget_obj->data = getSharedData (sdf);
// converting incoming data --- 163,178 ---- blockForWriting (sdf); pDOctaveGetCommand (pdoctget_obj); + // waiting for results if((sleepUntilWriteUnBlocked (sdf))==0) { error("pdoctave_get: pd and octave scheduling error, restart pd!"); + unBlockForReading (sdf); return; }
! if ((pdoctget_obj->data = getSharedData (sdf))==0) { ! error("pdoctave_get: empty data package received"); ! unBlockForReading (sdf); ! return; ! }
// converting incoming data
Index: pdoctave_dataframe.c =================================================================== RCS file: /cvsroot/pure-data/externals/iem/pdoctave/pdoctave_dataframe.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdoctave_dataframe.c 26 Mar 2006 12:47:03 -0000 1.3 --- pdoctave_dataframe.c 26 Mar 2006 21:34:29 -0000 1.4 *************** *** 1,4 **** #include "pdoctave_dataframe.h" ! static int scheduling_ok = 1;
SharedDataFrame *newSharedDataFrame () --- 1,4 ---- #include "pdoctave_dataframe.h" ! //static int scheduling_ok = 1;
SharedDataFrame *newSharedDataFrame () *************** *** 208,238 **** int sleepUntilReadUnBlocked (SharedDataFrame *sdf) { ! //alarm(MAX_SLEEP_TIME); ! while ((sdf->block_for_read!=0)&&scheduling_ok) ! sched_yield(); ! return scheduling_ok; }
int sleepUntilReadBlocked (SharedDataFrame *sdf) { ! //alarm(MAX_SLEEP_TIME); ! while ((sdf->block_for_read==0)&&scheduling_ok) ! sched_yield(); ! return scheduling_ok; }
int sleepUntilWriteUnBlocked (SharedDataFrame *sdf) { ! //alarm(MAX_SLEEP_TIME); ! while ((sdf->block_for_write!=0)&&scheduling_ok) ! sched_yield(); ! return scheduling_ok; } int sleepUntilWriteBlocked (SharedDataFrame *sdf) { ! //alarm(MAX_SLEEP_TIME); ! while ((sdf->block_for_write==0)&&scheduling_ok) ! sched_yield(); ! return scheduling_ok; } /* --- 208,246 ---- int sleepUntilReadUnBlocked (SharedDataFrame *sdf) { ! int elapsed_time=0; ! while ((sdf->block_for_read!=0)&&(elapsed_time<MAX_USLEEP_TIME)) { ! elapsed_time += STD_USLEEP_TIME; ! usleep(STD_USLEEP_TIME); ! } ! return (elapsed_time<MAX_USLEEP_TIME); }
int sleepUntilReadBlocked (SharedDataFrame *sdf) { ! int elapsed_time=0; ! while ((sdf->block_for_read==0)&&(elapsed_time<MAX_USLEEP_TIME)) { ! elapsed_time += STD_USLEEP_TIME; ! usleep(STD_USLEEP_TIME); ! } ! return (elapsed_time<MAX_USLEEP_TIME); }
int sleepUntilWriteUnBlocked (SharedDataFrame *sdf) { ! int elapsed_time=0; ! while ((sdf->block_for_write!=0)&&(elapsed_time<MAX_USLEEP_TIME)) { ! elapsed_time += STD_USLEEP_TIME; ! usleep(STD_USLEEP_TIME); ! } ! return (elapsed_time<MAX_USLEEP_TIME); } int sleepUntilWriteBlocked (SharedDataFrame *sdf) { ! int elapsed_time=0; ! while ((sdf->block_for_write==0)&&(elapsed_time<MAX_USLEEP_TIME)) { ! elapsed_time += STD_USLEEP_TIME; ! usleep(STD_USLEEP_TIME); ! } ! return (elapsed_time<MAX_USLEEP_TIME); } /* *************** *** 241,245 **** int timer = 0; if (sdf) { ! while ((sdf->block_for_read!=0)&&(timer < MAX_SLEEP_TIME)) { timer += usleep_time; usleep (usleep_time); --- 249,253 ---- int timer = 0; if (sdf) { ! while ((sdf->block_for_read!=0)&&(timer < MAX_USLEEP_TIME)) { timer += usleep_time; usleep (usleep_time); *************** *** 251,255 **** int timer = 0; if (sdf) { ! while ((sdf->block_for_read==0)&&(timer < MAX_SLEEP_TIME)) { timer +=usleep_time; usleep (usleep_time); --- 259,263 ---- int timer = 0; if (sdf) { ! while ((sdf->block_for_read==0)&&(timer < MAX_USLEEP_TIME)) { timer +=usleep_time; usleep (usleep_time); *************** *** 262,266 **** int timer = 0; if (sdf) { ! while ((sdf->block_for_write!=0)&&(timer < MAX_SLEEP_TIME)) { timer +=usleep_time; usleep (usleep_time); --- 270,274 ---- int timer = 0; if (sdf) { ! while ((sdf->block_for_write!=0)&&(timer < MAX_USLEEP_TIME)) { timer +=usleep_time; usleep (usleep_time); *************** *** 273,277 **** int timer = 0; if (sdf) { ! while ((sdf->block_for_write==0)&&(timer < MAX_SLEEP_TIME)) { timer +=usleep_time; usleep (usleep_time); --- 281,285 ---- int timer = 0; if (sdf) { ! while ((sdf->block_for_write==0)&&(timer < MAX_USLEEP_TIME)) { timer +=usleep_time; usleep (usleep_time);
Index: write_shared_mem.cc =================================================================== RCS file: /cvsroot/pure-data/externals/iem/pdoctave/write_shared_mem.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** write_shared_mem.cc 26 Mar 2006 12:47:03 -0000 1.4 --- write_shared_mem.cc 26 Mar 2006 21:34:29 -0000 1.5 *************** *** 67,73 **** } if (args(0).is_empty()) { - pdtype = UNKNOWN; unBlockForWriting (sdf); ! freeSharedDataFrame (&sdf); return octave_value(); } --- 67,72 ---- } if (args(0).is_empty()) { unBlockForWriting (sdf); ! removeSharedDataFrame (&sdf); return octave_value(); } *************** *** 81,85 **** error("failed to get new data memory!"); unBlockForWriting (sdf); ! freeSharedDataFrame (&sdf); return octave_value(); } --- 80,84 ---- error("failed to get new data memory!"); unBlockForWriting (sdf); ! removeSharedDataFrame (&sdf); return octave_value(); } *************** *** 95,99 **** error("failed to get new data memory!"); unBlockForWriting (sdf); ! freeSharedDataFrame (&sdf); return octave_value(); } --- 94,98 ---- error("failed to get new data memory!"); unBlockForWriting (sdf); ! removeSharedDataFrame (&sdf); return octave_value(); } *************** *** 107,111 **** error("failed to get new data memory!"); unBlockForWriting (sdf); ! freeSharedDataFrame (&sdf); return octave_value(); } --- 106,110 ---- error("failed to get new data memory!"); unBlockForWriting (sdf); ! removeSharedDataFrame (&sdf); return octave_value(); }