Esempio n. 1
0
Error NULLVC::send(BYTE *data, int datalen, DWORD notifyKey, int packetType)
{
    BYTE *send_data;
    int send_len;
    BYTE *dataBuffer = getDataBuffer();

    if(!comm_port->GetComm()) // return if comm is not active yet
        return SendError;

    AssertFatal(datalen < MaxPacketSize, "Packet overflow.");
    AssertFatal(datalen == 0 || data, "Bad packet.");

    log_file.log("NULLVC::send type %lx, state %lx",(long)packetType,(long)getState());

    if(!data)
        data = dataBuffer;
    else if(data != dataBuffer)
    {
        memcpy(dataBuffer, data, datalen);
        data = dataBuffer;
    }


    send_data = protocol->prepare_data_for_send(&send_len, data, datalen,
                notifyKey, packetType);

    if( send_data )
        return comm_port->WriteCommString(send_data, send_len);
    else
        return SendError;
}
//
// timeout is in milliseconds()
//
int
ParticleCloud::Post(
    unsigned long timeout
    )
{
    int retVal = 0;
    String buffer = getDataBuffer();

    if (buffer == "") {
        return retVal;
    }

    // Publish a particle event
    Particle.publish("readings", buffer, 60, PUBLIC);

    // Reset the send buffer for a new set of values
    Reset();

    return retVal;
}
Esempio n. 3
0
void OneSideHashJoin::storeInnerNode(void){
	unsigned int hashkey;
	//ONESIDE_HASH_NODE *setNode;
	int returnCode;
	unsigned int dataSize;
	int buffSize = getInnerDataBuffSize();
	char innerDataBuffer[buffSize];

	while(1){
		returnCode = innerOpeNode->getRow(pv, innerAttriNum);
		if(returnCode == -1)break;
		hashkey = 0;
		for(unsigned int i = 0; i < nodeNum; i++)
			hashkey += hashFunc(pv[innerPos[i]]);
		hashkey %= HASH_SIZE;

		//setNode = findSetHashTable(innerHashTable, hashkey, innerPos);
		
		dataSize = getDataBuffer(innerDataBuffer, buffSize, 0 , innerAttriNum);
		innerHash->db->writeRecord(&hashkey, sizeof(hashkey), innerDataBuffer, dataSize, true);
		//setNode->num++;
	}
}
Esempio n. 4
0
/** Data Collection Session**/
void APP_Run(int sel, int collectCount)
{
	//Local variables.
	int16_t x,y,z;
	uint8_t res;
	char* fileName = malloc(sizeof(char)*256);
	extern int collecting;

	/* SD card detection: PTE6 with pull-down! */
	PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);
	PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);

	int color;
	char annotation;
	if(sel == 0)
	{
		color = LED_RED;
		annotation = 'w';
	}
	else if(sel == 1)
	{
		color = LED_YELLOW;
		annotation = 'r';
	}
	else if(sel == 2)
	{
		color = LED_GREEN;
		annotation = 'b';
	}
	else if(sel == 3)
	{
		color = LED_CYAN;
		annotation = 'c';
	}
	else if(sel == 4)
	{
		color = LED_BLUE;
		annotation = 'B';
	}
	else if(sel == 5)
	{
		color = LED_MAGENTA;
		annotation = 't';
	}

	sprintf(fileName, "%d-%c.CSV", collectCount, annotation);

	/* create and open file */
	if (FAT1_open(&fp, fileName, FA_OPEN_ALWAYS|FA_WRITE)!=FR_OK) {
	Err(/*CREATE_FILE_ERROR*/);
	}

	/* closing file */
	(void)FAT1_close(&fp);

	int count = 1;
	DataBuffer* myBuffer = getDataBuffer();
	while(isCollectingData()==1)
	{
		if(myBuffer->currentReadBuffer!=-1)
		{
			LogToFile(myBuffer,annotation,fileName);
		}
		WAIT1_Waitms(2);
	}

	me.currentWriteIndex = 0;
}