UART TCP/python scripting

Hi,

I’m trying to read and write data over the UART via a tcp/python script but am having some trouble. I think TX operations are successful but I’m failing to properly read data.

Background
My goal is to use the Otii to enter a DUT bootloader by toggling the otii arc GPO pins, then be able to dynamically read/write data to program/configure the DUT. Once programed/configured, use the otii to characterize the power consumption. Ideally this is all handled through the Otii arc.

Questions

  1. Is there an example of reading and writing UART data via the TCP client/python or other?
  2. Are there any limitations on dynamically reading and writing data? I ask because it looks like I may be receiving data but only after I stop a recording. This wouldn’t really be appropriate given my use case. It feels like I shouldn’t have to start/stop a recording every time I want to fetch a response from the DUT.
  3. Is the correct approach to start a recording and use “get_channel_data()” or is there another approach to reading Rx traffic?

Any other pointers would be helpful.

Thanks!
jay

Hi Jay,

  1. No, we do not have any Python example available for download but if you create a case in our case system, then I am happy to share with you my demo script in Python that reads and analyses UART RX.
  2. Yes, but the only limitations are that you should have a recording running and that the maximum length, excluding CRLF, is 56 symbols in one line.
    Are you adding CR and LF in your TX text? (\l \n)
  3. Yes, use something like the below:
    recording = project.get_last_recording();
    count = recording.get_channel_data_count(my_arc.id, “rx”);
    rx_data = recording.get_channel_data(my_arc.id, “rx”, 0, count);

Best regards,
Björn

Thanks Bjorn,

I will follow up with a case.

  1. There aren’t CR/LF transmitted from my script or the DUT. The DUT bootloader uses very simple commands, single bytes or byte pairs to trigger actions. Is it possible that I’m not getting data because there are no CR/LFs, i.e. perhaps otii is waiting for a complete line before letting me fetch the data?

Thanks
jay

Hi Jay,

Yes, that is most likely the issue. Add CR and or LF, that should do the trick.

Best regards,
Björn

Hi, @bjorn.rosqvist. My DUT is a third-party component of the actual device. It sends by UART status messages with pre and post delimiters which are somewhat configurable (’<’ and ‘>’, for example) but CR and LR are not an option.

I made a temporal workaround connecting the DUT UART to an Arduino, which passes it through to its USB serial port, and inserts an CR when it detects an ‘>’. Then I connected the USB to my computer and configured it in Otii / Project Settings / UART / Logs (great feature, by the way!).

It worked like a charm. Now Otii can log the DUT status messages.

However, this requires an additional piece of hardware and USB port and adds a possible current/induction loop I’m not confortable with.

So… There is any chance of implementing in Otii a configurable terminating character or string? That would be great.

Hi,

Thank you so much for this, it is very valuable to get feedback and improvement suggestions from you.
I will add this feature as a customer request in our backlog.
However, I cannot make any promises if and when this will be implemented.

Best regards,
Björn

1 Like