Summary: Add USART2 serial message processing

Description: 
1.  Update configs subdir files with high speed USART2 serial baud rate.  Update Makefile with high speed USART1 baud rate
2.  Implement Nextion serial message processing from USART2.  This allows the Nextion display to be connected to the Nextion port on the hotspot PCB (Modem board).  SerialPort.cpp and SerialPort.h updated.
Tested on Simplex ZumSpot-RPi using 3.4" Nextion display and PD0DIB's "Model 8 - 3.5inch_GLOBE-SIMPLEX_v1.2" screens, with two touch areas ('REBOOT' and 'POWEROFF').
3.  Update README.md.

Test:  RPi 3B+ running Pi-Star:4.0.0-RC3, with ZumSpot-Rpi running 1.4.16 (updated with these changes) and using ON7LDS Nextion driver.

Feel free to improve these changes for use with PD0DIB's Nextion display pages.
pull/97/head
Garry Kraemer 7 years ago
parent 139eb95b66
commit 88455a50dd

@ -421,46 +421,46 @@ stlink-bl-old:
$(ST_FLASH) write bin/$(BINBIN_F1BL) 0x8002000
serial:
$(STM32FLASH) -v -w bin/$(BINBIN_F1) -g 0x0 $(devser)
$(STM32FLASH) -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 $(devser)
serial-nobl:
$(STM32FLASH) -v -w bin/$(BINBIN_F1NOBL) -g 0x0 $(devser)
$(STM32FLASH) -b 115200 -v -w bin/$(BINBIN_F1NOBL) -g 0x0 $(devser)
serial-bl:
$(STM32FLASH) -v -w $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13_long_rst.bin -g 0x0 $(devser)
$(STM32FLASH) -b 115200 -v -w $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13_long_rst.bin -g 0x0 $(devser)
sleep 3
$(STM32FLASH) -v -w bin/$(BINBIN_F1BL) -g 0x0 -S 0x08002000 $(devser)
$(STM32FLASH) -b 115200 -v -w bin/$(BINBIN_F1BL) -g 0x0 -S 0x08002000 $(devser)
serial-bl-old:
$(STM32FLASH) -v -w $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13.bin -g 0x0 $(devser)
$(STM32FLASH) -b 115200 -v -w $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13.bin -g 0x0 $(devser)
sleep 3
$(STM32FLASH) -v -w bin/$(BINBIN_F1BL) -g 0x0 -S 0x08002000 $(devser)
$(STM32FLASH) -b 115200 -v -w bin/$(BINBIN_F1BL) -g 0x0 -S 0x08002000 $(devser)
nano-hotspot:
ifneq ($(wildcard /usr/local/bin/stm32flash),)
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 200,-3,3:-200,3 /dev/ttyAMA0
/usr/local/bin/stm32flash -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 200,-3,3:-200,3 /dev/ttyAMA0
endif
ifneq ($(wildcard /usr/bin/stm32flash),)
/usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 200,-3,3:-200,3 /dev/ttyAMA0
/usr/bin/stm32flash -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 200,-3,3:-200,3 /dev/ttyAMA0
endif
nano-dv:
ifneq ($(wildcard /usr/local/bin/stm32flash),)
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 66,-67,67:-66,67 /dev/ttyAMA0
/usr/local/bin/stm32flash -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 66,-67,67:-66,67 /dev/ttyAMA0
endif
ifneq ($(wildcard /usr/bin/stm32flash),)
/usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 66,-67,67:-66,67 /dev/ttyAMA0
/usr/bin/stm32flash -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 66,-67,67:-66,67 /dev/ttyAMA0
endif
zumspot-pi:
ifneq ($(wildcard /usr/local/bin/stm32flash),)
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0
/usr/local/bin/stm32flash -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0
endif
ifneq ($(wildcard /usr/bin/stm32flash),)
/usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0
/usr/bin/stm32flash -b 115200 -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0
endif
mmdvm_hs_hat: zumspot-pi

@ -262,11 +262,12 @@ Install the necessary software tools:
sudo apt-get update
sudo apt-get install gcc-arm-none-eabi gdb-arm-none-eabi libstdc++-arm-none-eabi-newlib libnewlib-arm-none-eabi
cd ~
git clone https://git.code.sf.net/p/stm32flash/code stm32flash
cd stm32flash
make
sudo make install
Note: The Pi-Star image contains an executable for stm32flash. The next five steps can be skipped!
# cd ~
# git clone https://git.code.sf.net/p/stm32flash/code stm32flash
# cd stm32flash
# make
# sudo make install
Download the firmware sources:

@ -82,6 +82,9 @@ CSerialPort::CSerialPort() :
m_buffer(),
m_ptr(0U),
m_len(0U),
m_serial_buffer(),
m_serial_ptr(0U),
m_serial_len(0U),
m_debug(false),
m_firstCal(false)
{
@ -136,7 +139,7 @@ void CSerialPort::getStatus()
reply[3U] |= 0x10U;
if (m_pocsagEnable)
reply[3U] |= 0x20U;
reply[4U] = uint8_t(m_modemState);
reply[5U] = m_tx ? 0x01U : 0x00U;
@ -253,7 +256,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
uint8_t colorCode = data[6U];
if (colorCode > 15U)
return 4U;
#if defined(DUPLEX)
uint8_t dmrDelay = data[7U];
#endif
@ -317,7 +320,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
nxdnTX.setTXDelay(txDelay);
pocsagTX.setTXDelay(txDelay);
dmrDMOTX.setTXDelay(txDelay);
#if defined(DUPLEX)
dmrTX.setColorCode(colorCode);
dmrRX.setColorCode(colorCode);
@ -536,7 +539,7 @@ void CSerialPort::start()
beginInt(1U, 115200);
#if defined(SERIAL_REPEATER) || defined(SERIAL_REPEATER_USART1)
beginInt(3U, 9600);
beginInt(3U, SERIAL_REPEATER_BAUD);
#endif
}
@ -859,12 +862,62 @@ void CSerialPort::process()
}
#if defined(SERIAL_REPEATER) || defined(SERIAL_REPEATER_USART1)
// Drain any incoming serial data
// Check for any incoming serial data from a device/screen on UART2
// !!Notice!! on powerup the Nextion screen dumps FF FF FF 88 FF FF FF to the serial port.
while (availableInt(3U))
readInt(3U);
{
uint8_t ch = readInt(3U);
// read UART2
m_serial_buffer[m_serial_ptr] = ch;
m_serial_ptr++;
// fill the buffer one char at a time
if (m_serial_len > 128)
m_serial_len = 0U;
// if length is > 128 reset it
else
m_serial_len++;
// increase length
}
if ((m_serial_buffer[m_serial_len - 3] == 0xFF) && (m_serial_buffer[m_serial_len - 2] == 0xFF) && (m_serial_buffer[m_serial_len - 1] == 0xFF))
{
serial.writeSerialRpt(m_serial_buffer, m_serial_len);
// if the last 3 bytes are FF's then the screen is done sending data so send the m_serial_buffer to serial.writeSerialRpt()
m_serial_ptr = 0U;
m_serial_len = 0U;
// set ptr and reset length of buffer data since last message was valid and get ready for new data
}
#endif
}
#if defined(SERIAL_REPEATER) || defined(SERIAL_REPEATER_USART1)
void CSerialPort::writeSerialRpt(const uint8_t* data, uint8_t length)
{
if (m_modemState != STATE_IDLE)
return;
uint8_t reply[131U];
reply[0U] = MMDVM_FRAME_START;
reply[1U] = 0U;
reply[2U] = MMDVM_SERIAL;
uint8_t count = 3U;
for (uint8_t i = 0U; i < length; i++, count++)
reply[count] = data[i];
reply[1U] = count;
writeInt(1U, reply, count);
}
#endif
void CSerialPort::writeDStarHeader(const uint8_t* header, uint8_t length)
{
if (m_modemState != STATE_DSTAR && m_modemState != STATE_IDLE)
@ -1187,7 +1240,7 @@ void CSerialPort::writeDebugI(const char* text, int32_t n1)
for (uint8_t i = 0U; text[i] != '\0'; i++, count++)
reply[count] = text[i];
reply[count++] = ' ';
reply[count++] = ' ';
i2str(&reply[count], 130U - count, n1);

@ -30,6 +30,10 @@ public:
void process();
#if defined(SERIAL_REPEATER) || defined(SERIAL_REPEATER_USART1)
void writeSerialRpt(const uint8_t* data, uint8_t length);
#endif
void writeDStarHeader(const uint8_t* header, uint8_t length);
void writeDStarData(const uint8_t* data, uint8_t length);
void writeDStarLost();
@ -65,6 +69,10 @@ private:
uint8_t m_buffer[256U];
uint8_t m_ptr;
uint8_t m_len;
uint8_t m_serial_buffer[128U];
uint8_t m_serial_ptr;
uint8_t m_serial_len;
bool m_debug;
bool m_firstCal;

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

@ -71,6 +71,7 @@
// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi):
#define SERIAL_REPEATER
#define SERIAL_REPEATER_BAUD 115200
// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled):
// #define SERIAL_REPEATER_USART1

Loading…
Cancel
Save

Powered by TurnKey Linux.