//============================================================================= Multiplexer::Multiplexer() : m_num_threads(0), m_main_thread(pthread_self()), m_enable_jobs(true), m_loops(0), m_jobs_run(0), m_job_waits(0), m_job_waits_acc(0) { // Create a socketpair for waking up the main thread. socketpair(PF_UNIX,SOCK_STREAM,0,m_wakeup); fcntl(m_wakeup[0],F_SETFL,fcntl(m_wakeup[0],F_GETFL) | O_NONBLOCK); fcntl(m_wakeup[1],F_SETFL,fcntl(m_wakeup[1],F_GETFL) | O_NONBLOCK); set_latency(1000000); }
void osc_pad_t::impl_t::root_latency() { set_latency(get_latency()); }
int main( int argc, char *argv[] ) { // unsigned long in_buf; // char *data_buff; // int ret; int c; optparams_t oparams; int fd; int oflag; printf( "read_ft245 test program is started\n" ); oparams.dev_name = strdup( "//9/dev/ft245" ); //!!!! oparams.fname = NULL; oparams.nonblock = 0; oparams.devinfo = 0; oparams.rx_timeout = 0; oparams.psize = 8; oparams.npackets = 30; oparams.verbose = 0; oparams.reset = 0; oparams.latency = 0; while ( ( c = getopt( argc, argv, "d:f:nivrs:p:t:l:" ) ) != -1 ) { switch( c ) { case 'd': oparams.dev_name = optarg; break; case 'f': oparams.fname = optarg; break; case 'n': oparams.nonblock = 1; break; case 'i': oparams.devinfo = 1; break; case 'v': oparams.verbose++; break; case 's': oparams.psize = strtoul( optarg, NULL, 0 ); break; case 'p': oparams.npackets = strtoul( optarg, NULL, 0 ); break; case 't': TM = 1; break; case 'r': oparams.reset = 1; break; case 'l': oparams.latency = strtoul( optarg, NULL, 0 ); if ( oparams.latency == 0 ) { fprintf( stderr, "Command line: Bad latency value. Correct range is 1 - 255\n" ); oparams.latency = 0; } break; default: fprintf( stderr, "Unsupported comand line option\n" ); break; } } open_shmem(); // open device in block or nonblock mode oflag = O_RDONLY | O_NONBLOCK; if ( ( fd = open( oparams.dev_name, oflag ) ) == -1 ) { fprintf( stderr, "open() failed. %s\n", strerror( errno ) ); return ( -1 ); } //if ( oparams.reset ) reset_device( fd ); if ( oparams.devinfo ) get_dev_info( fd ); // timeout test if ( oparams.rx_timeout ) set_rx_timeout( fd, oparams.rx_timeout ); if ( oparams.latency ) set_latency( fd, oparams.latency ); printf( "Device latency time is %d\n", get_latency( fd ) ); //if ( oparams.reset ) //reset_device( fd ); printf( "Start data read. \n"); read_data_nonblock1( fd, oparams.psize, oparams.npackets, oparams.fname ); printf( "read_ft245 test program is finished %d\n",sum_ret ); close( fd ); return( 0 ); }