Quantcast
Channel: arm - openFrameworks
Viewing all articles
Browse latest Browse all 147

ofxTCPServer slow on raspberry pi 3

$
0
0

@bendylegs wrote:

As soon as I put the below in to either my update or draw loop my frame rate halves. I can send and receive fine on the client end but the pi that acts as the server experiences a drastic slow down in framerate. Top indicates low cpu use so I’m stumped…


if( !initialised ) return;
	//cout << "tcp draw called" << endl;
	for ( int i = 0; i < TCPServer.getLastID(); i++ ) {
		if(TCPServer.isClientConnected(i)) {

    		std::string str = TCPServer.receive(i); // will end with delimiter, so make sure client is sending it
    		if( str.length() > 0 ){
    			ofLog(OF_LOG_NOTICE) << "received  " << str << " on TCPServer from " << i;

				auto payload = ofJson::parse(str);

				DataPacket packet;

				packet.numbersInt.push_back( payload["screen"] );
				packet.numbersFloat.push_back( payload["x"] );
				packet.numbersFloat.push_back( payload["y"] );
				packet.numbersFloat.push_back( payload["vx"] );
				packet.numbersFloat.push_back( payload["vy"] );

				ofNotifyEvent( newDataEvent, packet, this );
    		} else {
    			ofLog(OF_LOG_NOTICE) << "!! received empty?? " << str << " on TCPServer from " << i;
    		}

The slow down isn’t immediate but occurs in the first few seconds then stays.

I get a lot of empty strings received which I guess just indicates the connection is still open? I’d assumed I should leave it open as I send things fairly regularly.

Context I’m sending a load of boids between screens and using OSC/UDP too many packets went missing over time and I was loosing birds.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 147

Trending Articles