I have telnet attempting to talk to a serial port on a custom board (based on the TIVA TM4C1294XL Enet_s2e application). This is basically the EK-TM4C1294XL with a additional serial port at Port c, pins 5,6,7 (UCA0). The same board is setup to bridge data from the USB to the same serial port. The serial port requires a GPIO actuated to transmit (Port C pin5). The USB to serial bridge works fine. In fact I see data on the telnet port when the USB to serial bridge is talking (in either direction). In order to get the Telent to send data to the serial port I have to actuate the GPIO pin. Using the smae software in the telnet side that I use with the serial port messes up many telnet values.
When SerialSend() in telent.c sends a character to the TX FIFO it does not actuated the TEST_485_EN. If I take the code from the serial_task.c routine that performs the same function successfully, it badly messes up the telnet code. ui32Port, which should be 0 or 1 goes to a large bogus number. I imagine the assert statement disables all IO at that point. Commenting out the two ROM_GPIOPinWrite statements returns everything back to normal?? Guess I could bit bang th UCAx??? control registers.
serial.c, which is only called only by telnet:
============================================================
void SerialSend(uint32_t ui32Port, uint8_t ui8Char)
{
ASSERT(ui32Port < MAX_S2E_PORTS); // Check the arguments.
//
// Disable the UART transmit interrupt while determining how to handle this
// character. Failure to do so could result in the loss of this character,
// or stalled output due to this character being placed into the UART
// transmit buffer but never transferred out into the UART FIFO.
//
UARTIntDisable(g_ui32UARTBase[ui32Port], UART_INT_TX);
if(RingBufEmpty(&g_sTxBuf[ui32Port]) && (UARTSpaceAvail(g_ui32UARTBase[ui32Port])))
{
// ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 1); // SET 485 TALK HERE GAA 03Nov2017
UARTCharPut(g_ui32UARTBase[ui32Port], ui8Char); // Write this character directly into the FIFO.
// ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0); // CLR 485 listen HERE GAA 03Nov2017
}
else if(!RingBufFull(&g_sTxBuf[ui32Port])) // See if there is room in the transmit buffer.
{
RingBufWriteOne(&g_sTxBuf[ui32Port], ui8Char); // Put this character into the transmit buffer.
}
UARTIntEnable(g_ui32UARTBase[ui32Port], UART_INT_TX); // Enable the UART transmit interrupt.
}
============================================================
The SerialTask() which blocks waiting on events from the serial ISR uses this approach successfully:
============================================================static void SerialTask(void *pvParameters)
{
tSerialEvent sEvent;
while(1) // Loop forever.
{
xQueueReceive(g_QueSerial, (void*) &sEvent, portMAX_DELAY); // Block until a message is put in queue by the interrupt handler.
if(sEvent.eEventType == RX)
{
if((g_sParameters.sPort[sEvent.ui8Port].ui8Flags & // If Telnet protocol is enabled, check for incoming IAC character,
PORT_FLAG_PROTOCOL) == PORT_PROTOCOL_TELNET)
{
if((sEvent.ui8Char == TELNET_IAC) && // If this is a Telnet IAC character, write it twice.
(RingBufFree(&g_sRxBuf[sEvent.ui8Port]) >= 2))
{
RingBufWriteOne(&g_sRxBuf[sEvent.ui8Port], sEvent.ui8Char);
RingBufWriteOne(&g_sRxBuf[sEvent.ui8Port], sEvent.ui8Char);
}
else if((sEvent.ui8Char != TELNET_IAC) && // If not a Telnet IAC character, only write it once.
(RingBufFree(&g_sRxBuf[sEvent.ui8Port]) >= 1))
{
RingBufWriteOne(&g_sRxBuf[sEvent.ui8Port], sEvent.ui8Char);
}
}
else // If not Telnet, then only write the data once.
{
RingBufWriteOne(&g_sRxBuf[sEvent.ui8Port], sEvent.ui8Char);
}
}
else // Check if it's a TX interrupt
{
while(!RingBufEmpty(&g_sTxBuf[sEvent.ui8Port]) && // Loop while there is space in the transmit FIFO
UARTSpaceAvail(g_ui32UARTBase[sEvent.ui8Port]))
{
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 1); // SET 485 TALK HERE
UARTCharPut(g_ui32UARTBase[sEvent.ui8Port],
RingBufReadOne(&g_sTxBuf[sEvent.ui8Port])); // Write the next character into the transmit FIFO.
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0); // CLR 485 listen HERE
}
}
}
}