mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
rewrote box serialization to not use a buffer, also maybe fixed mismatched boxes in GUI (thx Luggi09)
git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@452 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
d63c1f0604
commit
5bbf2bc88d
1 changed files with 18 additions and 11 deletions
29
src/serial.c
29
src/serial.c
|
@ -201,21 +201,28 @@ void serializeNames(const char *s)
|
||||||
|
|
||||||
void serializeBoxNamesReply(void)
|
void serializeBoxNamesReply(void)
|
||||||
{
|
{
|
||||||
char buf[256]; // no fucking idea
|
int i, j, k, flag = 1, count = 0, len;
|
||||||
char *c;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
reset:
|
||||||
for (i = 0; i < CHECKBOXITEMS; i++) {
|
for (i = 0; i < numberBoxItems; i++) {
|
||||||
for (j = 0; j < numberBoxItems; j++) {
|
for (j = 0; j < CHECKBOXITEMS; j++) {
|
||||||
if (boxes[i].boxIndex == availableBoxes[j])
|
if (boxes[j].boxIndex == availableBoxes[i]) {
|
||||||
strcat(buf, boxes[i].boxName);
|
len = strlen(boxes[j].boxName);
|
||||||
|
if (flag) {
|
||||||
|
count += len;
|
||||||
|
} else {
|
||||||
|
for (k = 0; k < len; k++)
|
||||||
|
serialize8(boxes[j].boxName[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
headSerialReply(strlen(buf));
|
if (flag) {
|
||||||
for (c = buf; *c; c++)
|
headSerialReply(count);
|
||||||
serialize8(*c);
|
flag = 0;
|
||||||
|
goto reset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialInit(uint32_t baudrate)
|
void serialInit(uint32_t baudrate)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue