mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
unify the style rxbytes are assembled & remove the need for a tmp-buffer
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3131 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
23ab893f38
commit
c9f9400d75
@ -242,7 +242,6 @@ static int32_t objectTransaction(UAVObjHandle obj, uint16_t instId, uint8_t type
|
|||||||
*/
|
*/
|
||||||
int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
||||||
{
|
{
|
||||||
static uint8_t tmpBuffer[4];
|
|
||||||
static UAVObjHandle obj;
|
static UAVObjHandle obj;
|
||||||
static uint8_t type;
|
static uint8_t type;
|
||||||
static uint16_t packet_size;
|
static uint16_t packet_size;
|
||||||
@ -314,6 +313,7 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rxCount = 0;
|
rxCount = 0;
|
||||||
|
objId = 0;
|
||||||
state = STATE_OBJID;
|
state = STATE_OBJID;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -322,12 +322,13 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
|||||||
// update the CRC
|
// update the CRC
|
||||||
cs = updateCRCbyte(cs, rxbyte);
|
cs = updateCRCbyte(cs, rxbyte);
|
||||||
|
|
||||||
tmpBuffer[rxCount++] = rxbyte;
|
objId += rxbyte << (8*(rxCount++));
|
||||||
|
|
||||||
if (rxCount < 4)
|
if (rxCount < 4)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Search for object, if not found reset state machine
|
// Search for object, if not found reset state machine
|
||||||
objId = (tmpBuffer[3] << 24) | (tmpBuffer[2] << 16) | (tmpBuffer[1] << 8) | (tmpBuffer[0]);
|
|
||||||
obj = UAVObjGetByID(objId);
|
obj = UAVObjGetByID(objId);
|
||||||
if (obj == 0)
|
if (obj == 0)
|
||||||
{
|
{
|
||||||
@ -358,6 +359,7 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instId = 0;
|
||||||
// Check if this is a single instance object (i.e. if the instance ID field is coming next)
|
// Check if this is a single instance object (i.e. if the instance ID field is coming next)
|
||||||
if (UAVObjIsSingleInstance(obj))
|
if (UAVObjIsSingleInstance(obj))
|
||||||
{
|
{
|
||||||
@ -366,7 +368,7 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
|||||||
state = STATE_DATA;
|
state = STATE_DATA;
|
||||||
else
|
else
|
||||||
state = STATE_CS;
|
state = STATE_CS;
|
||||||
instId = 0;
|
|
||||||
rxCount = 0;
|
rxCount = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -382,12 +384,11 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
|
|||||||
// update the CRC
|
// update the CRC
|
||||||
cs = updateCRCbyte(cs, rxbyte);
|
cs = updateCRCbyte(cs, rxbyte);
|
||||||
|
|
||||||
tmpBuffer[rxCount++] = rxbyte;
|
instId += rxbyte << (8*(rxCount++));
|
||||||
|
|
||||||
if (rxCount < 2)
|
if (rxCount < 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
instId = (tmpBuffer[1] << 8) | (tmpBuffer[0]);
|
|
||||||
|
|
||||||
rxCount = 0;
|
rxCount = 0;
|
||||||
|
|
||||||
// If there is a payload get it, otherwise receive checksum
|
// If there is a payload get it, otherwise receive checksum
|
||||||
|
Loading…
Reference in New Issue
Block a user