Beispiel #1
0
//! Set up device and execute command(s).
//
int main(int argc, char** argv) {
    // read in program arguments
    read_arguments(argc, argv);

#ifdef _DEBUG
    // DEBUG: list the options
    dump_options();
#endif // _DEBUG

    // help over-rides all. For options variable see cmdline.h
    if (options.showHelp) {
        printHelp();
        exit(0);
    }

    // open the device or its imposter (file), see dfile.h
    if (options.inputFromFile == 1) {
        dopen(cmdFilename);
    }
    else {
        dopen(":usb:");
    }

    // dump header can be executed with other commands
    if (options.dumpHeader == 1) {
        printHeader();
    }

    // now dispatch for processing
    if (options.dumpMemory == 1) {
        // hexdump device memory
        dumpmemory(memoryDumpStart, memoryDumpEnd, DumpWidth);
    }
    else if (options.writeMemoryToFile == 1) {
        // copy device memory to a file
        copymem(cmdFilename);
    }
    else if (options.printRecordsSince == 1) {
        // list records since given date & time
        listRecordsSince(dateSince);
    }
    else if (options.printRecords == 1) {
        // list specified records (0 = current, n = oldest)
        if (options.untilFirstRecord == 1) {
            endRecordNumber = getRecordsStored();
        }
        listRecords(startRecordNumber, endRecordNumber);
    }

    dclose();
}
Beispiel #2
0
int
main(int argc, char **argv)
{
	char *s0, *s1;

	if ((argc > 1) && (*argv[1] == '-')) {
		argc--;
		argv++;
		while (*++argv[0])
			if (*argv[0] == 'b')
				bflag++;
	}

	(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)		/* Should be defined by cc -D */
#define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it weren't */
#endif
	(void) textdomain(TEXT_DOMAIN);

	if (argc != 3)
		error(gettext("must have 2 file arguments"));
	file[0] = dopen(argv[1], argv[2]);
	file[1] = dopen(argv[2], argv[1]);
	for (;;) {
		s0 = getl(0, ++n0);
		s1 = getl(1, ++n1);
		if (s0 == NULL || s1 == NULL)
			break;
		if (cmp(s0, s1) != 0) {
			if (!easysynch() && !hardsynch())
				progerr("5");
		} else {
			clrl(0, n0);
			clrl(1, n1);
		}
	}
	/* diff is expected to return 1 if the files differ */
	if (s0 == NULL && s1 == NULL)
		return (diffFound);
	if (s0 == NULL) {
		(void) output(-1, INF);
		return (1);
	}
	if (s1 == NULL) {
		(void) output(INF, -1);
		return (1);
	}
	/* NOTREACHED */
	return (0);
}
Beispiel #3
0
void* fileXioRpc_Dopen(unsigned int* sbuff)
{
	int ret;
	struct fxio_pathsel_packet *packet=(struct fxio_pathsel_packet*)sbuff;

	#ifdef DEBUG
		printf("RPC Dopen Request\n");
	#endif
	ret=dopen(packet->pathname);
	sbuff[0] = ret;
	return sbuff;
}
GzipInputStream::GzipInputStream(int fd, const char* mode)
{
	m_fp = 0;
   	dopen(fd, mode);
}
Beispiel #5
0
// This is the getdir for use by the EE RPC client
// It DMA's entries to the specified buffer in EE memory
int fileXio_GetDir_RPC(const char* pathname, struct fileXioDirEntry dirEntry[], unsigned int req_entries)
{
	int matched_entries;
      int fd, res;
  	iox_dirent_t dirbuf;
	struct fileXioDirEntry localDirEntry;
	int intStatus;	// interrupt status - for dis/en-abling interrupts
	struct t_SifDmaTransfer dmaStruct;
	int dmaID;

	dmaID = 0;

	#ifdef DEBUG
		printf("RPC GetDir Request\n");
		printf("dirname: %s\n",pathname);
	#endif

	matched_entries = 0;

      fd = dopen(pathname);
      if (fd <= 0)
      {
        return fd;
      }
	{

        res = 1;
        while (res > 0)
        {
          memset(&dirbuf, 0, sizeof(dirbuf));
          res = dread(fd, &dirbuf);
          if (res > 0)
          {
		// check for too many entries
		if (matched_entries == req_entries)
		{
			close(fd);
			return (matched_entries);
		}
		// wait for any previous DMA to complete
	      // before over-writing localDirEntry
	      while(SifDmaStat(dmaID)>=0);
            DirEntryCopy(&localDirEntry, &dirbuf);
	      // DMA localDirEntry to the address specified by dirEntry[matched_entries]
	      // setup the dma struct
	      dmaStruct.src = &localDirEntry;
	      dmaStruct.dest = &dirEntry[matched_entries];
	      dmaStruct.size = sizeof(struct fileXioDirEntry);
	      dmaStruct.attr = 0;
	      // Do the DMA transfer
	      CpuSuspendIntr(&intStatus);
	      dmaID = SifSetDma(&dmaStruct, 1);
	      CpuResumeIntr(intStatus);
  	      matched_entries++;
          } // if res
        } // while

      } // if dirs and files

      // cleanup and return # of entries
      close(fd);
	return (matched_entries);
}
Beispiel #6
0
BzipOutputStream::BzipOutputStream(int fd, const char* mode)
{
	m_fp = 0;
	m_cf = 0;
   	dopen(fd, mode);
}
Beispiel #7
0
Fenfloss::Fenfloss(int  argc,  char  *argv[])
:coSimLib(argc, argv, argv[0], "Simulation coupling")
{
	char *pfn;
	////////// set up default parameters
        
#ifdef VERBOSE

	cerr << "##############################" << endl;
	cerr << "#####   Fenfloss "              << endl;
	cerr << "#####   PID =  " << getpid()   << endl;
	cerr << "##############################" << endl;
#endif
#ifndef YAC
	set_module_description("Fenfloss Simulation");
#endif
	SetDebugPath(coCoviseConfig::getEntry("Module.IHS.DebPath").c_str(),getenv(ENV_IHS_DEBPATH));
/*
	SetDebugLevel(0);
	if (getenv(ENV_IHS_DEBUGLEVEL))
           SetDebugLevel(atoi(getenv(ENV_IHS_DEBUGLEVEL)));
*/
        if ((pfn = CreateFileNameParam(coCoviseConfig::getEntry("value","Module.IHS.DebPath","/tmp/").c_str(), ENV_IHS_DEBPATH, coCoviseConfig::getEntry("value","Module.IHS.DebFile","Fenfloss.deb").c_str(), CFNP_NORM)) != NULL)
	{
           dopen(pfn);
           free(pfn);
	}

	// Parameters
   std::string dataPath; 
#ifdef WIN32
   const char *defaultDir = getenv("USERPROFILE");
#else
   const char *defaultDir = getenv("HOME");
#endif
   if(defaultDir)
      dataPath=coCoviseConfig::getEntry("value","Module.IHS.DataPath",defaultDir);
   else
      dataPath=coCoviseConfig::getEntry("value","Module.IHS.DataPath","/data/IHS");
	dprintf(2, "Fenfloss::Fenfloss(): dp = %s\n", dataPath.c_str());
        
        Fenfloss::CreateUserMenu();

	// Input ports : yet only parallel ones allowed
	p_grid    = addInputPort("distGrid","UnstructuredGrid","Distributed Grid");
	p_boco    = addInputPort("distBoco1","USR_DistFenflossBoco","Distributed Boundary Cond");
	p_boco2   = addInputPort("distBoco2","USR_DistFenflossBoco","Distributed Boundary Cond");
	p_boco2->setRequired(0);
	p_in_bcin = addInputPort("bcin","Polygons","Boundary surface of inlet(IN)");
	p_in_bcin->setRequired(0);

	// Output ports
	p_velocity   = addOutputPort("velocity","Vec3","Geschwindigkeit");
	p_press      = addOutputPort("p","Float","Druck");
	p_turb       = addOutputPort("turb","Float","Turbulen");
	p_out_bcin   = addOutputPort("out_bcin","Polygons","Boundary surface of inlet(OUT)");

	// not yet started
	stepNo = -1;

	// No object yet received
	d_distGridName = new char [1];
	d_distGridName[0] = '\0';
	d_distBocoName = new char [1];
	d_distBocoName[0] = '\0';

#ifdef HAVE_GLOBUS        
	globus_module_activate(GLOBUS_COMMON_MODULE);
	globus_module_activate(GLOBUS_SOAP_MESSAGE_MODULE);
#endif

}
Beispiel #8
0
int main()
{
	FILE *snd_in;
	FILE *snd_out;

	if((snd_in = popen("rec -t raw -b 16 -c 1 -e s -r 44100 -", "r")) == NULL) {
		fprintf(stderr, "could not open rec\n");
		exit(1);
	}
	if((snd_out = popen("play -t raw -b 16 -c 1 -e s -r 44100 -", "w")) == NULL) {
		fprintf(stderr, "could not open play\n");
		exit(1);
	}

	int n, m;
	short *data;
	float *float_data;
	while(1) {
		pid_t pitch_pid;
		FILE *pitch_in;
		FILE *pitch_out;
		pid_t excite_pid;
		FILE *excite_in;
		FILE *excite_out;
		pid_t mcep_pid;
		FILE *mcep_in;
		FILE *mcep_out;
		pid_t frame_pid;
		FILE *frame_in;
		FILE *frame_out;
		pid_t window_pid;
		FILE *window_in;
		FILE *window_out;
		pid_t sopr_pid;
		FILE *sopr_in;
		FILE *sopr_out;
		pid_t mlsadf_pid;
		FILE *mlsadf_in;
		FILE *mlsadf_out;
		pid_t clip_pid;
		FILE *clip_in;
		FILE *clip_out;

		void* buf = malloc(1000000);
		data = calloc(sizeof(short), PACKET_SIZE);
		float_data = calloc(sizeof(float), PACKET_SIZE);

		n = fread(data, 1, PACKET_SIZE, snd_in);

		// x2x +sf
		int i;
		for(i = 0; i < n; i++) {
			float_data[i] = (float)data[i];
        }

        // xtract pitch
        char *pitch_op[] = {"pitch", "-a", "1", "-s", "16", "-p", "80", NULL};
		pitch_pid = dopen("pitch", pitch_op, &pitch_out, &pitch_in);
		setlinebuf(pitch_out);
		setlinebuf(pitch_in);
		fwritef(float_data, 1, n, pitch_in);
		printf("pitch data: %d bytes", (int)fread(float_data, 1, 100000, pitch_out));
		printf("pitch started.\n");

		// xtract mcep
		char *frame_op[] = {"frame", "-p", "80", NULL};
		frame_pid = dopen("frame", frame_op, &frame_out, &frame_in);
		setlinebuf(frame_out);
		setlinebuf(frame_in);
		fwrite(float_data, 1, n, frame_in);
		printf("frame started.\n");
		
		char *window_op[] = {"window", NULL};
		window_pid = dopen("window", window_op, &window_out, &window_in);
		setlinebuf(window_out);
		setlinebuf(window_in);

		int frame_to_window[2];
		pipe(frame_to_window);
		dup2(frame_to_window[0], fileno(frame_out));
		dup2(frame_to_window[1], fileno(window_in));
		// while(n > 0) {
		// 	n = fread(buf, 1, 1000, frame_out);
		// 	printf("%d bytes read\n", n);
		// 	if(n < 0) break;
		// 	fwrite(buf, 1, n, window_in);
		// }
		kill(frame_pid, SIGTERM);
		pclose(frame_in);
		pclose(frame_out);
		printf("window started.\n");

		char *mcep_op[] = {"mcep", "-m", "25", "-a", "0.42", NULL};
		mcep_pid = dopen("mcep", mcep_op, &mcep_out, &mcep_in);
		setlinebuf(mcep_out);
		setlinebuf(mcep_in);

		int window_to_mcep[2];
		pipe(window_to_mcep);
		dup2(window_to_mcep[0], fileno(window_out));
		dup2(window_to_mcep[1], fileno(mcep_in));

		// while(n > 0) {
		// 	n = fread(buf, 1, 1000000, window_out);
		// 	if(n < 0) break;
		// 	fwrite(buf, 1, n, mcep_in);
		// }
		kill(window_pid, SIGTERM);
		pclose(window_in);
		pclose(window_out);
		printf("mcep started.\n");

//		printf("test: %d\n", (int)fread(buf, 1, sizeof(int), pitch_out));
		char* sopr_op[] = {"sopr", "-m", "0.3"};
		int sopr_pipe[2];
		pipe(sopr_pipe);
		sopr_in = fdopen(sopr_pipe[0], "w");
		sopr_out = fdopen(sopr_pipe[1], "rb");
		my_sopr(3, sopr_op, pitch_out, sopr_in);
		printf("sopr started.\n");

		char *excite_op[] = {"excite", "-p", "80", NULL};
		excite_pid = dopen("excite", excite_op, &excite_out, &excite_in);

		int sopr_to_excite[2];
		pipe(sopr_to_excite);
		dup2(sopr_to_excite[0], sopr_pipe[1]);
		dup2(sopr_to_excite[1], fileno(excite_in));
		// while(n > 0) {
		// 	n = fread(buf, 1, 1000000, sopr_out);
		// 	if(n < 0) break;
		// 	fwrite(buf, 1, n, excite_in);
		// }
//		pclose(sopr_in);
//		pclose(sopr_out);
		printf("excite started.\n");

		int mlsadf_pipe[2];
		if(vfork() == 0) { 
			char* mlsadf_op[] = {"mlsadf", "-m", "25", "-a", "0.42", "-p", "80"};
			pipe(mlsadf_pipe);
			mlsadf_in = fdopen(mlsadf_pipe[0], "wb");
			mlsadf_out = fdopen(mlsadf_pipe[1], "rb");
			my_mlsadf(7, mlsadf_op, excite_out, mcep_out, mlsadf_in);
			kill(excite_pid, SIGTERM);
			pclose(excite_in);
			pclose(excite_out);
			kill(mcep_pid, SIGTERM);
			pclose(mcep_in);
			pclose(mcep_out);
		}
		printf("mlsadf started.\n");

		char *clip_op[] = {"clip", "-y", "32000", "32000", NULL};
		clip_pid = dopen("clip", clip_op, &clip_out, &clip_in);

		int mlsadf_to_clip[2];
		pipe(mlsadf_to_clip);
		dup2(mlsadf_to_clip[0], mlsadf_pipe[1]);
		dup2(mlsadf_to_clip[1], fileno(clip_in));
		// while(n > 0) {
		// 	n = fread(buf, 1, 1000000, mlsadf_out);
		// 	if(n < 0) break;
		// 	fwrite(buf, 1, n, clip_in);
		// }
		// pclose(mlsadf_in);
		// pclose(mlsadf_out);
		printf("clip started.\n");

		while(n > 0) {
			n = fread(float_data, sizeof(float), PACKET_SIZE, clip_out);
			if(n < 0) break;
			for(i = 0; i < n; i++) {
				data[i] = (short)float_data[i];
	        }
			fwrite(data, 1, n, snd_out);
		}
		kill(clip_pid, SIGTERM);
		pclose(clip_in);
		pclose(clip_out);

		free(buf);
		free(data);
		free(float_data);
	}
	printf("done.\n");

	// extract pitch	


}
Beispiel #9
0
FileStream::FileStream(int fd, const char* mode)
{
	dopen(fd, mode);
}