Sign in to follow this  
Andre

Capture Incoming Data

Recommended Posts

I am working on a new project and need to capture data from the Comm monitor after triggering the device to dump the data. I have two triggering options.

Option 1

Device.DeviceName.SetRegisterS16(247,103,1)

Option 2

device.DeviceName.Write(chr(1))

 

Is there any way I can capture the incoming data? The data will need to be loaded into an array. In total 94 values will be dumped.  

Share this post


Link to post
Share on other sites

Here is an example of the data that is generated from the device.

Tx: \001
Rx: \076\097\115\116\032\080\097\103\101\032\114\101\099\111\114\100\101\100\032\032\049\048\032\111\102\032\050\048\052\055\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013

Share this post


Link to post
Share on other sites

That is all ASCII data.  Uncheck the box in the monitor that says "Display ASCII chars as codes" and you will see.  To capture the data, just do a bunch of readuntil(10) commands until it times out, then stick the result of each into a string or wherever else you want.  I see multiple lines of ASCII data, so readuntil(10) will work a number of times, then when done it will time out.  If the response is always a certain number of lines, you can repeat readuntil(10) that many times in a for() loop, and then stop.

You should probably do a purge() before doing the write() to trigger the response.

 

Share this post


Link to post
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
Sign in to follow this