Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed
Fork of CubicHand by
Diff: DataGlove.cpp
- Revision:
- 15:b48ac00af0b8
- Parent:
- 14:0c4a26dc6873
- Child:
- 18:6737bf53ccd1
diff -r 0c4a26dc6873 -r b48ac00af0b8 DataGlove.cpp
--- a/DataGlove.cpp Sun Dec 07 19:50:47 2014 +0000
+++ b/DataGlove.cpp Sun Dec 07 21:49:33 2014 +0000
@@ -21,6 +21,11 @@
{
GloveSocket.Init();
GloveSocket.Connect();
+ StreamData();
+}
+
+void DataGlove::StreamData()
+{
SendBuf[0] = '$';
SendBuf[1] = 0x0A;
SendBuf[2] = 0x03;
@@ -33,20 +38,8 @@
void DataGlove::Receive()
{
- uint8_t *Buf, *buffer;
- int8_t numReceived;
- bool raw = false;
- unsigned char bcc;
- int pkglen, u;
- int timeOfArrival, id, pkgtype;
- int j, k, y;
- double roll, yaw, pitch;
- double norm, test;
- int q0, q1, q2, q3;
- double q00, q11, q22, q33;
- printf("beginning of receive\r\n");
+ raw = false;
numReceived = GloveSocket.GetDataFromBuffer(Buf, 1);
- printf("received %d bytes\r\n", numReceived);
if (Buf[0] == '$') {
bcc = '$';
numReceived = GloveSocket.GetDataFromBuffer(Buf, 2);
@@ -222,19 +215,16 @@
}
}
else {
- printf("couldn't get data %d\r\n", notConnectedCount);
+ //printf("couldn't get data %d\r\n", notConnectedCount);
notConnectedCount++;
}
- printf("just before re-establishing connection\r\n");
// Re-establishing communication in case no data is received for 1s (20 frames per second*1 = 20)
if (notConnectedCount > 20) {
printf("Connection broke! Trying to re-establish...\r\n");
- GloveSocket.Disconnect();
- printf("Disconnected wifi\r\n");
+ GloveSocket.Reconnect();
+ StreamData();
notConnectedCount = 0;
- GloveSocket.Connect();
}
- wait(0.1);
}
void DataGlove::Parse()
