use both serial ports

I want to use both the serial ports on the development board. One port for outputting messages with printf() and the other one for writing out bytes with the normal open()/write() API functions.

Currently serial port 1 (/com/0) is used by printf(), how can I change this so it uses the other port?

(I need the first serial port for my application, the second serial port is optional for debugging, since it can only be used with modules that have a JTAG connector if I understand this correctly).

Edit the appconf.h file that is included with your project. Also, you’ll need to make sure that in bsp.h you’ve set the second serial port define to use a UART (i.e. set BSP_SERIAL_PORT_2 to BSP_SERIAL_UART_DRIVER).

I already found the answer myself:

In appconf.h:

/ad

  • APP_STDIO_PORT determines which serial port stdin, stdout, and stderr should be redirected to.
  • It should be set to the device name of the port or NULL.
  • @external
  • @category general_purpose
  • @since 1.0
    ad/
    #define APP_STDIO_PORT “/com/0”

And in bsp.h:

/ad

  • This constant controls which serial driver is built in
  • the BSP for serial port 1.
  • @since 6.0
  • @external
  • @category BSP_Configuration
  • @index BSP_SERIAL_PORT_1
  • @see @link SerialPortConfigurations
    ad/
    #define BSP_SERIAL_PORT_1 BSP_SERIAL_UART_DRIVER

/ad

  • This constant controls which serial driver is built in
  • the BSP for serial port 2.
  • @since 6.0
  • @external
  • @category BSP_Configuration
  • @see @link SerialPortConfigurations
    ad/
    #define BSP_SERIAL_PORT_2 BSP_SERIAL_NO_DRIVER

Is it true that only Digi devices with a JTAG connector have support for the second serial port?

Yes for the Digi Connect ME, as the second serial interface is provided through the JTAG interface. The Connect EM, however, allows access to a second 2 wire (TX + RX) serial interface.