示例#1
0
void client_printer()
{
 	Message_t msg, reply;
    int reply_port, status, i, received = 0;
    char * all_strings;

    reply_port = getCurrentThreadId();

    openPort(reply_port);

    msg = (Message_t)malloc(sizeof(struct message));
    reply = (Message_t)malloc(sizeof(struct message));

    srand(getCurrentThreadId());

    while(1)
    {
        if(rand() % 3 == 0)
        {
            createPacket(msg, PRINT, 10, 0);

            printf("\n[Client_on_port_%d]:Sent message:\t", getCurrentThreadId());
            if((status = Send(SERVER_PORT, msg))<0)
            {
                     printf("\n[Client_%d]:Send error",getCurrentThreadId());
                     exit(-1);
            }

            if((status = Receive(reply_port, reply))<0)
            {
                printf("\n[Client_%d]:Receive error",getCurrentThreadId());
                exit(-1);
            }

            all_strings = malloc((reply->total_size) * sizeof(char));

            while(reply->error_code == 1)
            {
                for(i = 0; i < MESSAGE_LENGTH; i++)
                    all_strings[received++] = reply->msg[i];

                if((status = Receive(reply_port, reply))<0)
                {
                    printf("\n[Client_%d]:Receive error",getCurrentThreadId());
                    exit(-1);
                }

            }
			if(reply->error_code != -1)
			{
				i=0;
				while(received < reply->total_size)
					all_strings[received++] = reply->msg[i++];

				printf("Table Entries: \n %s", all_strings);
			}
        }
    }

}
u16 mip_sdk_port_open(void **port_handle, int port_num, int baudrate)
{
  s32 ret;
  *port_handle = malloc(sizeof(struct serial_fd));
  struct serial_fd* sfd = (struct serial_fd*)*port_handle;

  sfd->pBuffer = (u8*)malloc(sizeof(u8) * MAX_BUFFER_SIZE);
  sfd->position = 0;
  sfd->size = 0;
  sfd->state = STATE_WAITING_ON_FD;
  sfd->portNumber = port_num;
  sfd->baudrate = baudrate;

  memset(sfd->pBuffer, 0, sizeof(u8) * MAX_BUFFER_SIZE);

  ret = -1;
  while ((ret = openPort(sfd)) < 0)
  {
    sleep(1);
  }

  printf("Opened serial port\n");

  return MIP_USER_FUNCTION_OK;
}
  //---------------------------------------------------------------------------
  // receives only one character
  bool Serial::receive( char & c )
  {

    if ( !isPortOpened_ )
    {
      if ( !openPort() )
      {
        // some error occured by opening port
        return false;
      }
    }

    int numberOfBytes;
    numberOfBytes =::read( descriptor_, & c, 1 );

    if ( numberOfBytes == 1 )
    {
      return true;
    }
    else
    {
      setStatusString( "error: could not receive the character" );
      return false;
    }
  }
示例#4
0
int main(int argc, char *argv[]) {
	int i,j,k,portFD;
	unsigned char data[1024];

	gettimeofday(&tStart,NULL);

	output(1,"HP iPAQ 214 BT chip GPIO twiddling util v1.1\n----------------------------------\n");

#ifndef NOIO
	gpioInit(1);
#else
	output(1,"TESTING MODE - NOT USING IO\n");
#endif
	
	if(argc > 1 && strcmp(argv[1],"on")==0){
		portFD=openPort();
		if(portFD == -1){ return 0; }

		output(1,"Shutting down chip first...\n");
#ifndef NOIO
		shutdownChip();
		tcflush(portFD, TCIOFLUSH); //flush buffers again
#endif
		output(1,"Waiting 2 secs.\n");
		sleep(2);

		output(1,"Bringing up chip...\n");
		bringUpChip();

		output(1,"Resetting chip...\n");
#ifndef NOIO
		sendReset(portFD);	
#endif

		output(1,"Turning LED on.\n");
#ifndef NOIO
		gpioSet(3,1);
#endif
	
		output(1,"closing port...");	fflush(stdout);
		close(portFD);
		output(1,"done\n");

	}else if(argc > 1 && strcmp(argv[1],"off")==0){
		output(1,"Shutting down chip...\n");
#ifndef NOIO
		shutdownChip();
		gpioSet(3,0);	//turn LED off
#endif
	
	}else
		printf("usage %s on/off\n",argv[0]);
	
	
#ifndef NOIO
	gpioCleanup();
#endif
	
	return 0;
}
/*****指纹收集构造函数******/
Finger_Gather::Finger_Gather(QObject *parent) :
    QObject(parent)
{
    globalData = GlobalData::getGlobalData();

   // usbComTool = new UsbComTool;
   // usbComTool->GetUsbCom();

    QVector<QString>::size_type size;
   //const char **temp_finger = usbComTool->GetComNameFromFile(size);
   qDebug()<<"size:"<<size;
    //qDebug()<<"data"<<temp_finger[0];
  // fprintf(stderr,"data0:%s\n",temp_finger[0]);
 //  fprintf(stderr,"data1:%s\n",temp_finger[1]);
 //  fprintf(stderr,"data2:%s\n",temp_finger[2]);

    if ( ( fd = openPort( FINGER_COM,0) ) < 0 )
  // if((fd = usbComTool->dynamicOpenPort(temp_finger ,size-1 , size))<0)
    {      //打开串口,如果打开失败,会返回-1
        qDebug() << "Open Finger Serial port failed";

    }

    if (setComConfig( fd , 57600 , 8 , 'N' , 1 ) < 0 ){//打开端口错误,返回-1
        qDebug() << "Set COM failed";

    }
}
示例#6
0
文件: ofxMidiIn.cpp 项目: wandp/RGB
// --------------------------------------------------------------------------------------
void ofxMidiIn::openPort(string _deviceName){
	if ( nPorts == 0 ) {
		ofLogError() << "No ports available!";
		return;
	}
	
	// Iterate through MIDI ports, find requested devices
	bool foundDevice = false;
	int _port;
	for(unsigned int i=0; i < nPorts; ++i){
		string portName = portNames[i].c_str();
		if(portName.compare(_deviceName) == 0) {
			foundDevice = true;
			_port = i;
		}
	}
	if(!foundDevice) {
		// if not found
		ofLogError() << "The selected port is not available";
		return;
	}
	
	openPort( _port );	
	
}
示例#7
0
void testShell()
{
	int fd, i, byte ;
	const char *microKeyer = "/dev/cu.usbserial-M2Q5BDJC" ;
	unsigned char split[] = { 0x0, 0x0, 0x0, 0x1, 0x1 } ;
	unsigned char vfoData[] = { 0x0, 0x0, 0x0, 0x3, 0x10 } ;
	
	fd = openPort( microKeyer ) ;
	if ( fd < 0 ) {
		printf( "cannot open microKeyer %s\n", microKeyer ) ;
		return ;
	}
	
	setRadio1Params( fd, 4800, 2, 8 ) ;			//  set radio baud rate
	sleep( 1 ) ;
	writeRadioBuffer( fd, 0, split, 5 ) ;		//  set split mode
	sleep( 1 ) ;
	writeRadioBuffer( fd, 0, vfoData, 5 ) ;		//  get VFO A and B data (should get 32 bytes back)
	
	//  read from Radio 1 until timed out
	for ( i = 0; i < 64; i++ ) {
		byte = getRadio( fd, 0 ) ;
		if ( byte < 0 ) break ;
		printf( "read byte %2d: 0x%02x\n", i, byte ) ;
	}
	
	close( fd ) ;
}
示例#8
0
	//------------------------------------------------------------------------------------------------------------------
	SerialWin32::SerialWin32(const char* _port, unsigned _baudRate){
		// Enforce correct data
		assert(nullptr != _port && '\0' != _port[0]);

		openPort(_port);
		setBaudRate(_baudRate);
	}
示例#9
0
depthProbe::depthProbe(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::depthProbe)
{
    ui->setupUi(this);
#ifdef DISCONNECTED
    zeroed = true;
#else
    zeroed=false;
#endif
    connect(ui->btnOpenFile,SIGNAL(clicked()),this,SLOT(openFile()));
    connect(ui->btnOpenPort,SIGNAL(clicked()),this,SLOT(openPort()));
    connect(ui->btnBegin,SIGNAL(clicked()),this,SLOT(Run()));
    connect(ui->btnZero,SIGNAL(clicked()),this,SLOT(Zero()));
#ifdef DEBUG
    connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(button()));
    ui->pushButton->setVisible(true);
#else
    ui->pushButton->setVisible(false);
#endif
    portOpen = false;
#ifdef Q_WS_X11
    ui->cmbPort->addItem("USB0");
    ui->cmbPort->addItem("USB1");
    ui->cmbPort->addItem("USB2");
    ui->cmbPort->addItem("USB3");
    ui->cmbPort->addItem("USB4");
    ui->cmbPort->addItem("USB5");
    ui->cmbPort->addItem("ACM0");
    ui->cmbPort->addItem("ACM1");
    ui->cmbPort->addItem("ACM2");
    ui->cmbPort->addItem("ACM3");
    ui->cmbPort->addItem("ACM4");
    ui->cmbPort->addItem("ACM5");
#ifdef DEBUG
    ui->cmbPort->setCurrentIndex(6);
#endif
#else
    ui->cmbPort->addItem("COM1");
    ui->cmbPort->addItem("COM2");
    ui->cmbPort->addItem("COM3");
    ui->cmbPort->addItem("COM4");
    ui->cmbPort->addItem("COM5");
    ui->cmbPort->addItem("COM6");
    ui->cmbPort->addItem("COM7");
    ui->cmbPort->addItem("COM8");
    ui->cmbPort->addItem("COM9");
    ui->cmbPort->addItem("COM10");
    ui->cmbPort->addItem("COM11");
    ui->cmbPort->addItem("COM12");
    ui->cmbPort->addItem("COM13");
    ui->cmbPort->addItem("COM14");
    ui->cmbPort->addItem("COM15");
    ui->cmbPort->addItem("COM16");
#ifdef DEBUG
    ui->cmbPort->setCurrentIndex(11);
#endif
#endif
    styleSheet = ui->btnOpenPort->styleSheet();
}
示例#10
0
/**
 * Constructor
 * @param mode the starting mode of Create
 * @param serialDevice the string name of serial port device, e.g. /dev/ttyUSB0
 * @param baudRate an integer representing the baudRate of the serial communication
 */
Create::Create(Mode mode, const std::string &serialDevice, int baudRate) {

	this->serialDevice = serialDevice;
	this->baudRate = baudRate;
	openPort();
	initialize(mode);
}
示例#11
0
文件: SerialPort.cpp 项目: at15/kc2b
bool CSerialPort::InitPort( UINT portNo ,const LPDCB& plDCB )
{
	/** 打开指定串口,该函数内部已经有临界区保护,上面请不要加保护 */ 
	if (!openPort(portNo))
	{
		return false;
	}
	
	/** 进入临界段 */ 
	EnterCriticalSection(&m_csCommunicationSync);

	/** 配置串口参数 */ 
	if (!SetCommState(m_hComm, plDCB))
	{
		return false;
	}

	/**  清空串口缓冲区 */
	PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);

	/** 离开临界段 */ 
	LeaveCriticalSection(&m_csCommunicationSync);

	return true;
}
示例#12
0
void MainWindow::serialconnect()
{
    //Hust to be safe - wipe all the user commands
    emit flushInjectionBuffer();

    if(!opened)
    {
        //Find the portinfo we need
        foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        {
            if(info.portName() == ui->serialBox->currentText())
            {
                printerinfo = info;
                break;
            }
        }

        //Emit signals needed
        emit setBaudrate(ui->baudbox->currentText().toInt());
        emit openPort(printerinfo);
        //Set the flag right
        opened=true;
        //Update UI
        ui->connectBtn->setText("Disconnect");
        ui->sendBtn->setDisabled(false);
        ui->progressBar->setValue(0);
        ui->controlBox->setDisabled(false);
        ui->consoleGroup->setDisabled(false);
        ui->statusGroup->setDisabled(false);
        ui->actionPrint_from_SD->setEnabled(true);
        ui->actionSet_SD_printing_mode->setEnabled(true);
        if(firmware == Repetier) ui->actionEEPROM_editor->setDisabled(false);
    }
示例#13
0
/*! Init the WMV bus client
 *  \param addr The clients address
 *  \param dev The device name of the attached communication interface, for example COM? in windows or /dev/ttyUSB? for Linux
 *  \param listener A pointer to a function which should be called when there is a message to be parsed from the bus
 *  \return 0 if the port was open sucessfully, 1 if not */
int WMVBusClient::initClient(unsigned char addr, QString dev, BusMessageListener *listener) {
  busAddr = addr;
  deviceName = dev;
  msgListener = listener;

  return(openPort(deviceName));
}
示例#14
0
// Writes image data to a file on the non-temporary storage (ie. HDD or flash
// memory) of the device running this sofware.
void* writeImageContentToFile(void* args)
{
	struct threadArgs* 	inputs = (struct threadArgs*)args;
	int 				nodeCtr = 0;
	struct lstnode* 	node = inputs->cNode;
	pthread_mutex_t* 	mutex = inputs->mutex;
	free(args);
	int fd = openPort(); 		        // open the serial port
	while(TRUE)
	{
		byte* buf = (byte*)malloc(6); // allocate buffer for meta data
		if(read(fd, buf, 6) == 6) // read meta data
		{
			pthread_mutex_lock(mutex); // lock so other thread can't change ptrs
			printf("Received: %s\n", buf);
			struct telpkt* tp = decode(buf, 5); // create telemetry pkt
			if(node->size > 0) node = writeDataToSerial(tp, fd, node, nodeCtr);
			free(tp);
			pthread_mutex_unlock(mutex);
		}
		free(buf);
	}
	free(inputs);
	pthread_exit(NULL);
}
示例#15
0
QespTest::QespTest(QWidget *parent)
    : QWidget(parent)

{
    //modify the port settings on your own
#ifdef Q_OS_UNIX
    port = new QextSerialPort(QLatin1String("/dev/ttyS0"), QextSerialPort::Polling);
#else
    port = new QextSerialPort(QLatin1String("COM1"), QextSerialPort::Polling);
#endif /*Q_OS_UNIX*/
    port->setBaudRate(BAUD19200);
    port->setFlowControl(FLOW_OFF);
    port->setParity(PAR_NONE);
    port->setDataBits(DATA_8);
    port->setStopBits(STOP_2);
    //set timeouts to 500 ms
    port->setTimeout(500);

    message = new QLineEdit(this);

    // transmit receive
    QPushButton *transmitButton = new QPushButton(tr("Transmit"));
    connect(transmitButton, SIGNAL(clicked()), SLOT(transmitMsg()));
    QPushButton *receiveButton = new QPushButton(tr("Receive"));
    connect(receiveButton, SIGNAL(clicked()), SLOT(receiveMsg()));
    QHBoxLayout *trLayout = new QHBoxLayout;
    trLayout->addWidget(transmitButton);
    trLayout->addWidget(receiveButton);

    //CR LF
    QPushButton *CRButton = new QPushButton(tr("CR"));
    connect(CRButton, SIGNAL(clicked()), SLOT(appendCR()));
    QPushButton *LFButton = new QPushButton(tr("LF"));
    connect(LFButton, SIGNAL(clicked()), SLOT(appendLF()));
    QHBoxLayout *crlfLayout = new QHBoxLayout;
    crlfLayout->addWidget(CRButton);
    crlfLayout->addWidget(LFButton);

    //open close
    QPushButton *openButton = new QPushButton(tr("Open"));
    connect(openButton, SIGNAL(clicked()), SLOT(openPort()));
    QPushButton *closeButton = new QPushButton(tr("Close"));
    connect(closeButton, SIGNAL(clicked()), SLOT(closePort()));
    QHBoxLayout *ocLayout = new QHBoxLayout;
    ocLayout->addWidget(openButton);
    ocLayout->addWidget(closeButton);

    received_msg = new QTextEdit();

    QVBoxLayout *myVBox = new QVBoxLayout;
    myVBox->addWidget(message);
    myVBox->addLayout(crlfLayout);
    myVBox->addLayout(trLayout);
    myVBox->addLayout(ocLayout);
    myVBox->addWidget(received_msg);
    setLayout(myVBox);

    qDebug("isOpen : %d", port->isOpen());
}
示例#16
0
HttpSocket::HttpSocket(const QString &iface, quint16 port)
    : QTcpServer(nullptr)
    , cfgInterface(iface)
    , terminated(false)
{
    if (!openPort(port)) {
        openPort(0);
    }

    DBUG << isListening() << serverPort();

    connect(MPDConnection::self(), SIGNAL(socketAddress(QString)), this, SLOT(mpdAddress(QString)));
    connect(MPDConnection::self(), SIGNAL(cantataStreams(QList<Song>,bool)), this, SLOT(cantataStreams(QList<Song>,bool)));
    connect(MPDConnection::self(), SIGNAL(cantataStreams(QStringList)), this, SLOT(cantataStreams(QStringList)));
    connect(MPDConnection::self(), SIGNAL(removedIds(QSet<qint32>)), this, SLOT(removedIds(QSet<qint32>)));
    connect(this, SIGNAL(newConnection()), SLOT(handleNewConnection()));
}
void Communication::sendData(const QByteArray data){
    if(!serial->isOpen()){
        openPort();
    }

    int sentSize= 0;
    sentSize = serial->write(data);
    qDebug() << "Sent: " << QString(data) << " size" << sentSize;
}
示例#18
0
bool SerialPort::verifyFreeEMS(QString portname)
{
	openPort(portname,115200,false);
	unsigned char ret = 0x0D;
	int writei =0;
#ifdef Q_OS_WIN32
	::WriteFile(m_portHandle, (void*)&ret, (DWORD)1, (LPDWORD)&writei, NULL);
#else
	writei = write(m_portHandle,&ret,1);
#endif
	if (writei <= 0)
	{
		qDebug() << "Error writing to verify FreeEMS";
		return false;
	}
	unsigned char buf[3];
#ifdef Q_OS_WIN32
	Sleep(100);
#else
	usleep(100000);
#endif
	//msleep(100);
	int count = 0;
#ifdef Q_OS_WIN32
	::ReadFile(m_portHandle,(LPVOID)buf,3,(LPDWORD)&count,NULL);
#else
	count = read(m_portHandle,buf,3);
#endif
	if (count > 0)
	{
		qDebug() << "Verify:" << QString::number(buf[0],16);
		qDebug() << "Verify:" << QString::number(buf[1],16);
		if (buf[0] == 0xE0 || buf[0] == 0xE1)
		{
			if (count > 1)
			{
				qDebug() << "Verify:" << QString::number(buf[2],16);
				if (buf[2] == 0x3E)
				{
					//Serial monitor running
					closePort();
					return false;
				}
				else
				{
					//Probably not;
					closePort();
					return true;
				}
			}
		}
	}
	//nothing on the port here either.
	closePort();
	return true;
}
示例#19
0
int init_serial(void){
	serial_fd = openPort(0);
	if(serial_fd < 0)
	{
		printf("serial open error.\n");
		exit(0);
	}
	//fd,115200, 
	setPara(serial_fd,6,8,1,0);
}
示例#20
0
bool commonPort::initialise( const PortConfig & /*port*/, commonController &mon )
{
   if ( initialisePort() && openPort() )
   {
      mon.portChain.push_back( this );
      monitor = &mon;
      return true;
   }
   return false;
}
void MdQextSerialCom::togglePort()
{
    if ( port ) {
        if ( port->isOpen() )
            closePort();
        else {
            openPort();
        }
    } else {
        setupPort();
    }
}
u32 mip_sdk_port_read_count(void *port_handle)
{
  fd_set rdfs;
  struct timeval timeout;

  if(port_handle == NULL)
  {
    printf("mip_sdk_read_count error: handle is null\n");
    return MIP_USER_FUNCTION_ERROR;
  }

  struct serial_fd* fd = (struct serial_fd*)port_handle;

  if (fd->state == STATE_WAITING_ON_FD)
  {
    openPort(fd);
  }
  else if (fd->size < MAX_BUFFER_SIZE)
  {
    FD_ZERO(&rdfs);
    FD_SET(fd->fd, &rdfs);

    timeout.tv_sec = 0;
    timeout.tv_usec = 10000;

    if (select(fd->fd+1, &rdfs, NULL, NULL, &timeout) > 0)
    {
      u32 i;

      //move the bytes down
      for (i = 0; i < fd->size && fd->position > 0; i++)
      {
        fd->pBuffer[i] = fd->pBuffer[fd->position + i];
      }
      fd->position = 0;

      size_t bytesRead = read(fd->fd, &fd->pBuffer[fd->size], MAX_BUFFER_SIZE - fd->size);

      if (bytesRead > 0)
      {
        fd->size += bytesRead;
        //printf("read_count: buffer size is %u\n", fd->size);
      }
      else
      {
        tempClosePort(fd);
      }
    }
  }

  return fd->size;
}
示例#23
0
/*!
  @param aDevName [in] Serial port device file name
  @return Sesnor's communication handler
  Returns NULL if failed
*/
tPort* scipConnect(char *aDevName)
{
  tPort *port;
  int ret;

  fprintf(stdout,"Connecting at 19200 bps ...\n");
  port=openPort(aDevName,19200);
  ret=scipTryComm(port);
  switch(ret){
    case 1:
    case 2:
      fprintf(stdout,"Connected at 19200 bps\n\n");
      return port;
    default:
      fprintf(stdout,"Could not connect at 19200 bps\n\n");
      break;
  }

  fprintf(stdout,"Connecting at 57600 bps ...\n");
  if(setupPort(fileno(port->dev),57600)!=EXIT_SUCCESS){
    perror("Could not set terminal parameters ");
    return NULL;
  }
  ret=scipTryComm(port);
  switch(ret){
    case 1:
    case 2:
      fprintf(stdout,"Connected at 57600 bps\n\n");
      return port;
    default:
      fprintf(stdout,"Could not connect at 57600 bps\n\n");
      break;
  }

  fprintf(stdout,"Connecting at 115200 bps ...\n");
  if(setupPort(fileno(port->dev),115200)!=EXIT_SUCCESS){
    perror("Could not set terminal parameters ");
    return NULL;
  }
  ret=scipTryComm(port);
  switch(ret){
    case 1:
    case 2:
      fprintf(stdout,"Connected at 115200 bps\n\n");
      return port;
    default:
      fprintf(stdout,"Could not connect at 115200 bps\n\n");
      break;
  }

  return NULL;
}
int SerialPortOpenPortNamed(char *portName, int baudRate) {
	int portNum;
	int n = strlen(portName);
	if ((n < 4) || (n > 5)) return PRIM_FAILED;
	// assume portName is: COM<num>, where <num> is or two decimal digits
	if (digitValue(portName[3]) < 0) return PRIM_FAILED;
	portNum = digitValue(portName[3]);
	if (n == 5) {
		if (digitValue(portName[4]) < 0) return PRIM_FAILED;
		portNum = (10 * portNum) + digitValue(portName[4]);
	}
	return openPort(portNum, baudRate);
}
void Communication::on_stateCounterChanged(int value)
{
    if(value > 2){
        emit connectionLost(true);
        ///when connection is lost, try opening port
        /// after informing the user.
        openPort();
    }

    if(value == 0){
        emit connectionLost(false);
    }
}
示例#26
0
int PosixSerial::initializePort()
{
    if(fd_ == -1) {
        if(openPort() == CROI_ERROR) {
            return CROI_ERROR;
        }
        if(configurePort() == CROI_ERROR) {
            return CROI_ERROR;
        }
    }
    initialized_ = true;
    return CROI_SUCCESS;
}
示例#27
0
/* static */ vrpn_Atmel *
vrpn_Atmel::Create(char* name, vrpn_Connection *c, 
                    char *port, long baud,
		    int channel_count ,
		    int * channel_mode)
{	
  int fd;

#ifdef VRPN_ATMEL_SERIAL_VRPN

  if ( (fd=vrpn_open_commport(port, baud)) == -1) {
    
    fprintf(stderr,"vrpn_Atmel: can't Open serial port\n");
  
    return NULL; 
  }
#else
  // Open the serial port
  if ( (fd=openPort(port, baud, &init_params)) == -1) {
    
    fprintf(stderr,"vrpn_Atmel: can't Open serial port\n");
  
    return NULL; 
  }
  
  // look if the atmel is connected
  if (! check_serial(fd) ) { 

    return NULL; 
  }
#endif 
 
  vrpn_Atmel * self = new vrpn_Atmel(name, c, fd);
      
  if ( (self->vrpn_Analog_Server::setNumChannels(channel_count) != channel_count) 
     || (self->vrpn_Analog_Output_Server::setNumChannels(channel_count) != channel_count) ) {
  
      fprintf(stderr,"vrpn_Atmel: the requested number of channels is not available\n");
      delete self;

      return NULL;
  }
  

  // init the channels based on the infos given from the config file
  self->init_channel_mode(channel_mode);
 
  self->_status = VRPN_ATMEL_STATUS_WAITING_FOR_CONNECTION; 

  return self;
}
示例#28
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  initSockets
 *  Description:  This function blocks the system until all connections are established
 * =====================================================================================
 */
void *initSockets(  ) {
    int i;

    for ( i = 0; i < g_num_players; i++ ) {
        openPort( g_players[i].port, &g_players[i].socket, &g_players[i].newsocket );
        g_players[i].connected = 1;
        glutPostRedisplay( );
    }

    /* Uncoment this if you want to start right away after all players are connected */
    startGame( );

    return NULL;
}
示例#29
0
 bool NqDVL::start(bool debug)
 {
   _debug = debug;
   openPort();
   if(isOpen())
     {
       ros::NodeHandle n;
       _timer = n.createTimer(ros::Duration(1.0/_freq),&NqDVL::timerCallBack,this);
     }
   else
     {
       return false;
     }
 }
示例#30
0
void MainWindow::slot_send()
{
        if (openPort())
    {
        //senddata += "\x0D";      //加结束标志
        //senddata += "\x0A";
        //QByteArray temp(senddata.toUtf8()); //带编码
         QByteArray temp(aaaaaaa.toUtf8()); //带编码
        serialPort->sendData(temp);
        //serialPort->sendData("I Love you");
        qDebug()<<" SendSuccess!baby!";
    }
       else emit SerialPortFail();
   }