Jump to content
  • 0

Is it possible to receive UART TX and RX separately with WaveForms script?


hrkzkb

Question

I'm Japanese, so I apologize for my poor English.

I purchased ANALOG DISCOVERY 3 and would like to receive TX and RX separately.

I executed the script below, but TX and Rx are received together.

 

// Script using Protocol UART.

if(!('Protocol' in this)) throw "Please open the Protocol tool";

Protocol.Mode.text = "UART" // make sure UART tab is selected
Protocol.UART.TX.value = 2
Protocol.UART.RX.value = 3
Protocol.config()
Protocol.UART.Receiver() // reset receiver

print("")
for (;;) {
    wait(0.1)
    var rx = Protocol.UART.Receives()
    if (rx[0] != "") {
        var d = new Date()
        print("TX:" + d.getMinutes() + "m" + d.getSeconds() + 's:' + rx[0])
    }
    if (rx[1] != "") {
        var d = new Date()
        print("RX:" + d.getMinutes() + "m" + d.getSeconds() + 's:' + rx[1])
    }
}

Output
RX:54m20s:\x02J
RX:54m20s:\x03\x02J00000
RX:54m21s:\x03
RX:54m25s:\x02J
RX:54m25s:\x03\x02J00000
RX:54m26s:\x03
RX:54m30s:\x02J
RX:54m30s:\x03\x02J00000
RX:54m31s:\x03

If anyone knows how to receive them separately, I would appreciate it if you could let me know.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @hrkzkb

Your code seems to be good, TX and RX should be returned in rx[0] and rx[1]. and additional UARTs when enabled in rx[2,3]
For printable text use Receives (string list) and for raw values use ReceiveArrays (2d numeric array)

image.png

image.png

Protocol.UART.Receiver();
if(1){
    while(wait(0.1)) {
        var rx = Protocol.UART.Receives(); // text
        var d = new Date();
        if (rx[0].length()) print("TX:"+d.toISOString()+":"+rx[0]);
        if (rx[1].length()) print("RX:"+d.toISOString()+":"+rx[1]);
    }
}else{
    while(wait(0.1)) {
        var rx = Protocol.UART.ReceiveArrays(); // numeric
        var d = new Date();
        if (rx[0].length()) print("TX:"+d.toISOString()+":"+rx[0]);
        if (rx[1].length()) print("RX:"+d.toISOString()+":"+rx[1]);
    }
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...