MOD 5234 Using both serial ports

Discussion to talk about software related topics only.
Post Reply
Quickdeploy
Posts: 5
Joined: Fri Sep 03, 2021 10:12 pm

MOD 5234 Using both serial ports

Post 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 );
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: MOD 5234 Using both serial ports

Post 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
Post Reply