Created
October 25, 2014 05:12
-
-
Save elfgoh/f9b478a3f3e6db804fb3 to your computer and use it in GitHub Desktop.
VC0706 library verify method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint8_t VC0706::_verify(uint8_t cmd) | |
| { | |
| if((vcBuff[VC0706_PTL_BYTE] != VC0706_RECV_MARK) || | |
| (vcBuff[VC0706_SERIAL_BYTE] != VC0706_SERIAL_NUMBER)){ | |
| DBG("return format error\n"); | |
| return RESP_DATA_FORMAT_ERROR; | |
| } | |
| if(vcBuff[VC0706_CMD_BYTE] != cmd){ | |
| DBG("return command error\n"); | |
| return RESP_DATA_CMD_ERROR; | |
| } | |
| return vcBuff[VC0706_STATUS_BYTE]; // 0 is OK, other is NG | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So
vcBuffis the receive buffer from the UART communications.When you do a
_read(num, ...)you try to read those many bytes over the UART bus. The_read()function probably returns the number of bytes successfully read from the UART bus. Those bytes are stored in yourvcBuffarray. Since this is arduino everything is global. Yay!!If the comms are happening correctly
vcBuffshould contain a bunch of bytes based on this protocol. http://www.adafruit.com/datasheets/VC0706protocol.pdf. But if you look through, the first byte after the serial number always identifies the command._verifyfunction basically checks a couple of things.(vcBuff[VC0706_PTL_BYTE] != VC0706_RECV_MARK)vcBuff[VC0706_SERIAL_BYTE] != VC0706_SERIAL_NUMBER)vcBuff[VC0706_CMD_BYTE] != cmd