Page 1 of 1

MOD 5234 Using both serial ports

Posted: Tue Sep 07, 2021 6:17 pm
by Quickdeploy
We currently have an application that uses both serial ports. The issue is if we set the bootloader to 115200 it seem to override our 9600 baud in our main code. It seems like may our printf are competing with our serial reads and writes. Do we need to re-assign stdout or something? Can you re-assign to null or USB or something?

Sample of our code is very similar to some of you example code.
#define SERIALPORT_TO_USE (1) //0 for the main port, 1 for the 10pin aux serial port
#define BAUDRATE_TO_USE (9600)
#define STOP_BITS (1)
#define DATA_BITS (8)

#define SERIALPORT_TO_USE1 (0) //0 for the main port, 1 for the 10pin aux serial port
#define BAUDRATE_TO_USE1 (9600)
#define STOP_BITS1 (1)
#define DATA_BITS1 (8)

//Close the serial port incase it is already open.
SerialClose( SERIALPORT_TO_USE );
SerialClose( SERIALPORT_TO_USE1 );

//Open the serial port
fdserial = OpenSerial( SERIALPORT_TO_USE, BAUDRATE_TO_USE, STOP_BITS, DATA_BITS, eParityNone );
fd1 = OpenSerial( SERIALPORT_TO_USE1, BAUDRATE_TO_USE1, STOP_BITS1, DATA_BITS1, eParityNone );

Re: MOD 5234 Using both serial ports

Posted: Wed Sep 08, 2021 5:03 am
by pbreed
You need to call:

#include <iosys.h>
with your fd from openserial:
ReplaceStdio( 0, fd ); //stdin
ReplaceStdio( 1, fd ); //stdout aka printf etc...
ReplaceStdio( 2, fd ); //stderror