![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Cubic Hand project for EECS 249A course.
Dependencies: MMA8451Q TSI cc3000_hostdriver_mbedsocket NVIC_set_all_priorities mbed Multi_WS2811
Diff: DataGlove.cpp
- Revision:
- 15:b48ac00af0b8
- Parent:
- 14:0c4a26dc6873
- Child:
- 18:6737bf53ccd1
--- 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()