Skip to content

Commit

Permalink
rewrote box serialization to not use a buffer, also maybe fixed misma…
Browse files Browse the repository at this point in the history
…tched boxes in GUI (thx Luggi09)

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@452 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
  • Loading branch information
timecop@gmail.com committed Oct 27, 2013
1 parent d63c1f0 commit 5bbf2bc
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,28 @@ void serializeNames(const char *s)

void serializeBoxNamesReply(void)
{
char buf[256]; // no fucking idea
char *c;
int i, j;

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);
int i, j, k, flag = 1, count = 0, len;

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)
Expand Down

0 comments on commit 5bbf2bc

Please sign in to comment.