Cannot read properly from UART with Thingy 91

Hi.

We are working on a project that needs to read several bytes from the UART using Thingy 91. Connectivity bridge is flashed in the 52840 SoC but the main project in the 9160 only manages to read 7 bytes from the UART. I've attached a sample that replicates the problem including a simple program in go which reads 2 files and sends them to the specified serial port (indicated as first argument). I've also recently updated the firmware.

6545.test.rar

Parents
  • Looking also for an alternative solution for this. 
    I found that it is the newline causing the receiving to be triggered as done. I could send however long a char:
    sending "hello world"

    D: uart evt 3
    T: rx_enable ret: 0
    D: uart evt 2
    T: hello world
    D: uart evt 4
    D: uart evt 5
    T:
    D: uart evt 3
    T: rx_enable ret: 0

    hello world is properly received.
    But when sending "hello 
    world", with a new line in-between the received msg becomes scrambled:
    D: uart evt 3
    T: rx_enable ret: 0
    D: uart evt 2
    worldllo
    D: uart evt 4
    D: uart evt 5
    T:
    D: uart evt 3
    T: rx_enable ret: 0


    Since you are sending certificates, as was I, hopefully a better solution comes up but mine was:
    switch to asynchronous uart api and prepare the certificates before sending them over by stripping all the newline characters and re-add them back in on the mcu.
    (Since the location of newlines for pem type certificates is after 64characters it's easy to find the correct location to add them back in)

  • I tried to do so, but unfortunately the problem persists. It keeps receiving the same 7 bytes everytime there is a message. I hope they can find another solution.

  • Hi.

    Thanks for the reply. I tried the provided example and it works fine using putty, but as soon as I close the terminal, it won't work again if I reopen it. Also, it doesn't receive anything if I try to send data using the program I provided before. In both cases it gets blocked and I even have to reset the thingy and recover the device in order to flash it again. Is there any idea of what is causing this?

  • Hi,

    1) What nRF Connect SDK version are you using?

    MarioDLH said:
    Also, it doesn't receive anything if I try to send data using the program I provided before. In both cases it gets blocked and I even have to reset the thingy and recover the device in order to flash it again. Is there any idea of what is causing this?

    2) These errors are happened after you closed the terminal, and opened it again? Before you closed the terminal, it was working as expected ?

  • I'm using version 2.0.0 currently. When I try sending data opening the port with an external program it doesn't work in any case. It can receive bytes using a terminal if I flash (or restart) the device with it previously opened. It's like it won't work if a serial connection isn't detected at the moment the example starts runnning.

  • Hi,

    MarioDLH said:
    It's like it won't work if a serial connection isn't detected at the moment the example starts runnning.

    Sorry for the delay. Try to add something like this:

    	/* Data Terminal Ready - check if host is ready to communicate */
    	while (!dtr) {
    		ret = uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
    		if (ret) {
    			LOG_ERR("Failed to get Data Terminal Ready line state: %d",
    				ret);
    			continue;
    		}
    		k_msleep(100);
    	}

    Example usage here.

Reply
  • Hi,

    MarioDLH said:
    It's like it won't work if a serial connection isn't detected at the moment the example starts runnning.

    Sorry for the delay. Try to add something like this:

    	/* Data Terminal Ready - check if host is ready to communicate */
    	while (!dtr) {
    		ret = uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
    		if (ret) {
    			LOG_ERR("Failed to get Data Terminal Ready line state: %d",
    				ret);
    			continue;
    		}
    		k_msleep(100);
    	}

    Example usage here.

Children
No Data
Related