Exemplo n.º 1
0
void IVEFStreamHandler::slotConnected() {
    std::cout << QString("iListen connection established logging in as %1").arg( m_user ).toLatin1().data() << std::endl;
    // we are connected, send the login first

    // create a message
    ivef::MSG_IVEF msg;

    // every message has a header
    ivef::Header header;
    header.setMsgRefId(QUuid::createUuid().toString());
    //header.setVersion("1.0");
    msg.setHeader(header);

    // and a body with the request
    ivef::Body body;
    ivef::LoginRequest request;
    request.setName(m_user);
    request.setPassword(m_password);
    request.setEncryption(1); // plain
    body.setLoginRequest(request);
    msg.setBody(body);

    // log
    //std::cout << msg.toXML().toLatin1().data() << std::endl;

    QByteArray data = msg.toXML().toUtf8();
    sendRawData(data);
}
void loop()
{
    // every 100 msecs get new data
    if( loop_cnt > 1 )
    {
        loop_cnt = 0;

        nunchuck_get_data();

        accx  = nunchuck_accelx(); // ranges from approx 70 - 182
        accy  = nunchuck_accely(); // ranges from approx 65 - 173
        zbut = nunchuck_zbutton();
        cbut = nunchuck_cbutton();


        //figure out what area the acc is in
        newPos[0] = map(accx,east,west,0,800);
        newPos[1] = map(accy,south,north,800,0);


        //send absolute positions
        sendRawData();

        //send just the area
        //findArea();
        //if(lastArea != activeArea) sendArea();

    }
    loop_cnt++;
    delay(1);

}
Exemplo n.º 3
0
static int transmitDataBlock(sender_state_t sendst, struct slice *slice, int i)
{
    struct fifo *fifo = sendst->fifo;
    struct net_config *config = sendst->config;
    struct dataBlock msg;
    int size;

    assert(i < MAX_SLICE_SIZE);
    
    msg.opCode  = htons(CMD_DATA);
    msg.sliceNo = htonl(slice->sliceNo);
    msg.blockNo = htons(i);

    msg.reserved = 0;
    msg.reserved2 = 0;
    msg.bytes = htonl(slice->bytes);

    size = slice->bytes - i * config->blockSize;
    if(size < 0)
	size = 0;
    if(size > config->blockSize)
	size = config->blockSize;
    
    sendRawData(sendst->socket, config, 
		(char *) &msg, sizeof(msg),
		fifo->dataBuffer + 
		(slice->base + i * config->blockSize) % fifo->dataBufSize,
		size);
    return 0;
}
Exemplo n.º 4
0
bool Socket::sendRawDataIM(const void *pBuffer,const DWORD size)
{
	LogCheckCondition(pBuffer && size,false,"套接字发送消息失败消息非法");
	
	DWORD offset = 0;
	do
	{
		SWORD retcode = sendRawData(&((char*)pBuffer)[offset],size - offset);
		LogCheckCondition(retcode != -1,false,"套接字发送消息失败");
		offset += retcode;
	}while(offset < size);
	return offset == size;
}
Exemplo n.º 5
0
/**
* \brief 发送指定字节数的原始数据,忽略超时,无限制时间的发送,直到发送完毕或者发送失败
* \param pBuffer 待发送的原始数据
* \param nSize 待发送的原始数据大小
* \return 发送数据是否成功
*/
bool CSocket::sendRawDataIM(const void *pBuffer,const int nSize)
{
	//Zebra::logger->debug("CSocket::sendRawDataIM");
	if (NULL == pBuffer || nSize <= 0)
		return false;
	int retcode = sendRawData(pBuffer,nSize);
	if (-1 == retcode)
	{
		printf("客户端断开 -1\n");  
		return false;
	}
	else
	{
		printf("发送成功\n");
	}
	return true;
}
Exemplo n.º 6
0
/**
 * \brief 发送指定字节数的原始数据,忽略超时,无限制时间的发送,直到发送完毕或者发送失败
 * \param pBuffer 待发送的原始数据
 * \param nSize 待发送的原始数据大小
 * \return 发送数据是否成功
 */
bool zSocket::sendRawDataIM(const void *pBuffer, const int nSize)
{
	//Zebra::logger->trace("zSocket::sendRawDataIM");
	if (NULL == pBuffer || nSize <= 0)
		return false;

	int offset = 0;
	do
	{
		int retcode = sendRawData(&((char *)pBuffer)[offset], nSize - offset);
		if (-1 == retcode)
		{
			return false;
		}
		offset += retcode;
	}
	while(offset < nSize);

	return (offset == nSize);
}
Exemplo n.º 7
0
static int transmitFecBlock(sender_state_t sendst, struct slice *slice, int i)
{
    struct net_config *config = sendst->config;
    struct fecBlock msg;

    /* Do not transmit zero byte FEC blocks if we are not in async mode */
    if(slice->bytes == 0 && !(config->flags & FLAG_ASYNC))
        return 0;
        
    assert(i < config->fec_redundancy * config->fec_stripes);
    
    msg.opCode  = htons(CMD_FEC);
    msg.stripes = htons(config->fec_stripes);
    msg.sliceNo = htonl(slice->sliceNo);
    msg.blockNo = htons(i);
    msg.reserved2 = 0;
    msg.bytes = htonl(slice->bytes);    
    sendRawData(sendst->socket, sendst->config, 
                (char *) &msg, sizeof(msg),
                (slice->fec_data + i * config->blockSize), config->blockSize);
    return 0;
}
void HD7279A::sendCmdAndData(unsigned char cmd, unsigned char data) {
	delayMicroseconds(50);
	sendRawData(cmd);
	delayMicroseconds(20);
	sendRawData(data);
}
void HD7279A::sendCmd(unsigned char cmd) {
	digitalWrite(clkPin, 0);
	delayMicroseconds(50);
	sendRawData(cmd);
}