frame

NUCLEO-F401RE and X-NUKLEO-PLM01A1

I have Nucleo F401RE board connected trough USB port and communicating with PC over virtual serial port. This set up works fine. To control PLM ad on board, I need to send data trough another serial port. How to create second port? For instance port 1, or port 2, and exchange data between actual and virtual ports?

Comments

  • Hi igninja,

    Here you can find a simple example code for using different serial ports with different baud rates.
    Here the doc of our Serial Class.

    Hepo this can help you 
    Matteo Cipriani
    Zerynth Support Team
  • Dear Matteo, thanks. It helps to set up additional serial ports. The only question I have - how to change default bode rate to 57600 from 115200?
  • Hi igninja,

    if you want to change the baud rate you can use the 'baud' argument when you define your serial entity (even the default one).

    If you need that the same serial port uses two different baud rates (switching one to the other), you have to close the serial port and initialize it again with the new baud value (and vice-versa). 

    Keep me posted :)
    Matteo Cipriani
    Zerynth Support Team
  • Hi Matteo,
    I modified sample program. It works, but bode rate is 115200.

    import streams

    host=streams.serial(SERIAL0,baud=57600,set_default=True)
    modem = streams.serial(SERIAL2,baud=9600,set_default=False)

    while True:
        print("Write some chars on the serial port and terminate with \\n (new line)")
        line=host.readline() # read and return any single character available on the serial port until a \n is found
        print("You wrote:", line)
        print()
        #line=modem.readline()
        sleep (300)


  • Hi igninja,

    sorry for the late answer; my bad, I forget to tell you that, because of the Zerynth Uplinker uses the SERIAL0 to load bytecode data, in some devices this port remains open and to change the baud rate you have to close and open it again; try this code:
    ser0 = streams.serial()
    ser0.close()
    ser0 = streams.serial(SERIAL0, baud=57600,set_default=True)
    Keep me posted!
    Matteo Cipriani
    Zerynth Support Team
Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.