Fix UART context in serial passthrough
This commit is contained in:
committed by
Raphael Coeffic
parent
2b7e5f04fa
commit
4e08e8f6ad
+5
-2
@@ -1046,10 +1046,11 @@ int cliSet(const char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_SERIAL_PASSTHROUGH)
|
#if defined(ENABLE_SERIAL_PASSTHROUGH)
|
||||||
|
static void *spInternalModuleCTX = nullptr;
|
||||||
static void spInternalModuleTx(uint8_t* buf, uint32_t len)
|
static void spInternalModuleTx(uint8_t* buf, uint32_t len)
|
||||||
{
|
{
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
IntmoduleSerialDriver.sendByte(nullptr, *(buf++));
|
IntmoduleSerialDriver.sendByte(spInternalModuleCTX, *(buf++));
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1068,7 +1069,7 @@ static void spInternalModuleSetBaudRate(uint32_t baud)
|
|||||||
params.baudrate = baud;
|
params.baudrate = baud;
|
||||||
|
|
||||||
// re-configure serial port
|
// re-configure serial port
|
||||||
IntmoduleSerialDriver.init(¶ms);
|
spInternalModuleCTX = IntmoduleSerialDriver.init(¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use proper method instead
|
// TODO: use proper method instead
|
||||||
@@ -1131,6 +1132,7 @@ int cliSerialPassthrough(const char **argv)
|
|||||||
params.baudrate = baudrate;
|
params.baudrate = baudrate;
|
||||||
|
|
||||||
void* uart_ctx = IntmoduleSerialDriver.init(¶ms);
|
void* uart_ctx = IntmoduleSerialDriver.init(¶ms);
|
||||||
|
spInternalModuleCTX = uart_ctx;
|
||||||
|
|
||||||
// backup and swap CLI input
|
// backup and swap CLI input
|
||||||
auto backupCB = cliReceiveCallBack;
|
auto backupCB = cliReceiveCallBack;
|
||||||
@@ -1161,6 +1163,7 @@ int cliSerialPassthrough(const char **argv)
|
|||||||
// restore callsbacks
|
// restore callsbacks
|
||||||
cliSetBaudRateCb(nullptr);
|
cliSetBaudRateCb(nullptr);
|
||||||
cliReceiveCallBack = backupCB;
|
cliReceiveCallBack = backupCB;
|
||||||
|
spInternalModuleCTX = nullptr;
|
||||||
|
|
||||||
// and stop module
|
// and stop module
|
||||||
IntmoduleSerialDriver.deinit(uart_ctx);
|
IntmoduleSerialDriver.deinit(uart_ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user