This commit is contained in:
workinghard
2015-06-30 07:43:39 -07:00
parent 10f9926cf4
commit 44041e9818
3 changed files with 16 additions and 16 deletions

View File

@@ -31,6 +31,8 @@
//using Poco::Net::SocketAddress; //using Poco::Net::SocketAddress;
//using Poco::Exception; //using Poco::Exception;
TCPConnector* connector;
unsigned char buffer3D[64]; unsigned char buffer3D[64];
unsigned char receiveBuffer[32]; unsigned char receiveBuffer[32];
int bytesReceived; int bytesReceived;
@@ -114,7 +116,7 @@ void msgCloseFrameStream() {
if (stream) { if (stream) {
buffer3D[0] = 's'; buffer3D[0] = 's';
buffer3D[1] = 'S'; buffer3D[1] = 'S';
stream->send(buffer3D, 2); // End the stream mode stream->send(reinterpret_cast<const char*>(buffer3D), 2); // End the stream mode
} }
} }
@@ -129,7 +131,7 @@ void msgOpenFrameStream() {
buffer3D[6] = 'S'; buffer3D[6] = 'S';
buffer3D[7] = 's'; buffer3D[7] = 's';
buffer3D[8] = ' '; buffer3D[8] = ' ';
stream->send(buffer3D, 9); stream->send(reinterpret_cast<const char*>(buffer3D), 9);
} }
} }
@@ -157,7 +159,7 @@ void msgStartWrite(u_int32_t msgLength) {
printf("2: %u\n", myBuffer[2]); printf("2: %u\n", myBuffer[2]);
printf("3: %u\n", myBuffer[3]); printf("3: %u\n", myBuffer[3]);
stream->send(buffer3D, 13); stream->send(reinterpret_cast<const char*>(buffer3D), 13);
} }
} }
@@ -190,7 +192,7 @@ void testFrame() {
buffer3D[60]=254; buffer3D[60]=254;
buffer3D[63]=254; buffer3D[63]=254;
} }
stream->send(buffer3D, 64); stream->send(reinterpret_cast<const char*>(buffer3D), 64);
} }
@@ -206,7 +208,7 @@ void testStream2() {
buffer3D[i] = 255; // Aus buffer3D[i] = 255; // Aus
} }
} }
stream->send(buffer3D, 64); stream->send(reinterpret_cast<const char*>(buffer3D), 64);
sleepcp(1000); // 20 FPS sleepcp(1000); // 20 FPS
if ( frameChange < 2 ) { if ( frameChange < 2 ) {
frameChange++; frameChange++;
@@ -228,7 +230,7 @@ void CubeNetwork::sendBytes(const unsigned char* byteBuffer, unsigned int byteLe
if ( byteBuffer != NULL ) { if ( byteBuffer != NULL ) {
// let arduino knows what to expect // let arduino knows what to expect
msgStartWrite(byteLength); msgStartWrite(byteLength);
unsigned char myBuffer[4]; char myBuffer[4];
int ret = stream->receive(myBuffer,4); int ret = stream->receive(myBuffer,4);
printf("received Length:\n"); printf("received Length:\n");
printf("0: %u\n", myBuffer[0]); printf("0: %u\n", myBuffer[0]);
@@ -238,7 +240,7 @@ void CubeNetwork::sendBytes(const unsigned char* byteBuffer, unsigned int byteLe
printf("ret: %u\n", ret); printf("ret: %u\n", ret);
// send bytes to write // send bytes to write
stream->send(byteBuffer, byteLength); stream->send(reinterpret_cast<const char*>(byteBuffer), byteLength);
// Reset to the frameStream mode // Reset to the frameStream mode
if ( streamMode == 2 ) { if ( streamMode == 2 ) {
msgOpenFrameStream(); msgOpenFrameStream();
@@ -258,7 +260,7 @@ void CubeNetwork::updateFrame(const unsigned char * frameSequence, unsigned int
buffer3D[i] = frameSequence[i+((frameCount-1)*64)]; buffer3D[i] = frameSequence[i+((frameCount-1)*64)];
} }
// Send the frame // Send the frame
stream->send(buffer3D, 64); stream->send(reinterpret_cast<const char*>(buffer3D), 64);
} }
} }

View File

@@ -22,11 +22,11 @@
#define __Cube4Fun__CubeNetwork__ #define __Cube4Fun__CubeNetwork__
#include <iostream> #include <iostream>
#include "Poco/Foundation.h" //#include "Poco/Foundation.h"
#include "Poco/Net/SocketAddress.h" //#include "Poco/Net/SocketAddress.h"
#include "Poco/Net/DialogSocket.h" //#include "Poco/Net/DialogSocket.h"
#include "Poco/Net/NetException.h" //#include "Poco/Net/NetException.h"
#include "Poco/Exception.h" //#include "Poco/Exception.h"
#include <stdlib.h> /* srand, rand */ #include <stdlib.h> /* srand, rand */
#include <time.h> /* time */ #include <time.h> /* time */
#include <chrono> #include <chrono>
@@ -43,8 +43,6 @@ public:
static bool openConnection(const char* ipAddr, unsigned int port); static bool openConnection(const char* ipAddr, unsigned int port);
//static void openConnection(); //static void openConnection();
static void closeConnection(); static void closeConnection();
private:
static TCPConnector* connector;
}; };
#endif /* defined(__Cube4Fun__CubeNetwork__) */ #endif /* defined(__Cube4Fun__CubeNetwork__) */

View File

@@ -26,4 +26,4 @@
+ (bool) openConnection: (const char *) ipAddress port: (UInt32) port; + (bool) openConnection: (const char *) ipAddress port: (UInt32) port;
+ (void) closeConnection; + (void) closeConnection;
+ (bool) connected; + (bool) connected;
@end @end