I was hooking up a serial camera to the spark core last night.
After hours of testing we ended up throwing out the library that was part of the tutorial for the device because it was clearly not working.
So we decided to just use the serial1 library and re write everything from the ground up. Here is our test.
Bare bones test for serial communication:
Serial1.begin(38400); delay(10); uint8_t x; uint8_t y; uint8_t z; uint8_t a; Serial1.write(0x56); Serial1.write(0); Serial1.write(0x11); Serial1.write(0); x = Serial1.read(); y = Serial1.read(); z = Serial1.read(); a = Serial1.read();
Output from above test script.
Results failed: Sent 0x56 0 0x11 0 Response 0x76
Expected results: 0x76 0 0x11 0 ‘data’
We started testing with just variable X. It was being set to 118 = 0x76 in hex. So this was encouraging because we got a response back from the device. No matter what we tried we could not get any more data. Just a Received response. We added multiple serial1.read() set to different variables y, z, a and all the variables get set to 118 .
Serial1.read() does not iterate to the next byte of data in the buffer. It seems to be acting like Serial1.peek() that just views the data in the buffer but does not remove it to.
- Help, Thoughts or explanations would be greatly appreciated.
Communication Protocol format are as follows：
Receive command format：
Protocol sign（1byte）+Serial number（1byte）+Command（1byte）+Data-lengths（1byte）+Data（0~16bytes）
Return command format：
Protocol sign（1byte）+Serial number（1byte）+Command（1byte）+Status（1byte）+Data-lengths（1byte）+Data（0~16bytes）
it marks that the protocol is VC0706 Serial Communication Protocol, the receive
sign is0x56(‘V’), return sign is 0x76(‘v’).
GEN_VERSION 0x11 Get Firmware version information