-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed sending message from PC / Fix for ENABLE_MESSENGER_UART #120
Changes from 2 commits
bfe941d
d6b86fe
faa0ef2
518debd
5b9d0b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,13 @@ | |
#include "sram-overlay.h" | ||
#endif | ||
#include "version.h" | ||
#ifdef ENABLE_MESSENGER | ||
#ifdef ENABLE_MESSENGER_UART | ||
#include "app/messenger.h" | ||
#include "external/printf/printf.h" | ||
#endif | ||
#endif | ||
|
||
|
||
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer)) | ||
|
||
|
@@ -212,7 +219,7 @@ static void CMD_0514(const uint8_t *pBuffer) | |
#endif | ||
|
||
gSerialConfigCountDown_500ms = 12; // 6 sec | ||
|
||
// turn the LCD backlight off | ||
BACKLIGHT_TurnOff(); | ||
|
||
|
@@ -260,7 +267,7 @@ static void CMD_051D(const uint8_t *pBuffer) | |
return; | ||
|
||
gSerialConfigCountDown_500ms = 12; // 6 sec | ||
|
||
bReloadEeprom = false; | ||
|
||
#ifdef ENABLE_FMRADIO | ||
|
@@ -369,6 +376,31 @@ bool UART_IsCommandAvailable(void) | |
if (gUART_WriteIndex == DmaLength) | ||
return false; | ||
|
||
#ifdef ENABLE_MESSENGER | ||
#ifdef ENABLE_MESSENGER_UART | ||
|
||
if (UART_DMA_Buffer[gUART_WriteIndex] == 'S' && UART_DMA_Buffer[gUART_WriteIndex + 1] == 'M' && UART_DMA_Buffer[gUART_WriteIndex + 2] == 'S' && UART_DMA_Buffer[gUART_WriteIndex + 3] == ':') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was also wondering if we need to require data to start with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh nevermind I guess reading from CHIRP would then trigger message send. Perhaps in the future it should be limited to only when messenger screen is active. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe |
||
{ | ||
|
||
char txMessage[PAYLOAD_LENGTH + 4]; | ||
memset(txMessage, 0, sizeof(txMessage)); | ||
snprintf(txMessage, (PAYLOAD_LENGTH + 4), "%s", &UART_DMA_Buffer[gUART_WriteIndex + 4]); | ||
|
||
for (int i = 0; txMessage[i] != '\0'; i++) | ||
{ | ||
if (txMessage[i] == '\r' || txMessage[i] == '\n') | ||
txMessage[i] = '\0'; | ||
} | ||
if (strlen(txMessage) > 0) | ||
{ | ||
MSG_Send(txMessage); | ||
UART_printf("SMS>%s\r\n", txMessage); | ||
gUpdateDisplay = true; | ||
} | ||
} | ||
|
||
#endif | ||
#endif | ||
while (gUART_WriteIndex != DmaLength && UART_DMA_Buffer[gUART_WriteIndex] != 0xABU) | ||
gUART_WriteIndex = DMA_INDEX(gUART_WriteIndex, 1); | ||
|
||
|
@@ -442,7 +474,7 @@ bool UART_IsCommandAvailable(void) | |
for (i = 0; i < (Size + 2u); i++) | ||
UART_Command.Buffer[i] ^= Obfuscation[i % 16]; | ||
} | ||
|
||
CRC = UART_Command.Buffer[Size] | (UART_Command.Buffer[Size + 1] << 8); | ||
|
||
return (CRC_Calculate(UART_Command.Buffer, Size) != CRC) ? false : true; | ||
|
@@ -455,33 +487,33 @@ void UART_HandleCommand(void) | |
case 0x0514: | ||
CMD_0514(UART_Command.Buffer); | ||
break; | ||
|
||
case 0x051B: | ||
CMD_051B(UART_Command.Buffer); | ||
break; | ||
|
||
case 0x051D: | ||
CMD_051D(UART_Command.Buffer); | ||
break; | ||
|
||
case 0x051F: // Not implementing non-authentic command | ||
break; | ||
|
||
case 0x0521: // Not implementing non-authentic command | ||
break; | ||
|
||
case 0x0527: | ||
CMD_0527(); | ||
break; | ||
|
||
case 0x0529: | ||
CMD_0529(); | ||
break; | ||
|
||
case 0x052F: | ||
CMD_052F(UART_Command.Buffer); | ||
break; | ||
|
||
case 0x05DD: | ||
#if defined(ENABLE_OVERLAY) | ||
overlay_FLASH_RebootToBootloader(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include "bsp/dp32g030/syscon.h" | ||
#include "bsp/dp32g030/uart.h" | ||
#include "driver/uart.h" | ||
#include "external/printf/printf.h" | ||
|
||
static bool UART_IsLogEnabled; | ||
uint8_t UART_DMA_Buffer[256]; | ||
|
@@ -102,3 +103,16 @@ void UART_LogSend(const void *pBuffer, uint32_t Size) | |
UART_Send(pBuffer, Size); | ||
} | ||
} | ||
|
||
void UART_printf(const char *str, ...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we reuse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not for debug, but for send/recv via serial port. I think it should not be mixed. |
||
{ | ||
char text[256]; | ||
int len; | ||
|
||
va_list va; | ||
va_start(va, str); | ||
len = vsnprintf(text, sizeof(text), str, va); | ||
va_end(va); | ||
|
||
UART_Send(text, len); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this refactor. Good job!