Context:
I am currently working on a project involving data transmission from UART to SSH using a TM4C1294 microcontroller. The development environment is Code Composer Studio.
Problem Statement:
I'm experiencing issues with the formatting and completeness of data transmitted between UART and SSH. For example when trying to send this data;
Serial 0 is up, line protocol is up Hardware is MCI Serial Internet address is 150.136.190.203, subnet mask is 255.255.255.0 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, rely 255/255, load 1/255 Encapsulation HDLC, loopback not set, keepalive set (10 sec) Last input 0:00:07, output 0:00:00, output hang never Output queue 0/40, 0 drops; input queue 0/75, 0 drops Five minute input rate 0 bits/sec, 0 packets/sec Five minute output rate 0 bits/sec, 0 packets/sec 16263 packets input, 1347238 bytes, 0 no buffer Received 13983 broadcasts, 0 runts, 0 giants 2 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 2 abort 1 carrier transitions 22146 packets output, 2383680 bytes, 0 underruns 0 output errors, 0 collisions, 2 interface resets, 0 restarts
- UART to SSH: Data sent from UART to SSH gets truncated and only partial messages are received. For example, I try to send a detailed status message, but only the first part is received before it cuts off.
Serial 0 is up,
- SSH to UART: Data sent from SSH to UART does not preserve the intended layout. It should display as multi-line formatted text, but instead, it's coming through as one continuous line without any breaks.
Serial 0 is up, line protocol is up Hardware is MCI Serial Internet address is 150.136.190.203, subnet mask is 255.255.255.0 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, rely 255/255, load 1/255 Encapsulation HDLC, loopback not set, keepalive set (10 sec) Last input 0:00:07, output 0:00:00, output hang never Output queue 0/40, 0 drops; input queue 0/75, 0 drops Five minute input rate 0 bits/sec, 0 packets/sec Five minute output rate 0 bits/sec, 0 packets/sec 16263 packets input, 1347238 bytes, 0 no buffer Received 13983 broadcasts, 0 runts, 0 giants 2 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 2 abort1 carrier transitions 22146 packets output, 2383680 bytes, 0 underruns 0 output errors, 0 collisions, 2 interface resets, 0 restarts
What I've Tried:
- I've increased the UART buffer size to 1024 bytes to accommodate larger chunks.
- Checked and ensured that no overflow or buffer overrun errors are reported by the microcontroller.
- Experimented with different baud rates and settings to rule out communication speed and configuration issues.
Relevant Code Snippets:
UART Initialization and Read Function:
uint32_t UARTRead(uint32_t ui32Base, uint8_t *buffer, uint32_t length) { uint32_t i; for (i = 0; i < length; ++i) { if (!UARTCharsAvail(ui32Base)) break; buffer[i] = UARTCharGet(ui32Base); } return i; } void UARTWrite(uint32_t ui32Base, const uint8_t *buffer, uint32_t length) { for (uint32_t i = 0; i < length; ++i) { UARTCharPut(ui32Base, buffer[i]); } }
Session Handling in ShellServer:
void startSerialSession(ShellServerSession *session) { uint8_t uartBuffer[1024]; uint32_t uartBytesRead; while (1) { uartBytesRead = UARTCharsAvail(UART0_BASE) ? UARTRead(UART0_BASE, uartBuffer, sizeof(uartBuffer)) : 0; if (uartBytesRead > 0) { shellServerWriteStream(session, (char *)uartBuffer, uartBytesRead, NULL, 0); } char shellBuffer[1024]; size_t shellBytesReceived = 0; error_t readError = shellServerReadStream(session, shellBuffer, sizeof(shellBuffer), &shellBytesReceived, 0); if (readError == NO_ERROR && shellBytesReceived > 0) { UARTWrite(UART0_BASE, (uint8_t *)shellBuffer, shellBytesReceived); } osDelayTask(10); // To prevent CPU overload } }
Specific Question:
- How can I ensure that the entire data payload is transmitted without truncation and preserves the intended formatting?
- In the context of UART communications, what are the recommended strategies for explicitly handling special characters such as carriage returns and line feeds? How can I ensure these characters are correctly processed to maintain data formatting between UART and SSH?
- How critical is it to have synchronized hardware settings like baud rate, parity, and stop bits across communicating UART devices? Can slight discrepancies lead to significant communication errors, and how can I best verify and align these settings?
- I'm considering implementing CRC checks or a simpler checksum method to ensure data integrity during UART communication. Does anyone have advice on the most efficient methods to implement these checks in embedded systems, particularly for the TM4C1294 microcontroller?
Additional Details:
- Baud rate: 115190
- Data bits: 8
- Parity: None
- Stop bits: 1
- UART Config - Base: 0x4000C000, Clock: 120000000 Hz, Baud: 115190, Data Bits: 8 bits, Parity: None, Stop Bits: 1 stop bit, Flow Control: None Current configuration displayed.
Thank you for any suggestions or guidance you can provide!