CF/BF - Improve performance of mspSerialPush / MSP_DISPLAYPORT.
* avoiding the use of an unncessesary buffer and memcopy * the `pushBuf` was a fixed size * the size didn't correlate to the size of the buffer being passed in. * avoids repeating the memcpy for each port being used for MSP. * reduces ram usage.
This commit is contained in:
parent
ca5bafeab9
commit
b307007ac3
|
@ -44,7 +44,7 @@ PG_REGISTER(displayPortProfile_t, displayPortProfileMsp, PG_DISPLAY_PORT_MSP_CON
|
|||
|
||||
static displayPort_t mspDisplayPort;
|
||||
|
||||
static int output(displayPort_t *displayPort, uint8_t cmd, const uint8_t *buf, int len)
|
||||
static int output(displayPort_t *displayPort, uint8_t cmd, uint8_t *buf, int len)
|
||||
{
|
||||
UNUSED(displayPort);
|
||||
return mspSerialPush(cmd, buf, len);
|
||||
|
@ -52,7 +52,7 @@ static int output(displayPort_t *displayPort, uint8_t cmd, const uint8_t *buf, i
|
|||
|
||||
static int heartbeat(displayPort_t *displayPort)
|
||||
{
|
||||
const uint8_t subcmd[] = { 0 };
|
||||
uint8_t subcmd[] = { 0 };
|
||||
|
||||
// ensure display is not released by MW OSD software
|
||||
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
|
||||
|
@ -65,21 +65,21 @@ static int grab(displayPort_t *displayPort)
|
|||
|
||||
static int release(displayPort_t *displayPort)
|
||||
{
|
||||
const uint8_t subcmd[] = { 1 };
|
||||
uint8_t subcmd[] = { 1 };
|
||||
|
||||
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
|
||||
}
|
||||
|
||||
static int clearScreen(displayPort_t *displayPort)
|
||||
{
|
||||
const uint8_t subcmd[] = { 2 };
|
||||
uint8_t subcmd[] = { 2 };
|
||||
|
||||
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
|
||||
}
|
||||
|
||||
static int drawScreen(displayPort_t *displayPort)
|
||||
{
|
||||
const uint8_t subcmd[] = { 4 };
|
||||
uint8_t subcmd[] = { 4 };
|
||||
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
|
||||
}
|
||||
|
||||
|
|
|
@ -262,17 +262,10 @@ void mspSerialInit(void)
|
|||
mspSerialAllocatePorts();
|
||||
}
|
||||
|
||||
int mspSerialPush(uint8_t cmd, const uint8_t *data, int datalen)
|
||||
int mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
|
||||
{
|
||||
static uint8_t pushBuf[34];
|
||||
int ret = 0;
|
||||
|
||||
mspPacket_t push = {
|
||||
.buf = { .ptr = pushBuf, .end = ARRAYEND(pushBuf), },
|
||||
.cmd = cmd,
|
||||
.result = 0,
|
||||
};
|
||||
|
||||
for (int portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
|
||||
mspPort_t * const mspPort = &mspPorts[portIndex];
|
||||
if (!mspPort->port) {
|
||||
|
@ -284,9 +277,11 @@ int mspSerialPush(uint8_t cmd, const uint8_t *data, int datalen)
|
|||
continue;
|
||||
}
|
||||
|
||||
sbufWriteData(&push.buf, data, datalen);
|
||||
|
||||
sbufSwitchToReader(&push.buf, pushBuf);
|
||||
mspPacket_t push = {
|
||||
.buf = { .ptr = data, .end = data + datalen, },
|
||||
.cmd = cmd,
|
||||
.result = 0,
|
||||
};
|
||||
|
||||
ret = mspSerialEncode(mspPort, &push);
|
||||
}
|
||||
|
|
|
@ -73,5 +73,5 @@ bool mspSerialWaiting(void);
|
|||
void mspSerialProcess(mspEvaluateNonMspData_e evaluateNonMspData, mspProcessCommandFnPtr mspProcessCommandFn, mspProcessReplyFnPtr mspProcessReplyFn);
|
||||
void mspSerialAllocatePorts(void);
|
||||
void mspSerialReleasePortIfAllocated(struct serialPort_s *serialPort);
|
||||
int mspSerialPush(uint8_t cmd, const uint8_t *data, int datalen);
|
||||
int mspSerialPush(uint8_t cmd, uint8_t *data, int datalen);
|
||||
uint32_t mspSerialTxBytesFree(void);
|
||||
|
|
Loading…
Reference in New Issue