Jump to content
  • 0

Can AD2 sniff bidirectional UART @ 115200baud?


potatohead

Question

Hi folks!

I'm thinking of buying an Analog Discovery 2.

One piece of functionality I need is sniffing a serial connection between two devices. Not just a set number of samples - I mean capturing both TX and RX bytes to file/PC memory, for however many hours I need to catch my nasty little bug. 

 

The actual amount of data transfered is low. I'm actually utilizing maybe 30% of the capacity, at around 10kB/s TX and RX.

 

On top of that, I'd like to add support for my custom software protocol that's running on the UART. Kind of like in wireshark you can see what a packet is, not just a plaintext context-less byte barf. If waveforms doesn't support this, I'm completely fine with writing an utility that, say, takes raw UART data over loopback TCP and formats it externally.

 

Is this possible on the Analog DIscovery? What settings should I be using to make it work like that?

 

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

Hi @potatohead

You can install and use the WaveForms application in demo mode to explore the features. https://reference.digilentinc.com/waveforms3
The WaveForms SDK provides access to control the device and capture raw data. The SDK is included in the WF installer.
The WF application Protocol tool supports continuous capture of one UART line.
In the Logic Analyzer interface you can add and decode multiple UART lines but at limited record or short repeated captures.
In case you know the what you want to capture you can use the various trigger options, on UART value or pulse length, glitch, timeout...

image.png.c711450603d630b590e1923bbc49370a.png

Link to comment
Share on other sites

On 26.02.2018 at 11:34 AM, attila said:

The WF application Protocol tool supports continuous capture of one UART line.
In the Logic Analyzer interface you can add and decode multiple UART lines but at limited record or short repeated captures.

Sadly, if I knew what the bug looks like, I wouldn't need an analyzer in the first place. Thing is, I don't - it just fails some hours after init. 

I've hacked together two UART converters connectex RX and GND and it's working peachy. Only problem is I'll have to write my own analyzer to corellate the frames. Disappointing that AD2 can't handle sniffing a single UART. I think even my 5$ knockoff Saleae can do that. 

Link to comment
Share on other sites

Hi @potatohead

I would like to help you, but I would need more detail about the failure you are facing. 
How do you notice there is a failure? Can you hook any additional wire to trigger one? Or in case the UART communication stops you could trigger on this line with a pulse/timeout option with pre-trigger data...

The WF application lets you record 10M samples, which for 9.6k UART lines means several minutes.
The other brand you mentioned is more expensive than the AD2 and supports only logic analyzer.

Link to comment
Share on other sites

59 minutes ago, attila said:

Hi @potatohead

I would like to help you, but I would need more detail about the failure you are facing. 
How do you notice there is a failure? Can you hook any additional wire to trigger one? Or in case the UART communication stops you could trigger on this line with a pulse/timeout option with pre-trigger data...

The WF application lets you record 10M samples, which for 9.6k UART lines means several minutes.
The other brand you mentioned is more expensive than the AD2 and supports only logic analyzer.

The protocol is a simple assymetric master/slave one. The master device sends a fixed-width 1024 byte control frame, the slave device replies with a fixed-width 256 byte frame as soon as it can. 

Master sets timeout timer to 180s
Master sends 1024-byte frame
Slave receives processes and executes master frame. Commands that fetch catched data return immediately while blocking commands execute within 170s. 
Slave responds with 256-byte frame
Master registers 256 incoming bytes, kills the timeout timer and processes the frame. When the master has any more work to schedule it sends an appropriate 1024 byte data frame. If the master has nothing to schedule for the slave, it sends a 1024-byte prompt frame so the slave may report any pending messages it has for the master. In summary, the master always starts the transmission with a 1024 byte master frame, the slave always terminates the transmission with a 256 byte slave frame. 

If the master does not receive 256 bytes within 180s, it triggers an exception.

Depending on the day, this bug happened as early as 30 minutes/30mb in , or 3 days and 3gb in. It varies. 

 

Possible reasons why this might be happening:

Missing byte in master frame, causing the slave buffer to underrun and not have a valid command to respond to
Missing byte in slave response frame, causing the master buffer to underrun 

But those are just guesses. I'm figuring out what exactly is happening with two cheapo RS232 converters ATM.

 

Unfortunately we're running at 115200baud, so AD2's digital pins are too slow. The best we can do is get two AD2s listening to both UART lines at the same time, though I'm not sure how we'd integrate the results in one window. 

 


 

Link to comment
Share on other sites

Hi @potatohead

That would a lot of data to process... but I suppose you are interested in the last transmissions before timeout.
With WF app you could use the Logic Analyzer Record to capture the frames. WF v3.7.12-2 adds data compression for recording. In case there is at least ~50 ms (sufficient for capture and export) between master and slave transmission you could capture these in separate acquisitions. 
The Logic/ Logging can export the acquisitions, currently limited to 10k.
You could use the Script tool to repeat the captures until timeout is signalled.

image.thumb.png.c830b3b6f365cd48019bbd329def0942.png

Link to comment
Share on other sites

11 minutes ago, attila said:

Hi @potatohead

That would a lot of data to process... but I suppose you are interested in the last transmissions before timeout.
With WF app you could use the Logic Analyzer Record to capture the frames. WF v3.7.12-2 adds data compression for recording. In case there is at least ~50 ms (sufficient for capture and export) between master and slave transmission you could capture these in separate acquisitions. 
The Logic/ Logging can export the acquisitions, currently limited to 10k.
You could use the Script tool to repeat the captures until timeout is signalled.

image.thumb.png.c830b3b6f365cd48019bbd329def0942.png

That is an excellent approach - I can put delays in both master and slave code to enforce a minimum 50ms delay. Grabbing an AD2 from a nearby desk, will report with results.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...