diff --git a/NetworkSync.cpp b/NetworkSync.cpp index 4142fea..30b4a06 100644 --- a/NetworkSync.cpp +++ b/NetworkSync.cpp @@ -9,11 +9,14 @@ #include "LinearAlgebra/Angle8.h" #include "LinearAlgebra/Spherical.h" -void NetworkSync::SendVector3(unsigned char *data, unsigned int startIndex, +void NetworkSync::SendVector3(unsigned char *data, unsigned char *startIndex, const Vector3 v) { - SendSingle100(data, startIndex, v.x); - SendSingle100(data, startIndex += 4, v.y); - SendSingle100(data, startIndex += 4, v.z); + SendSingle100(data, *startIndex, v.x); + (*startIndex) += 4; + SendSingle100(data, *startIndex, v.y); + (*startIndex) += 4; + SendSingle100(data, *startIndex, v.z); + (*startIndex) += 4; } void NetworkSync::SendQuaternion(unsigned char *data, const int startIndex, @@ -52,7 +55,7 @@ void NetworkSync::SendSpherical(unsigned char *data, int startIndex, // SendSingle100(data, startIndex += 4, s.distance); // } -void NetworkSync::SendQuat32(unsigned char *data, int startIndex, +void NetworkSync::SendQuat32(unsigned char *data, unsigned char *startIndex, const Quaternion q) { unsigned char qx = (char)(q.x * 127 + 128); unsigned char qy = (char)(q.y * 127 + 128); @@ -65,10 +68,10 @@ void NetworkSync::SendQuat32(unsigned char *data, int startIndex, qw = -qw; } // Serial.printf(" (%d) %d:%d:%d:%d ", startIndex, qx, qy, qz, qw); - data[startIndex++] = qx; - data[startIndex++] = qy; - data[startIndex++] = qz; - data[startIndex++] = qw; + data[(*startIndex)++] = qx; + data[(*startIndex)++] = qy; + data[(*startIndex)++] = qz; + data[(*startIndex)++] = qw; } void NetworkSync::SendAngle8(unsigned char *data, unsigned int startIndex, diff --git a/NetworkSync.h b/NetworkSync.h index 9368d06..096c5b7 100644 --- a/NetworkSync.h +++ b/NetworkSync.h @@ -62,7 +62,7 @@ protected: // const float value); // void SendAngle32(unsigned char *data, unsigned int startIndex, // const float value); - void SendVector3(unsigned char *data, unsigned int startIndex, + void SendVector3(unsigned char *data, unsigned char *startIndex, const Vector3 v); void SendQuaternion(unsigned char *data, const int startIndex, const Quaternion q); @@ -71,7 +71,8 @@ protected: void SendSpherical(unsigned char *data, int startIndex, Spherical s); // void SendSpherical16(unsigned char *data, int startIndex, Spherical s); // void SendSpherical32(unsigned char *data, int startIndex, Spherical s); - void SendQuat32(unsigned char *data, int startIndex, const Quaternion q); + void SendQuat32(unsigned char *data, unsigned char *startIndex, + const Quaternion q); }; } // namespace RoboidControl