This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART config rejected with error -134

Hi, I have an Adafruit Feather nRF52840 which I'm programming using SDK 3.1.1. I want the following UART config but it is being rejected with error -134 which I believe means "Unsupported value" (defined in Zephyr's errno.h header):

#define ENOTSUP 134         /**< Unsupported value */

Here's my config:

const struct uart_config uart_cfg = {
		.baudrate = 31250,
		.parity = UART_CFG_PARITY_NONE,
		.stop_bits = UART_CFG_STOP_BITS_1,
		.data_bits = UART_CFG_DATA_BITS_8,
		.flow_ctrl = UART_CFG_FLOW_CTRL_NONE
	};
	
	
// then later....

	err = uart_configure(uart, &uart_cfg);

	if (err) {
		printk("UART config failed with error %d\n",err);
		return err;
	}
	
// and in the console I see:
//
// 00> UART config failed with error -134

What is it about my requested configuration that is unsupported? It seems pretty standard to me. FYI this is the configuration for MIDI 1.0.

Thanks as always for your support

p.s. before switching to using Zephyr I was programming the board with Circuit Python and had no problem sending data over the UART in this way.

  • More information on this:

    My Adafruit Feather nRF52840 has a MIDI daughter board with 5-pin DIN sockets. I have its MIDI OUT connected to my PC using a special adapter cable. The USB end has active electronics which cause Windows to register it as a MIDI device. This has prevented me from engaging directly with the serial communications using (say) a terminal. Instead I use a MIDI monitor application to see the data being received.

    I've now got the Adafruit Feather connected to the serial interface of a Raspberry Pi rather than a Windows PC and have a simple script reading directly from the serial port and printing the bytes received from the Adafruit Feather. I've tried various baud rates but none result in the expected values being received and printed.

    The Adafruit Feather sends 

    static uint8_t noteON [3] = {144, 48, 100};

    and then 

    static uint8_t noteOFF [3] = {128, 48, 100};

    in an infinite loop.

    The script on the Raspberry Pi is this:

    import serial
    
    baudrates=[4800, 9600, 19200, 38400, 115200]
    num_br = len(baudrates)
    i=0
    
    while (i < num_br):
    
      br = baudrates[i]
      print("BAUDRATE: "+str(br))
      ser = serial.Serial('/dev/ttyAMA0', baudrate=br)
    
      data = ser.read(3)
      print("Decimal: "+str(data[0])+" "+str(data[1])+" "+str(data[2])+"\t\tBinary: "+format(data[0],'008b')+" "+format(data[1],'008b')+" "+format(data[2],'008b'))
    
      data = ser.read(3)
      print("Decimal: "+str(data[0])+" "+str(data[1])+" "+str(data[2])+"\t\tBinary: "+format(data[0],'008b')+" "+format(data[1],'008b')+" "+format(data[2],'008b'))
    
      data = ser.read(3)
      print("Decimal: "+str(data[0])+" "+str(data[1])+" "+str(data[2])+"\t\tBinary: "+format(data[0],'008b')+" "+format(data[1],'008b')+" "+format(data[2],'008b'))
    
      data = ser.read(3)
      print("Decimal: "+str(data[0])+" "+str(data[1])+" "+str(data[2])+"\t\tBinary: "+format(data[0],'008b')+" "+format(data[1],'008b')+" "+format(data[2],'008b'))
    
      i = i + 1
    
    print("FINISHED")

    The Serial object has the following parameters and defaults:

    classserial.Serial
    __init__(port=None, baudrate=9600, bytesize=EIGHTBITS, parity=PARITY_NONE, stopbits=STOPBITS_ONE, timeout=None, xonxoff=False, rtscts=False, write_timeout=None, dsrdtr=False, inter_byte_timeout=None, exclusive=None)

    The script overrides the default baud rate with a series of different values.

    This is the output:

    pi@raspberrypi:~/MIDI $ python ./autobaud_uart_test.py 
    BAUDRATE: 4800
    Decimal: 253 253 253		Binary: 11111101 11111101 11111101
    Decimal: 255 253 253		Binary: 11111111 11111101 11111101
    Decimal: 255 253 253		Binary: 11111111 11111101 11111101
    Decimal: 253 253 255		Binary: 11111101 11111101 11111111
    BAUDRATE: 9600
    Decimal: 239 231 231		Binary: 11101111 11100111 11100111
    Decimal: 239 255 255		Binary: 11101111 11111111 11111111
    Decimal: 231 255 239		Binary: 11100111 11111111 11101111
    Decimal: 255 231 255		Binary: 11111111 11100111 11111111
    BAUDRATE: 19200
    Decimal: 158 159 255		Binary: 10011110 10011111 11111111
    Decimal: 183 254 190		Binary: 10110111 11111110 10111110
    Decimal: 151 254 159		Binary: 10010111 11111110 10011111
    Decimal: 255 190 158		Binary: 11111111 10111110 10011110
    BAUDRATE: 38400
    Decimal: 255 163 111		Binary: 11111111 10100011 01101111
    Decimal: 250 255 235		Binary: 11111010 11111111 11101011
    Decimal: 175 250 254		Binary: 10101111 11111010 11111110
    Decimal: 235 111 250		Binary: 11101011 01101111 11111010
    BAUDRATE: 115200
    Decimal: 218 92 148		Binary: 11011010 01011100 10010100
    Decimal: 117 121 83		Binary: 01110101 01111001 01010011
    Decimal: 117 27 197		Binary: 01110101 00011011 11000101
    Decimal: 218 92 148		Binary: 11011010 01011100 10010100
    FINISHED

    None of the sets of data from the different baud rates matches the values being transmitted. There are other possible baud rates and the issue may have nothing to do with baud rates as such. But it does seem the config at the receiver is not the same as that of the transmitter i.e. the Adafruit Feather.

    FYI I've received and processed MIDI information using this same technique from Python and the same Raspberry Pi hardware many times so I'm confident this end of things is OK.

    Could there be a bug in the Zephyr UART driver that is resulting in mismatched configs? I know this is considerably less likely than the issue being with my code but it's at least theoretically possible.

    Hope someone can help with this. I think I'm now at a dead end.

    Thanks in anticipation

Related