コード例 #1
0
ファイル: main.c プロジェクト: taarakan/Obuchenie
void main()
{
char c;
int i1;
int i2;
int a;
printf("pervoe chislo ");
scanf("%d",&i1);

printf("vtoroe chislo ");
 scanf("%d",&i2);

while (1)
{
 puts(" 1 - add");
 puts(" 2 - usb");
 puts(" 3 - mul");
 puts(" 4 - div");
 c=getchar();
 switch(c)
 {case '1':a=add(i1,i2);
  break;
  case '2': a=usb(i1,i2);
  break;
  case '3': a=mul(i1,i2);
  break;
  case '4': a=div(i1,i2);
  break;
 }
 printf("Rezultat=%d \n", a);
}
}
コード例 #2
0
ファイル: main.cpp プロジェクト: j0t4/espardino
int main(void)
{

	xTaskHandle xHandleA,xHandleB,xHandleC;

	Serial usb(USB_TX,USB_RX);	
	
	xTaskCreate( vATaskFunction, (const signed char*)"TASKLEDS_A", configMINIMAL_STACK_SIZE, &usb , tskIDLE_PRIORITY+1, &xHandleA );
	xTaskCreate( vBTaskFunction, (const signed char*)"TASKLEDS_B", configMINIMAL_STACK_SIZE, &usb , tskIDLE_PRIORITY+1, &xHandleB );
	xTaskCreate( vCTaskFunction, (const signed char*)"TASKLEDS_C", configMINIMAL_STACK_SIZE, &usb , tskIDLE_PRIORITY+1, &xHandleC );

	vTaskStartScheduler(); /* start the task scheduler, all task start now */

}
コード例 #3
0
ファイル: lidar.cpp プロジェクト: jibee/STpp
int main() {
	Platform::STM32F4_WithUSB b;
	Platform::UsbSerial usb(b);
	usb << "Hello !" << endl;

	Platform::Gpio LidarRX(b.GpioD[9]);
	Platform::Uart Lidar(3);
	LidarNeato lidar(LidarRX, Lidar);

	while(true) {
		lidar_neato_t packet;
		lidar >> packet;

#if 0
		usb << "["
				  << (int)packet.index
				  << "]"
				  << "@"
				  << (int)packet.speed
				  /*
				  << ":"
				  << (int)packet.data[0]
				  << "," << (int)packet.data[1]
				  << "," << (int)packet.data[2]
				  << "," << (int)packet.data[3]*/
				  << "=" << (int)(packet.data[0]&0x7fff)
				  << ";" << endl;
#else
		usb << "@" << (int) packet.speed << endl;
		for(int i=0; i<4; ++i) {
			usb
				<< "#"
				<< ((int)(packet.index-0xa0))*4+i
				<< ","
				<< ((int)packet.data[i]&0x3fff)
				<< ((packet.data[i]&0x4000) ? "!" : "")
				<< endl;
		}
#endif
	}

	while(1);
}
コード例 #4
0
// choose logo image
void MainWindow::usbSelectImage()
{
    QString tempPath =
        QFileDialog::getOpenFileName(ui->usbInfoPage,
                                     "Select *.bmp (with rgb565 or rgb888):",
                                     QDir::homePath()
#ifdef Q_WS_MAEMO_5
                                     + "/MyDocuments"
#endif
                                     ,
                                     "*.bmp"
                                    );
    if (tempPath.isEmpty())
        return;

    if (bmpCheckFormat(tempPath) == false)
    {
        QMessageBox::warning(ui->usbInfoPage, "Error!",
                             QFileInfo(tempPath).fileName() +
                             " is not a *.bmp image with "
                             "16bit (rgb565) or 24bit (rgb888) palette.");
        return;
    }

    QImage usb(tempPath);
    if (enableAnySizes->isChecked() == false)
    {
        if ((usb.width() < 40) || (usb.height() < 40))
        {
            QMessageBox::warning(this, "Error!",
                                 "Selected image has width or/and height less than default image!\n"
                                 "Default size for usb is 40x40.\n"
                                 "If you want to use this image anyway - enable any image sizes from the menu bar.");
            return;
        }
    }

    usbPath = tempPath;
    usbPreview->setPixmap(QPixmap::fromImage(usb));
    usbFileName->setText(QFileInfo(usbPath).fileName());
}
コード例 #5
0
ファイル: main.cpp プロジェクト: uriahjb/symphotron
int main( void )
{
    mInit();
    mUSBInit();
    mBusInit();

    // Set up usb interface
    bQueue in_q;
    bQueue out_q;
    usbIface usb( &in_q, &out_q );
    
//    picker_setup();
    stepper_setup();
//    set_timer5 (60000,30000,1200);
    
    setMode( STEP_8TH);
    setSpeedLimits( 65, 500 );
    set_speed(m_speed_min);
    setAccelerationLimit(100); //5000 is good
    
    uint8_t cmd; 
    uint16_t pos = 0;
    while(1)
    {
        usb.readBytes();

        // Handle bytes 
        if (!in_q.isempty() ) {
          mBlueTOGGLE;
          in_q.dequeue(&cmd);
          if ( cmd == 'l' ) {
            pos += 10;
          } else if ( cmd == 'h' ) {
            pos -= 10;
          }
        }
        update(pos);
    }
    return(0);
}
コード例 #6
0
ファイル: main.cpp プロジェクト: j0t4/espardino
int main(void)
{
	float x,y,dx,dy;
	Serial usb(USB_TX,USB_RX);
	SSD1308 oled;

	oled.attach(P0_19, /*MOSI*/
				P0_18, /*MISO*/
				P0_17, /*SCK*/
				P0_20, /*CS */
				P0_16, /*DC*/
				P0_15  /*RESET*/);

	oled.init();
	oled.setContrast(0x50);


	x=0;y=0;
	dx=0.7;dy=0.2;

	oled.setFont(FONT_6x8,FONT_NORMAL);

	while(1)
	{
		x+=dx;
		y+=dy;
		if (x>=127 || x<=0) dx=-dx;
		if (y>=63 || y<=0) dy=-dy;

		oled.clear();
		oled.plot(x,y,1);
		oled.gotoxy(x,y);
		oled.printf("(%d,%d) hello",(int)x,(int)y);
		oled.line(64,32,x,y,1);

		oled.dump();

	}
}
コード例 #7
0
ファイル: main.cpp プロジェクト: uriahjb/symphotron
int main( void )
{
    // Initialize m4 things
    mInit();
    //mBusInit();
    mUSBInit();

    // Set up usb interface
    bQueue in_q;
    bQueue out_q;
    usbIface usb( &in_q, &out_q );
    
    // Initialize midi interface
    midiParser midi( &in_q );
    midiMsg msg;

    mYellowON;
    
    while(1)
    {
      usb.readBytes();
      /*
      mWaitms(500);
      mGreenON;
      usb.printf( "hello world\n" );
      mWaitms(500);
      mGreenOFF;
      */
      if ( midi.hasMsg(&msg) ) {
        mGreenTOGGLE;
        usb.printf("msg: %02x\n", msg.status);
        usb.printf("channel: %02x\n", msg.channel);
        usb.printf("data[0]: %02x\n", msg.data[0]);
        usb.printf("data[1]: %02x\n", msg.data[1]);
      }
      // Write data out 
      usb.writeBytes();
    }
}
コード例 #8
0
ファイル: connectionmgr2.cpp プロジェクト: Tasssadar/Lorris
ConnectionPointer<Connection> ConnectionManager2::getConnWithConfig(quint8 type, const QHash<QString, QVariant> &cfg)
{
    this->refresh();

#ifdef HAVE_LIBYB
    // We want to receive first USB enumeration events,
    // so that connections created here can be opened
    QApplication::processEvents();
#endif

    Connection *enumCon = NULL;
    for(int i = 0; i < m_conns.size(); ++i)
    {
        if(m_conns[i]->getType() != type)
            continue;

        switch(type)
        {
            case CONNECTION_SERIAL_PORT:
            {
                SerialPort *sp = (SerialPort*)m_conns[i];
                if(sp->deviceName() == cfg["device_name"])
                {
                    if(!sp->removable())
                        enumCon = sp;
                    else if(sp->baudRate() == cfg["baud_rate"])
                        return ConnectionPointer<Connection>::fromPtr(sp);
                }
                break;
            }
            case CONNECTION_TCP_SOCKET:
            {
                TcpSocket *socket = (TcpSocket*)m_conns[i];
                if(socket->host() == cfg["host"] && socket->port() == cfg["port"])
                    return ConnectionPointer<Connection>::fromPtr(socket);
                break;
            }
            case CONNECTION_UDP_SOCKET:
            {
                UdpSocket *socket = (UdpSocket*)m_conns[i];
                if (socket->name() == cfg["name"] &&
                    socket->host() == cfg["host"] && socket->port() == cfg["port"])
                    return ConnectionPointer<Connection>::fromPtr(socket);
                break;
            }
            case CONNECTION_PROXY_TUNNEL:
            {
                ProxyTunnel *tunnel = (ProxyTunnel*)m_conns[i];
                if(tunnel->name() == cfg["name"])
                    return ConnectionPointer<Connection>::fromPtr(tunnel);
                break;
            }
            case CONNECTION_SHUPITO_TUNNEL:
            {
                QHash<QString, QVariant> c = cfg.value("companions").toHash();
                QHash<QString, QVariant>::iterator itr = c.find(ShupitoTunnel::getCompanionName());
                if(itr == c.end())
                    return ConnectionPointer<Connection>();

                qint64 id = itr.value().toLongLong();
                if(id != 0 && id == m_conns[i]->getCompanionId(ShupitoTunnel::getCompanionName()))
                    return ConnectionPointer<Connection>::fromPtr((ShupitoTunnel*)m_conns[i]);
                break;
            }
            case CONNECTION_SHUPITO_SPI_TUNNEL:
            {
                QHash<QString, QVariant> c = cfg.value("companions").toHash();
                QHash<QString, QVariant>::iterator itr = c.find(ShupitoSpiTunnelConn::getCompanionName());
                if(itr == c.end())
                    return ConnectionPointer<Connection>();

                qint64 id = itr.value().toLongLong();
                if(id != 0 && id == m_conns[i]->getCompanionId(ShupitoSpiTunnelConn::getCompanionName()))
                    return ConnectionPointer<Connection>::fromPtr((ShupitoSpiTunnelConn*)m_conns[i]);
                break;
            }
#ifdef HAVE_LIBYB
            case CONNECTION_USB_ACM2:
            {
                UsbAcmConnection2 *usb = (UsbAcmConnection2*)m_conns[i];
                if (usb->vid() == cfg.value("vid", 0).toInt() &&
                    usb->pid() == cfg.value("pid", 0).toInt() &&
                    usb->serialNumber() == cfg.value("serial_number").toString() &&
                    usb->intfName() == cfg.value("intf_name").toString() &&
                    usb->baudRate() == cfg.value("baud_rate", 115200).toInt() &&
                    usb->stopBits() == cfg.value("stop_bits", 0).toInt() &&
                    usb->parity() == (UsbAcmConnection2::parity_t)cfg.value("parity", 0).toInt() &&
                    usb->dataBits() == cfg.value("data_bits", 8).toInt())
                {
                    usb->applyConfig(cfg);
                    return ConnectionPointer<Connection>::fromPtr(usb);
                }
                break;
            }
            case CONNECTION_SHUPITO23:
            {
                UsbShupito23Connection *usb = (UsbShupito23Connection*)m_conns[i];
                if (usb->vid() == cfg.value("vid", 0).toInt() &&
                    usb->pid() == cfg.value("pid", 0).toInt() &&
                    usb->serialNumber() == cfg.value("serial_number").toString() &&
                    usb->intfName() == cfg.value("intf_name").toString())
                {
                    usb->applyConfig(cfg);
                    return ConnectionPointer<Connection>::fromPtr(usb);
                }
                break;
            }
            case CONNECTION_STM32:
            {
                STM32Connection *stm32 = (STM32Connection*)m_conns[i];
                if (stm32->vid() == cfg.value("vid", 0).toInt() &&
                    stm32->pid() == cfg.value("pid", 0).toInt() &&
                    stm32->serialNumber() == cfg.value("serial_number").toString() &&
                    stm32->intfName() == cfg.value("intf_name").toString())
                {
                    return ConnectionPointer<Connection>::fromPtr(stm32);
                }
                break;
            }
#endif
            default:
                return ConnectionPointer<Connection>();
        }
    }

    if(enumCon)
    {
        enumCon->applyConfig(cfg);
        return ConnectionPointer<Connection>::fromPtr(enumCon);
    }

    if(type == CONNECTION_SHUPITO_TUNNEL)
    {
        QHash<QString, QVariant> c = cfg.value("companions").toHash();
        QHash<QString, QVariant>::iterator itr = c.find(ShupitoTunnel::getCompanionName());
        if(itr == c.end())
            return ConnectionPointer<Connection>();

        qint64 id = itr.value().toLongLong();
        if(id == 0)
            return ConnectionPointer<Connection>();

        ConnectionPointer<Connection> tunnel(new ShupitoTunnel());
        tunnel->applyConfig(cfg);
        tunnel->setRemovable(false);
        this->addConnection(tunnel.data());
        return tunnel;
    }
    else if(type == CONNECTION_SHUPITO_SPI_TUNNEL)
    {
        QHash<QString, QVariant> c = cfg.value("companions").toHash();
        QHash<QString, QVariant>::iterator itr = c.find(ShupitoSpiTunnelConn::getCompanionName());
        if(itr == c.end())
            return ConnectionPointer<Connection>();

        qint64 id = itr.value().toLongLong();
        if(id == 0)
            return ConnectionPointer<Connection>();

        ConnectionPointer<Connection> tunnel(new ShupitoSpiTunnelConn());
        tunnel->applyConfig(cfg);
        tunnel->setRemovable(false);
        this->addConnection(tunnel.data());
        return tunnel;
    }
#ifdef HAVE_LIBYB
    else if(type == CONNECTION_USB_ACM2)
    {
        ConnectionPointer<Connection> usb(createUsbAcmConn());
        usb->applyConfig(cfg);
        return usb;
    }
    else if(type == CONNECTION_STM32)
    {
        ConnectionPointer<Connection> stm32(createSTM32Conn());
        stm32->applyConfig(cfg);
        return stm32;
    }
#endif

    return ConnectionPointer<Connection>();
}
コード例 #9
0
int main(int argc, char **argv)
{
  std::string file = "/dev/controller_sensor";
  UInt32 baudrate = 115200;
  SerialInterface usb("/dev/controller_sensor", baudrate);


  if (argc > 1)
  {
    file = argv[1];
    printf("%s info: Opening %s\n", argv[0], file.c_str());
  }

  if (pthread_mutex_init(&myMutex, NULL) != 0)
  {
    printf("Failed to get mutex: %s\n", strerror(errno));
    exit(-1);
  }

  name = argv[0];

  float temp[3] = {0.0};
  float pressure = 0.0;
  int motorKilled = 0, waterDetected, dropperLeft= 0, dropperRight= 0;
  float curVolt[2] = {0.0};
  int numVariables = 10;

  float ttemp[3] = {0.0};
  float tpressure = 0.0;
  int tmotorKilled = 0, twaterDetected= 0, tdropperLeft= 0, tdropperRight= 0;
  float tcurVolt[2] = {0.0};

  timer tempTimer, pressureTimer, motorTimer, currentTimer, waterTimer, dropperTimer;

  tempTimer.start(1, 0);
  pressureTimer.start(1, 0);
  motorTimer.start(1, 0);
  currentTimer.start(1, 0);
  waterTimer.start(1, 0);
  dropperTimer.start(1, 0);

  ros::init(argc, argv, "SubSensorController");
  ros::NodeHandle nh;

  ros::Publisher temperatuerPub = nh.advertise<std_msgs::Float32MultiArray>("Controller_Box_Temp", 1000);
  ros::Publisher pressurePub = nh.advertise<std_msgs::Float32>("Pressure_Data", 1000);
  ros::Publisher MotorPub = nh.advertise<std_msgs::UInt8>("Motor_State", 1000);
  ros::Publisher computerPub = nh.advertise<std_msgs::Float32MultiArray>("Computer_Cur_Volt", 1000);
  ros::Publisher waterPub = nh.advertise<std_msgs::UInt8>("Water_Detected", 1000);
  ros::Publisher dropperPub = nh.advertise<std_msgs::UInt8MultiArray>("Dropper_States", 1000);

  ros::Subscriber torpedoSub = nh.subscribe("Torpedo_Launch", 1000, torpedoCallback);
  ros::Subscriber dropperSub = nh.subscribe("Dropper_Activate", 1000, dropperCallback);

  ros::Rate loop_rate(1);

  while (ros::ok())
  {
    if (controllerState == STATE_WAITING_ON_FD)
    {
      if (checkLock() && getLock())
      {
        controllerState = STATE_WORKING;
        sleep(5);
        
        //fd = open(file.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
        // if (fd == -1)
        // {
        //   printf("%s Error: System failed to open %s: %s(%d)\n", argv[0], file.c_str(), strerror(errno), errno);
        //   sleep(1);
        // }
        // else
        // {
        //   if (setupTTY(fd) == 0) 
        //   {
        //     controllerState = STATE_WORKING;

        //     sleep(5); //wait for sensor to boot and stabilize
        //   }
        //   else
        //     close(fd);
        // }
        releaseLock();
      }
    }
    else if (controllerState == STATE_WORKING)
    {
      std::string line = "";
      if (checkLock() && getLock())
      {
        UInt8 aBuf[baudrate];
        usb.recv(aBuf,baudrate);
        std::string temp ((const char*)aBuf,baudrate);
        line = temp;
        //line = getTTYLine(fd);
        //printf("got line %s\n", line.c_str());
        releaseLock();
      }

      if (line != "")
      {
        //printf("line: %s\n", line.c_str());
        if (line.length() > 0 && goodLine(line, numVariables))
        {
          int scanfVal;

          if ((scanfVal = sscanf(line.c_str(), "S%f,%f,%f,%d,%f,%f,%f,%d,%d,%dE", &ttemp[0], &ttemp[1], &ttemp[2], &tmotorKilled,
              &tcurVolt[0], &tcurVolt[1], &tpressure, &twaterDetected, &tdropperLeft, &tdropperRight)) == numVariables)
          {
            if ((temp[0] != ttemp[0]) || (temp[1] != ttemp[1]) || (temp[2] != ttemp[2]) || tempTimer.isTimeout())
            {
              //temperature
              std_msgs::Float32MultiArray tempMsg;
              temp[0] = ttemp[0];
              temp[1] = ttemp[1];
              temp[2] = ttemp[2];
              tempMsg.data.push_back(temp[0]);
              tempMsg.data.push_back(temp[1]);
              tempMsg.data.push_back(temp[2]);
              temperatuerPub.publish(tempMsg);
              tempTimer.start(1, 0);
              ros::spinOnce();
            }

            if (motorKilled != tmotorKilled || motorTimer.isTimeout())
            {
              //motorkilled
              std_msgs::UInt8 motorMsg;
              motorKilled = tmotorKilled;
              motorMsg.data = motorKilled;
              MotorPub.publish(motorMsg);
              motorTimer.start(1, 0);
              ros::spinOnce();
            }

            if ((curVolt[0] != tcurVolt[0]) || (curVolt[1] != tcurVolt[1] || currentTimer.isTimeout()))
            {
              //curvolt
              std_msgs::Float32MultiArray curMsg;
              curVolt[0] = tcurVolt[0];
              curVolt[1] = tcurVolt[1];
              curMsg.data.push_back(curVolt[0]);
              curMsg.data.push_back(curVolt[1]);
              computerPub.publish(curMsg);
              currentTimer.start(1, 0);
              ros::spinOnce();
            }

            if (pressure != tpressure || pressureTimer.isTimeout())
            {
              //depth
              std_msgs::Float32 pressureMsg;
              pressure = tpressure;
              pressureMsg.data = pressure;
              pressurePub.publish(pressureMsg);
              pressureTimer.start(1, 0);
              ros::spinOnce();
            }

            if (waterDetected != twaterDetected || waterTimer.isTimeout())
            {
              //water detected
              std_msgs::UInt8 waterMsg;
              waterDetected = twaterDetected;
              waterMsg.data = waterDetected;
              waterPub.publish(waterMsg);
              waterTimer.start(1, 0);
              ros::spinOnce();
            }

            if (tdropperLeft != dropperLeft || tdropperRight != dropperRight || dropperTimer.isTimeout())
            {
              //water detected
              std_msgs::UInt8MultiArray dropperMsg;
              dropperLeft = tdropperLeft;
              dropperRight = tdropperRight;
              dropperMsg.data.push_back(dropperLeft);
              dropperMsg.data.push_back(dropperRight);
              dropperPub.publish(dropperMsg);
              dropperTimer.start(1, 0);
              ros::spinOnce();
            }

            if (VERBOSE)
              ROS_INFO("published");
          }
          else
          {
            printf("%s info: Throwing away %d:\"%s\"\n", argv[0], scanfVal, line.c_str());
            fflush(stdout);
          }
        }
      }
    }
  }

  pthread_mutex_destroy(&myMutex);
  close(fd);
  return 0;
}
コード例 #10
0
ファイル: main.c プロジェクト: tedluo/photobox
int main(int argc,char **argv)
{
	unsigned char* fbp;

	if(usb() != 0)
	{
		fprintf(stdout,"Faile to mount USB.\n");
		exit(1);
	}
	if(get_media_info(&my_usb_info) != 0)
	{
		fprintf(stdout,"%s:%d:Faled to get usb device information.\n ",__FILE__,__LINE__);
		exit(1);
	}

	if((fbp =init_framebuff(&vinfo,&finfo)) ==NULL)
	{
		fprintf(stdout,"Failed to init framebuff.\n");
		exit(1);
	}
	int code;
	pthread_t pthread_key_ctr;
	if((code = pthread_create(&pthread_key_ctr,NULL,key_ctr,NULL)) < 0)
	{
		fprintf(stderr,"Create thread failed:%s\n",strerror(errno));
		exit(1);
	}
	chdir("./mountPos");	
	//int i;
	//fprintf(stdout,"counter_p =%d\n",my_usb_info.counter_p);
	//fprintf(stdout,"buff_media_picture[1] =%s\n",my_usb_info.buff_media_picture[1]);

	while(1)
	{
		if(picture_mode == 1)
		{
			int i;
			for(i = 0;i < my_usb_info.counter_p;i++)
			{
				memset(buffer,0,screensize);
				picture_to_memory_copy(my_usb_info.buff_media_picture[i]);
				//int line_size =  vinfo.xres *vinfo.bits_per_pixel/8;
				//for(j = 0;j <= vinfo.yres;j++)
				//{	
				//	memcpy(fbp + j * line_size,buffer,line_size);
				//	usleep(100);
				//}
				memset(fbp,0,screensize);
				memcpy(fbp,buffer,screensize);
				memset(buffer,0,screensize);
				sleep(1);
				if(quit_flag == 1)
				{
					break;
				}
				if(back_menu == 1)
				{
					back_menu = 0;
					picture_mode = 0;
					break;
				}

			}
		}
		else if(picture_mode == 2)
		{	
			if(selects_flag == 1)
			{
				//fprintf(stdout,"%s:%d:Can'i go here?\n",__FILE__,__LINE__);
				//fflush(stdout);
				memset(buffer,0,screensize);
				picture_to_memory_copy(my_usb_info.buff_media_picture[selects]);
				//fprintf(stdout,"%s:%d:Can'i go here?\n",__FILE__,__LINE__);
				//fflush(stdout);
				//memset(fbp,0,screensize);
				memcpy(fbp,buffer,screensize);
				memset(buffer,0,screensize);
				selects_flag = 0;
				key_down_flag = 0;
				while(1)
				{
					if(un_selects_flag == 1)
					{
						un_selects_flag = 0;
						key_down_flag = 0;
						break;
					}
					if(back_menu == 1)
					{
						back_menu = 0;
						key_down_flag = 0;
						break;
					}
					if(quit_flag == 1)
					{
						break;
					}
				}
			}	
			show_pictures();
			while(!key_down_flag)
			{
				un_selects_flag = 0;
			
			}
			if(back_menu == 1)
			{
				back_menu = 0;
				picture_mode = 0;
				continue;
			}
			if(quit_flag == 1)
			{
				break;
			}
		}

		if(quit_flag == 1)
		{
			quit_flag = 0;
			break;
		}
	}

	chdir("..");
	umount("./mountPos");
	system("rm  -r mountPos");
	return 0;

}
コード例 #11
0
int main(int argc, char** argv){
	//select loggin level 
	logger_default_config(log4cxx::Level::getInfo());

	std::string adc_id;
	std::string filename;
	size_t offset = 0x08000000; // 128M * 4 -> second memory bank
	size_t block_size = 2048;
	size_t data_size = 4096;
	bool simple_mode = false;
	bool halbe_mode = false;
	bool statistic_mode = false;

	{
		namespace po = boost::program_options;
		po::options_description desc("Allowed options");
		desc.add_options()
			("help", "produce help message")
			("adc", po::value<std::string>(&adc_id)->required(), "specify ADC board")
			("data_size", po::value<size_t>(&data_size), "Amount of data to read (kB), default 4096kB")
			("block_size", po::value<size_t>(&block_size), "Read data in blocks of this size(kB), default 2048kB")
			("simple_mode", po::bool_switch(&simple_mode), "Run forever and collect statistics.")
			("halbe_mode ", po::bool_switch(&halbe_mode), "Run forever and collect statistics.")
			("statistic_mode", po::bool_switch(&statistic_mode), "Run forever and collect statistics.")
		;

		po::variables_map vm;
		po::store(po::command_line_parser(argc, argv)
						.options(desc)
						.run()
				, vm);

		if (vm.count("help")) {
			std::cout << std::endl << desc << std::endl;
			return 0;
		}
		po::notify(vm);
	}

	if (simple_mode)
	{
		//create the top of the tree
		Vmoduleusb io(usbcomm::note);

		if(io.open(usb_vendorid, usb_deviceid, adc_id)){
			std::cout << "Open failed" << std::endl;
			return -1;
		}
		else {
			std::cout << "Board " << adc_id << " opened" << std::endl;
		}

		//create sp6 class tree
		Vusbmaster usb(&io);
		//usbmaster knows three clients, must be in this order!!!
		Vusbstatus status(&usb);
		Vmemory mem(&usb);
		Vocpfifo ocp(&usb);
		//ocpfifo clients
		Vspiconfrom confrom(&ocp);
		Vspigyro gyro(&ocp);
		Vspiwireless wireless(&ocp);
		std::cout << "Transfering " << data_size << "kB in "
			      << calc_blocks(data_size * 1024, block_size * 1024)
				  << " block(s) of "
				  << calc_words(block_size) << " words." << std::endl;
		size_t errorcnt = memtest(mem, calc_words(data_size), offset, calc_words(block_size));
		std::cout << "Transmission errors: " << errorcnt << std::endl;
		if (errorcnt > 0)
			return -1;
	}
    if (halbe_mode)
	{
		Vmoduleusb io(usbcomm::note, usb_vendorid, usb_deviceid, adc_id);
		std::cout << "Board " << adc_id << " opened" << std::endl;
		Vusbmaster usb(&io);
		Vusbstatus status(&usb);
		Vmemory mem(&usb);
		Vocpfifo ocp(&usb);
		Vmux_board mux_board(&ocp, mux_board_mode(adc_id));
		Vflyspi_adc adc(&ocp);

		// write configuration to adc
		adc.configure(0);
		adc.setup_controller(0, calc_words(data_size),
				0 /* single mode */, 0 /* trigger enable */, 0 /* trigger */);

		const uint32_t startaddr = adc.get_startaddr();
		const uint32_t endaddr   = adc.get_endaddr();
		const uint32_t num_words = endaddr - startaddr;
		if (startaddr != 0 or endaddr != calc_words(data_size))
		{
			std::cout << "Invalid start or end addresses: startaddr="
				      << startaddr << " endaddr=" << endaddr;
			exit(-1);
		}
		std::cout << "Transfering " << num_words << " words in "
			      << calc_blocks(data_size * 1024, block_size * 1024)
				  << " block(s) of "
				  << num_words << " words." << std::endl;
		size_t errorcnt = memtest(mem, num_words, offset, calc_words(block_size));
		std::cout << "Transmission errors: " << errorcnt << std::endl;
		if (errorcnt > 0)
			return -1;
	}
}