mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +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)
|
||||
{
|
||||
char buf[256]; // no fucking idea
|
||||
char *c;
|
||||
int i, j;
|
||||
int i, j, k, flag = 1, count = 0, len;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
for (i = 0; i < CHECKBOXITEMS; i++) {
|
||||
for (j = 0; j < numberBoxItems; j++) {
|
||||
if (boxes[i].boxIndex == availableBoxes[j])
|
||||
strcat(buf, boxes[i].boxName);
|
||||
reset:
|
||||
for (i = 0; i < numberBoxItems; i++) {
|
||||
for (j = 0; j < CHECKBOXITEMS; j++) {
|
||||
if (boxes[j].boxIndex == availableBoxes[i]) {
|
||||
len = strlen(boxes[j].boxName);
|
||||
if (flag) {
|
||||
count += len;
|
||||
} else {
|
||||
for (k = 0; k < len; k++)
|
||||
serialize8(boxes[j].boxName[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headSerialReply(strlen(buf));
|
||||
for (c = buf; *c; c++)
|
||||
serialize8(*c);
|
||||
if (flag) {
|
||||
headSerialReply(count);
|
||||
flag = 0;
|
||||
goto reset;
|
||||
}
|
||||
}
|
||||
|
||||
void serialInit(uint32_t baudrate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue